数据库连接问题
package com.jdbc.test;
import java.beans.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
public class Testjdbc {
private static final String url="jdbc:mysql://127.0.0.1:3306/testdata";
private static final String user="root";
private static final String password="root";
public static void main(String[] args) throws Exception {
//1、加载驱动程序
Class.forName("com.mysql.jdbc.Driver") ;
//2、获得数据库的连接
Connection conn=DriverManager.getConnection(url, user, password);
//3、实现增删改查
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select id,name from testtable");
//上面两句提示错误,请高手教我,谢谢
while(rs.next()){
System.out.println(rs.getInt("id")+","+rs.getString("name"));
}
}
}