我添加了mysql-connector-java-5.1.19.jar,但我不知道为什么会出现错误。 driver is imported as shown in the image
public class data {
String server = "jdbc:mysql://localhost/";
String user = "root";
String pass = "toor";
public int starting() {
int id;
try {
Class.forName("com.mysql.jdbc.driver");
Connection incre = (Connection) DriverManager.getConnection("inc"+server, user, pass);
Statement statement = (Statement) incre.createStatement();
String select = "Select start from incr;";
ResultSet rs = (ResultSet) statement.executeQuery(select);
if(rs.next()){
id = rs.getInt("start");
}
incre.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
答案 0 :(得分:2)
Java区分大小写,而不是您需要的com.mysql.jdbc.driver
Class.forName("com.mysql.jdbc.Driver");
但是,对于现代JDBC驱动程序,这行根本不需要,所以我会尝试删除它。