This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing MySQL from NetBeans

 
Mahi Rahman
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I am trying to get conncetion to MySQL database using this simple java class.



I have added the mysql driver to NetBeans IDE, but when I try to compile the file I get a ClassNotFound error (the file can't locate the mysqljdbc.jar). Can anybody please suggest me how to fix this? If I need to register the database specificaly for this program how to do it then?

Thanks in advace!
 
Vyas
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try importing it as a library or put it in the Netbeans tomcat/lib
 
Jan Cumps
Bartender
Posts: 2618
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did not mention your Netbeans Version, but here is how it works in NetBeans 6:

Right click on your project -> Properties
Category Libraries
Compile tab
Add JAR / Folder.

Locate the driver jar and confirm.

Regards, Jan
 
Mahi Rahman
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hei Jan!

Great! I use NetBeans 5.5 and I found the steps you suggested is also applicable to this version. And, it's now working! Thanks a lot for your tips!

Mahi.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!