Osiris93
Osiris93

Reputation: 189

JDBC Driver connection not working in NetBeans IDE

I have created a login screen but each time I test it, I get the following error message: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I know my database connection coding is correct because I have used it before and no errors are displayed. I tried adding the database driver through this Stack Overflow How to connect NetBeans to MySQL database? but the problem persists and I have also ensured the database was connected in the driver.

How do I get the driver to work?

Upvotes: 0

Views: 9601

Answers (2)

Adi
Adi

Reputation: 11

Use Connection Properties button and add a property with field name serverTimezone and value UTC.

This should work if error was caused by timezone issue.

It worked for me on Netbeans 11.2 with jdbc driver jar 8.0.17

Upvotes: 1

Alex Minjun Yu
Alex Minjun Yu

Reputation: 3707

You need to download the MySql connector/J driver. It is essentially a jar file that looks something like this: mysql-connector-java-5.1.23-bin.jar Download here: http://dev.mysql.com/downloads/connector/j/

If you are building a dynamic web application, you need to put the jar file under the WEB-INF/lib folder.

If you are building a simple Java program, add this jar to your runtime build path. Regardless of what IDE you are using, adding jar file to your build path should be pretty easy.

Hope it helps.

Upvotes: 0

Related Questions