something likes this:
..
public static final String JDBC_DRIVER="org.gjt.mm.mysql.Driver";
public static final String DB="jdbc:mysql://localhost:3306/ems";
public static final String DB_USER="wwwuser";
public static final String DB_PW="";
...
Class.forName(JDBC_DRIVER).newInstance();
Connection conn=DriverManager.getConnection(DB,DB_USER,DB_PW);
.... ("ems" is my db name", 3306 is port#)
good luck!
alvin
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Kurtz
Todd-sc4536
Sent: Friday, January 21, 2000 6:49 AM
To: [EMAIL PROTECTED]
Subject: Unable to load JDBC Driver
Greetings,
I do appreciate any help that you might provide. Many Thanks.
The response I get from my servlet is:
"Couldn't load database driver: org.gjt.mm.mysql.Driver"
Basically, I am having problems getting my servlet to connect
to my database with a JDBC driver. Everything works on my pc,
but not on my server. Unfortunately, I don't have my own server
connected to the Internet. I have a virtual hosting account with
a web hosting company. I have a MySQL database set up there. They
have the JDBC driver mm.mysql.jdbc-1.2b (org.gjt.mm.mysql.Driver).
And, my class file is in my servlets directory. Other servlets
do work in this directory, but none require a database connection
except this one.
Note: I'm displaying a false domain, user, and password here.
As I mentioned, everything works on my pc via
http://localhost:8080/examples/servlet/DBTest
but not on the webhosting.com server at
http://www.falsedomain.com/servlets/DBTest .
THESE ARE QUESTIONS I ASKED MY WEB HOSTING COMPANY, BUT
HAVEN'T RECEIVED A REPLY ON:
CONCERNING LOADING THE JDBC DRIVER:
1. Is the JDBC driver named "org.gjt.mm.mysql.Driver"?
2. Is the JDBC driver already in our CLASSPATH?
3. Do I need to specify a path to the JDBC driver?
CONCERNING CONNECTING TO THE DATABASE:
4. What is the correct path to the database "TestDB"?
ex: "jdbc:mysql:WHAT GOES HERE?"
THIS IS THE SECTION OF PERTINENT CODE:
try {
// Load the mysql Driver
Class.forName("org.gjt.mm.mysql.Driver");
// Get a Connection to the database
con = DriverManager.getConnection(
"jdbc:mysql:TestDB?user=falseUser password=falsePassword");
// By the way, I don't think the line above works, but I'm not
// sure because the error message refers to loading the driver,
// not connecting to the database.
/* But, the line below works on my local pc */
// "jdbc:mysql://localhost/DBTest?user=root password=todd");
Thanks Again,
Todd Kurtz
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html