private static String url = "jdbc:mysql://127.0.0.1:3306/students";
private static String user = "root";
private static String password = null;
private static java.sql.Connection con = null;
static {
try {
Class.forName("com.mysql.jdbc.Driver");
//为什么会在上一句报错java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
con = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
e.printStackTrace();
}
}
添加回答
举报
0/150
提交
取消