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:


Class.forName("com.mysql.jdbc.Driver");			                    con=DriverManager.getConnection(url,"root","<pwd>");     
    	    Statement stmt = con.createStatement();
    	    ResultSet rs = stmt.executeQuery("select * from login");
    				DbPassword = rs.getString("Password");
    		catch(Exception d)
    				System.out.println("" + d);

I get the following output:

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...

Recommended Answers

All 7 Replies

You'll need to add the jdbc driver jar to your project properties under Libraries. You can access those under the File menu or by right-clicking the project in the Projects window.

Hi Ezzaral...Thanks for your reply...Yes I got to the project properties page.By "jdbc driver" you mean the mysql-jdbc connector jar I believe...Am I right?


Hello Ezzaral..I tried it but it gives the same error message.I extracted the tar.gz file that I downloaded and added the folder to the list of source packages in the project properties..please help...Thanks.

You need to add the jar file to the Libraries for the project.

I did it and it worked like magic.Thank you very much.Will this be enough also for web apps...because I noticed the jar files in the classes tab of tomcat6.0 and the connector jar is missing... as opposed to the list displayed in the below url

Should I add the connector jar to that list too?...To get a web app working...Thanks...

If your Tomcat installation doesn't have that jar then yes you'll probably have to add it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.