-1

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver got this error also after adding sql-connector-jar to lib of dynamic web project.please help me with this.

  • How are you managing your dependencies? I don't know what "dynamic web project" means, but typically people use Maven or Gradle to manage a Java project and its dependencies. – ndc85430 Jun 12 '22 at 07:33

1 Answers1

0

at first you need to create a java project and name it after creating you can see a folder called referenced libraries down to your java project folder

so add your jar which is in this directory (if you have Mysql installed in your system ) C:\Program Files (x86)\MySQL\Connector J 8.0

in this folder you can find the .jar add to the referenced libraries and start executing the code it will work

or execute this Class.forName("com.mysql.cj.jdbc.Driver");

this might work