Skip navigation links

MySQL Forums


Advanced Search

Can't load JDBC driver
Posted by: Marc Chanliau ()
Date: October 10, 2009 02:37PM

I wrote a very simple Java app to access a MySQL database (the "menagerie" example in the MySQL Tutorial).

My database connection works fine, but I get an exception from my program (Can't find the JDBC driver). The problem is with the line including "com.mysql.jdbc.Driver". I still get the error is I replace "com.mysql.jdbc.Driver" with the actual path of the MySQL JDBC driver.

Any suggestions?

For information, my program goes as follows (can't be simpler than that!):

import java.sql.*;

public class FirstJDBC {
public static void main(String args[]) {

try {
//Load JDBC driver
Class.forName ("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception e) {
System.out.println("Can't find the MySQL JDBC driver");
return;
}

String url = "jdbc:mysql://localhost:3306/menagerie";
String userName = "marcc";
String password = "xxxx";
Connection conn;

try {
//Connect to database
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (SQLException e) {
System.out.println("Connection problem: " + e.getMessage());
return;
}
}
}

Options: ReplyQuote


Subject Written By Posted
Can't load JDBC driver Marc Chanliau 10/10/2009 02:37PM
Re: Can't load JDBC driver Chad Bourque 10/10/2009 03:33PM
Re: Can't load JDBC driver Marc Chanliau 10/10/2009 03:33PM
Re: Can't load JDBC driver Chad Bourque 10/10/2009 03:44PM
Re: Can't load JDBC driver Marc Chanliau 10/11/2009 12:09PM


Sorry, only registered users may post in this forum.