1

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. Exception in thread "main" java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) at com.mysql.cj.jdbc.StatementImpl.checkForDml(StatementImpl.java:385) at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:983) at InsertJDBC.main(InsertJDBC.java:22)

suvojit_007
  • 1,690
  • 2
  • 17
  • 23
pooja
  • 21
  • 3

1 Answers1

1

In your Class.forName() change it to Class.forName("com.mysql.cj.jdbc.Driver") from Class.forName("com.mysql.jdbc.Driver").Although current java loads the drivers without the use of Class.forName("") provided the jar is recognised in the classpath

Ian Carson
  • 11
  • 2