Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC - MySQL - Help

Status
Not open for further replies.

jeanpierre

Technical User
Jun 14, 2001
137
CA
I have a problem loading the database driver for MySQL.

OS : Win XP (Home)
Database : MySQL
JDBC Driver : MM.MySQL

What I did to install the driver : I un-archived the distribution .jar archive,
you can install the driver in two ways-

1) When to Control Panel|Systems|Advance|Environment Variables and entered the path to the org subdirectory of the downloaded folder - C:\mm.mysql-2.0.11\org

2) To be doubly safe, I added mm.mysql-2.0.11-bin.jar folder to C:\j2SDK1.4.0\jre\lib\ext

Here is the code I used to establish a connection. The database is called "test":

import java.sql.*;

public class ConnecTion{

public static void main(String args[])
{

Connection connection;
try {
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost/test";
String username = "dillinger";
String password = "master";
connection = DriverManager.getConnection(url, username, password);
}
catch (ClassNotFoundException e) {
System.err.println("Could not load database driver!");
}
catch (SQLException e) {
System.err.println("Could not connect to the database!");
}
}
}


The errors message I receive is "Cannot load database driver!"


Are there any suggestions?

Thanks.
 
remember the java package directory structure...

from what i understand you unarg'ed the jar.

make sure the class files are in

/org/gjt/mm/mysql directory

and not

mm.mysql-2.0.11\org

as for ext... i am not sure by default ext is in the classpath
be safe and put the jar somewhere else and just add the path in compile classpath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top