Please help

Hi all,Can anyone please tell me how to use jdbc with mysql.I have downloaded mysql_jdbc driver but ones I tried to connect my database it find the driver.Any help?JamesL
[212 byte] By [jamesliJ] at [2007-9-26 5:39:59]
# 1

Hi,

This is how we can connect JDBC to mysql

// loads the JDBC driver

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

// get a database connection

Connection conn = DriverManager.getConnection(

"jdbc:mysql://hostname/databaseName",

"user",

"password");

obviously the JDBC driver "org.gjt.mm.mysql.Driver" must be in classpath. You can download it from

http://www.mysql.com/downloads/api-jdbc.html

Hope this wil help you.

Anil.

Developer Technical Support.

Sun Microsystems

http://www.sun.com/developers/support

ramanil_indts at 2007-7-1 13:54:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Thanks ramanil_indts,Although I still have same problems but thanks for your contribution JamesL
jamesliJ at 2007-7-1 13:54:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Hi,Can someone please say what causes this:java.lang.ClassNotFoundException: org.gjt.mm.mysql.DriverThanks
jamesliJ at 2007-7-1 13:54:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Java can't find the driver in your classpath. You should have a file named "mysql.jar" or something similar. This needs to be put in the CLASSPATH environment variable. Note that regular class files can be found using only a directory path, but jar files must be explicitly named. In other words,if the jar file is in /usr/local/java/lib, then you must put

"/usr/local/java/lib/mysql.jar"

in your classpath, not just

"/usr/local/java/lib"

preaney at 2007-7-1 13:54:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...