Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to MySQL

 
Tahir Abbas
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Tahir Abbas
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic