Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by: jassen moran
Date: September 13, 2008 09:31AM

I had the same error:

Jdbc11.java:15: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName("com.mysql.jdbc.Driver");

After banging my head against the table and pulling out my hair, I found a thread in the forum with the solution: http://forums.mysql.com/read.php?39,195136,195136.

Apparently with the latest Connector/J, the following line of code is not needed:

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

Once I removed the line, my java program compiles successfully and runs! I didn't even need to add the mysql connector j jar path to my CLASSPATH.

I hope this helps someone.

My system environment
=======================================
JDK: 1.6.0_06
mysql-connector-java-5.1.6-bin.jar
linux 2.6.9
MySQL 5.0.45

Options: ReplyQuote


Subject
Written By
Posted
April 07, 2007 11:27PM
December 26, 2007 11:43AM
February 05, 2008 01:05AM
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
September 13, 2008 09:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.