Home > Blockchain >  Error: Could not find or load main class com.mysql.jdbc.DocsConnectionPropsHelper
Error: Could not find or load main class com.mysql.jdbc.DocsConnectionPropsHelper

Time:04-28

enter image description here

I am getting error when i load the driver,am i adding the driver correctly,Can someone help to resolve

CodePudding user response:

am i adding the driver correctly

I don't think so.

There is something very odd going on here. According to the official MySQL source code repo for Connector/J on Github, there is no com.mysql.jdbc.DocsConnectionPropsHelper class in Connector/J version 8.0.28. But this class does exist in Connector/J 5.1.x.

So it looks like you must somehow be using Connector/J 5.x rather than 8.0.x as the IDE screenshot seems to suggest.

Check the dependencies on the actual runtime classpath you are using to run this code. (Note that the screenshot shows the project's build classpath not its runtime classpath.)

Certainly you should not be mixing the two generations of driver. Calling RegisterDriver with the (8.0.x) com.mysql.cj.jdbc.Driver class when you have the 5.x driver on the classpath is wrong.

CodePudding user response:

you can try like this

Class.forName("com.mysql.cj.jdbc.Driver").newInstance();

  •  Tags:  
  • java
  • Related