Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

 
Bill Riedl
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using NetBeans 6.7.1 and am trying to connect to a MySQL DB. Below is a snippet from my code(I cut out the actual connection parameters and placed their names in italics). I'm new to this and this is just a scratch method for me to play around. When I compile I receive an error stating that class "com.mysql.jdbc.Driver" cannot be found. a MySQL driver is packaged with NetBeans and this is the URL according to the documentation. Am I missing something?

Thanks for your help!

private void scratch() throws SQLException, ClassNotFoundException
{

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://address:port/database","username","password");

}
 
satishbsk kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
place mysql-connector-java-*.bin.jar file in your class path
 
Bill Riedl
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satishbsk ...works now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic