aspose file tools*
The moose likes JDBC and the fly likes Connecting to MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connecting to MySQL" Watch "Connecting to MySQL" New topic
Author

Connecting to MySQL

Tahir Abbas
Ranch Hand

Joined: May 05, 2007
Posts: 44
Hello Everyone,

I am quite new in using JDBC, I know this question is repeated but as i couldn't solve problem so writing you for help.

I am running this program in eclipse with Windows vista and MySQL and receiving this error "Cannot connect to database serverjava.lang.ClassNotFoundException: com.mysql.jdbc.Driver"

I copied all extracted file of "mysql-connector-java-5.1.6" in MySQLDB package and also tried by setting the classpath but always get error.

I'll be very thankful to you for help in this regard.
[ August 14, 2008: Message edited by: Tahir Abbas ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30352
    
150

Tahir,
Is this a standalone Java program in Eclipse? If so, can you confirm the mysql jar is in your project's build path. If not, what server are you using?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tahir Abbas
Ranch Hand

Joined: May 05, 2007
Posts: 44
Thanks! for help, yea problem was in build path i am writing steps may be helpful for someone else.

1- After opening project window(menu) > Preference then select Java>build Path > classpath variable and click on new button and give variable name and path of unzipped mysql connector folder in the appeared dialogue box, click ok again ok.

2- Right click on Project Properties select Java Build Path then click on Libraries tab then click on classpath variable. Select the newly formed variable from the list then click on Extend button ___.jar file will appear click on jar file then click ok, ok.

This way i got right output.

Thanks! for help and Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting to MySQL