Questions | Login

Top / PHP / MySQL

MySQL-JAVA connectivity?

demo 21 Dec 2008 03:05am
Hey,
I have written a program in java & trying to do java-database connectivity but i am getting java.lang.classNotFoundException : com.mysql.jdbc.Driver not found . Could you please let me know how to get rid of this error, i.e. which drivers need to be installed & what should be the path of it. I am not using any IDE. I have simply made the program in a notepad & saved it on desktop.

Please help me ASAP. It's urgent.
Thank you
Regards,
Priya

Answers

demo 21 Dec 2008 03:14am
Since you are running this off your desktop, this is almost certainly a classpath issue.

Firstly, you'll need the JDBC driver for MySQL, if you don't already have it. You can find this driver here:

http://dev.mysql.com/downloads/connector/j/3.1.html

Once you've pulled the jar out of the zip file, be sure you include those jars when you execute your program. The way to do that from the command line is to use the -cp parameter. For example:

java -cp mysql-connector-java-1.3-bin.jar YourClass
demo 21 Dec 2008 03:25am
did you do it like:

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

If you are using Java6SE, use the built in Derby DB. If not, make sure you have the MySql running. MySql is part of EE, and it is a custom db if you download it separate and install it to use with SE.

Related

Submit Answer

You must be logged in to post an answer. Please Login or Register.

Powered by phpMyAnswers.