tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allen <allentheengin...@earthlink.net>
Subject RE: How to configure Mysql with Tomcat.
Date Thu, 16 Nov 2000 22:26:29 GMT
Hi,

I place the MySQL drivers in my WEB-INF/lib directory (in their JAR
file) and I make sure that it is in my classpath. You can check your
class path if you place this code into a servlet (it is writing to the
response's writer):
  Properties sysProp = System.getProperties();
  Enumeration propNames = sysProp.propertyNames();
  while (propNames.hasMoreElements())
  {
    String name = (String)propNames.nextElement();
   out.print(name);
   out.print("=");
   out.println(sysProp.getProperty(name));
  }

I use the driver this way:

    Class.forName("org.gjt.mm.mysql.Driver");
    Connection dbConn =
DriverManager.getConnection("jdbc:mysql://localhost/mydb", "username",
"password");

So, the problem might be the name of the driver that you are using (I
noticed that you do not have a gjt in your driver name).

I got my drivers from the MySQL website: http://www.mysql.com/

Allen

You wrote:
-----------------------------------------------------------------
Hello,

I wrote a simple servlet to insert a row into a mysql database table.
I'm running Tomcat 3.2b7.

What are the steps to configure Tomcat to work with this servlet?
The problem I'm having now is the driver isn't found.

Where do I place the driver? In the lib directory?

How do I reference a new instance of the driver?
This is how I reference it now:
Class.forName("org.mm.mysql.Driver").newInstance();

Will the connection information remain the same?
Here is the connection information I currently use:
con = DriverManager.getConnection("jdbc:mysql://localhost/webdata",
"user", "password");

TIA
--
Tony Keith


Mime
View raw message