MySQL Forums
Forum List  »  Microsoft SQL Server

Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by: Oliver f
Date: September 25, 2007 04:22PM

I had this problem also.
Solution involved doing 2 things:
1. Since I was using eclipse, I had to configure the build path within eclipse, NOT in the system environment variables.
To do this:
* (in Eclipse) Right-click on project folder and choose [Build path > add external archives]. Navigate to where you have the mysql-connector .jar file.

This should have fixed it, but there was also a bug in the code:

2. The string holding the select statement was over two lines, concatenated with a plus sign, i.e.

String select = "Select title, year, price"
+ "from movie order by year";

This works fine if select is passed to System.out.println(), but apparently the executeQuery(select) method doesn't like it. When the string is on one line it works, i.e.

String select = "Select title, year, price from movie order by year";

Hope that helps.



Edited 1 time(s). Last edit at 12/03/2010 01:09PM by Oliver f.

Options: ReplyQuote


Subject
Written By
Posted
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
September 25, 2007 04:22PM


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.