MySQL Forums
Forum List  »  Connector/JDBC and Java

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");

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());

Options: ReplyQuote

Written By
Can't load JDBC driver
October 10, 2009 02:37PM
October 10, 2009 03:33PM
October 10, 2009 03:33PM
October 10, 2009 03:44PM
October 11, 2009 12:09PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.