Exception with com.mysql.jdbc.Driver
Posted by: gauri18
Date: February 01, 2005 01:51AM

Hi ,

I am a newbie to JAVA and Connector/J on LINUX. I am having following problem when I try to test the installation. Here is program with which I am testing:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcExample2 {

public static void main(String args[]) {
Connection con = null;

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test",
"", "");

if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");

} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}

This program compiles fine but when I try to run it ..I get the followig error:
java.lang.ClassNotFoundException:com.mysql.jdbc.Driver.

I have copied my mysql-connector-java-3.0.16-ga-bin.jar file to j2sdk1.4.2_07/jre/lib/ext dir and also put both the directories in the classpath. but the error persists. Is my classpath not setting correctly? Or could it be a problem with my j2sdk installation?
this is urgent pls help me............
thanks.

Options: ReplyQuote


Subject
Written By
Posted
Exception with com.mysql.jdbc.Driver
February 01, 2005 01:51AM


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.