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
提交
取消