You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Catherine Shepherd <ca...@imperiumglobal.com> on 2002/06/15 19:35:50 UTC

RE: Urgent : Error connecting to mysql Database from JSP pagedeployed on tomcat server

Firstly perhaps this is a question for a Java forum.  However, it seems you
are not instantiating your driver properly.  This is a connection test class
that works fine connecting from a Tomcat instance on Win2K to a MySQL
instance on a remote Red Hat 7.2 box using the MM.MySQL driver
(http://mmmysql.sourceforge.net/).  Try it out on your system.  If you are
using a different driver you'll need to change the DBDRIVER String.

package com.imperiumglobal.tools.db;
import java.sql.*;
public class ConnectionTester {
  public static void main(String[] args) {
    String DBDRIVER = "org.gjt.mm.mysql.Driver";
    String DBURL = "jdbc:mysql://[hostname]/[dbname]";
    String DBUSER = "[username]";
    String DBPASSWORD = "[db password]";
    System.out.println("trying connection...");
    try {
      Class.forName(DBDRIVER).newInstance();
      Connection conn =
        DriverManager.getConnection(
          DBURL + "?user=" + DBUSER + "&password=" + DBPASSWORD);
      System.out.println("good connection");
    } catch (Exception e) {
      System.out.println("no connection: " + e);
    }
  }
}

James

-----Original Message-----
From: Jayanta Halder [mailto:JHALDER@dfg.ca.gov]
Sent: 14 June 2002 16:35
To: tomcat-user@jakarta.apache.org
Subject: Urgent : Error connecting to mysql Database from JSP
pagedeployed on tomcat server

While running the application i am getting following error ....

Cannot load JDBC driver class 'null'
java.lang.NullPointerException:



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>