privatestaticString url = "jdbc:mysql://127.0.0.1:3306/students";
privatestaticString user = "root";
privatestaticString password = null;
privatestaticjava.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();
}
}