470,631 Members | 1,737 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

mysql jdbc driver problem

hello

I am trying to connect to mysql database using connector/J jdbc driver
this is my code

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

class JdbcTest1 {

public static void main(String[] args) {
// Connection conn = null;
// Statement st = null;
//ResultSet rs = null;
//ResultSetMetaData rmd = null;
String query = null;

try{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
System.out.println("Driver Registration Successful.");
} catch (InstantiationException ie){
System.out.println("Class Instantiation Exception: " + ie);
} catch (ClassNotFoundException cnf){
System.out.println("Class Not Found Exception: " + cnf);
} catch (IllegalAccessException iae){
System.out.println("Illegal Access Exception: " + iae);
}

try {
// conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?user=root&pas
sword=root");
java.sql.Connection conn =
DriverManager.getConnection("jdbc:mysql:///mysql","root", "root");
System.out.println("Connection to MySQL Database Successful");
} catch (SQLException sqe1){
System.out.println("Caught SQL Exception: " + sqe1);
}

}

}

The output is

Driver registeration successful

java.lang.NoClassDefFound error
com/mysql/jdbc/Connection
at com.mysql.jdbc.NonRegisteringDriver.connect()

I am not able to figure out whether it is the URL problem to getConnection
or something else

please help

Jul 19 '05 #1
0 1621

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mdh | last post: by
reply views Thread by sridhar nagabhurshana | last post: by
reply views Thread by Peter Höltschi | last post: by
39 posts views Thread by Mairhtin O'Feannag | last post: by
oll3i
5 posts views Thread by oll3i | last post: by
1 post views Thread by paulq182 | last post: by
1 post views Thread by manjava | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.