使用mysql运行JDBC程序时出现此错误

时间:2018-11-01 03:45:44

标签: java mysql jdbc

  

正在加载类com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'。司机是   通过SPI自动注册并手动加载驱动程序   通常不需要上课。线程“主”中的异常   java.sql.SQLException:无法使用以下命令发出数据操作语句   executeQuery()。在   com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)     在   com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)     在   com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)     在   com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)     在   com.mysql.cj.jdbc.StatementImpl.checkForDml(StatementImpl.java:385)     在   com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:983)     在InsertJDBC.main(InsertJDBC.java:22)

1 个答案:

答案 0 :(得分:0)

在您的Class.forName()中将其更改为 来自的Class.forName(“ com.mysql.cj.jdbc.Driver”) Class.forName(“ com.mysql.jdbc.Driver”)。尽管当前的Java在不使用Class.forName(“”)的情况下加载驱动程序,只要在类路径中可以识别该罐子

相关问题