您好,我正在尝试更新我的表格,但连接一直失败。以下是我的代码:
try {
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver).newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=convertToNull","root","P@typd79");
Statement stmt = con.createStatement();
String query = "INSERT INTO project_one.personal_info(ssn,name,street,city,state,zip,class,degree,s,imm) VALUES"
+ "(" + social + "," + Name + "," + Address + "," + City + "," + State + "," + Zip
+ "," + Year + "," + Degree + "," + HS + "," + IMM + ")";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null, "New student added successfully");
} catch (Exception e) {
JOptionPane.showMessageDialog(null,"Data not saved: " + e,"Error",JOptionPane.ERROR_MESSAGE);
}
}
连接名称和驱动程序正确,但出现以下错误java.lang.classnotfound.exeption:com.mysql.jdbc.Driver.
我错过了什么?