0

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:

code:

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

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

2
Contributors
7
Replies
10
Views
9 Years
Discussion Span
Last Post by Ezzaral
0

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.

0

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?

0

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.

0

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
http://blogs.sun.com/larry/entry/mysql_connector_j_jdbc_driver1

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.