import java.sql.*;
public class JDBC {
public JDBC()
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try
Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/database=bookmisuser=root&password=202636");
Statement stat=conn.createStatement();
ResultSet rst=stat.executeQuery("select * from user");
while(rst.next())
{
System.out.println(rst.getString(1));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args)
{
new JDBC();
}
}Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/database=bookmisuser=root&password=202636");
这句驱动管理器设置报错。请大家帮忙解决一下
public class JDBC {
public JDBC()
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try
Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/database=bookmisuser=root&password=202636");
Statement stat=conn.createStatement();
ResultSet rst=stat.executeQuery("select * from user");
while(rst.next())
{
System.out.println(rst.getString(1));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args)
{
new JDBC();
}
}Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/database=bookmisuser=root&password=202636");
这句驱动管理器设置报错。请大家帮忙解决一下
String url = "jdbc:mysql://localhost:3306/mytest";
String uname = "root";
String psw = "****";
String sql = "select username, password from ***";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(url,uname,psw);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
从网上下载个,导入再试试
找找转意符替换了