tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@ihpc.nus.edu.sg (Yonglin Li)
Subject JDBC
Date Tue, 04 Sep 2001 03:45:44 GMT
Hi, experts!
    I met a problem when I tried to make JDBC connection by using the
code as follows.

    The program work well when I use startup.bat to start tomcat.

    But I cannot use it when I start Tomcat as a service. Yet I can
still use all the other JSP sameples, it tells me the URL is not valid
or does not exist. I promise the ODBC data source is there and I can use
it when I start tomcat using Startup.bat
So can some body tell me the reason.

--------------------------------------------


public class PersistentConnection {

    private static Connection theConnection;
    public static Connection getConnection() {return theConnection;}

    public void setDbClass() {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

        } catch (Exception e) {
            System.err.println("Error loading class");
            e.printStackTrace(System.err);
        }
    }

    public void setConnection() {
        try {
            theConnection =
DriverManager.getConnection("jdbc:odbc:NorthWind","username","password");

        }catch (Exception e) {
            System.err.println("Error setting DBUrl");
            e.printStackTrace(System.err);
        }
    }

  public void shutDown() {
    try {
      theConnection.close();
    } catch (Exception e) {}
  }
}


Mime
View raw message