• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException with MySql and Netbeans

 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I am using Netbeans 6.0.1 and I've installed MySql on Fedora 8...I 've been able to configure the jdbc-MySql connector that's bundled with Netbeans and I can create tables and query MySql using the Netbeans GUI.So I guess my connection was correct...My connection properties are as follows:

Database URL -jdbc:mysql://localhost:3306/test
Driver -com.mysql.jdbc.Driver

But when I execute the code below I get a ClassNotFoundException:



I get the following output:

init:
deps-jar:
compile:
run:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

BUILD SUCCESSFUL (total time: 4 seconds)

Any pointers to what I am doing wrong will be greatly appreciated...Thanks in advance...
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like that you have not included mysql JDBC driver in your project classpath.

right click on project, select libraries and see whether you have mysql under Run tab or not, in case that you can not see mysql as one of the libraries which your project use, then add it from the libraries list.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you downloaded Connector/J, mysql-connector-java-5.0.8-bin.jar.

It's a separate download from mysql.org. It comes in a zip file I think, so you don't put the zip on the classpath, but unzip the zip, and fild the file named something like: mysql-connector-java-5.0.8-bin.jar.

Do a search on your filesystem for mysql-connector*.jar. See if you can find the jar file anywhere. If you can, it's not in the right place. If you can't then you need to get it, and THEN put it in the right place.

Good luck!

-Cameron McKenzie
 
wang jiajian
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you must understand java classpath means.

classpath is the key of your question.if you understand it,you can get answer by yourself.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the late reply and thanks for all your responses.I could'nt log in this week as I got busy.I solved the classpath issue and everything is working fine.Thanks again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic