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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC MySQL - This is killing me !!!!!!!

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.
 
The file mm.mysql-2.0.11-bin.jar contains the file mysql.jar that is the JDBC-driver. That is the fil you should register and put in jre/lib/ext.
 
jeanpierre;

I have the *exact* same problem.
I have win2k professional intead and have created classpath system variable with the darn thing pointed to any concievable combination of using the .jar file to unarchiving and using the directory. I am using IBM's VA for Java to write and test programs.

I am, I confess, absolutely stuck.
 
OK, so what you have to do is to unzip the file mm.mysql-2.0.11-bin.jar, in it is the jdbc jar file mysql.jar you should point out.
 
I got this figured out. These forums had some good suggestions.
I found the classpath environment variable works in either autoexec.bat or the system Environment Variable screen just fine. I did also update Win2k professional to SP3. I got the java application to work after I exported from my IDE (IBM's VA for Java).

The real problem was I failed to get IBM VA for Java to see the resources I wanted to use. I solved this in VA for Java by going to the Resource tab, right click on the project, go to add tab and selected Resources. From there I could point VA to the correct classpath the system was using. It sure pays to RTFM and this was one of those times I fell off the bandwagon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top