From tomcat-user-return-46434-apmail-jakarta-tomcat-user-archive=jakarta.apache.org@jakarta.apache.org Tue Sep 04 03:47:05 2001 Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 62927 invoked by uid 500); 4 Sep 2001 03:47:05 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 62918 invoked from network); 4 Sep 2001 03:47:04 -0000 Received: from sonata.ihpc.nus.edu.sg (137.132.15.21) by daedalus.apache.org with SMTP; 4 Sep 2001 03:47:04 -0000 Received: from ihpc.nus.edu.sg (liyl.ihpc.nus.edu.sg [137.132.25.36]) by sonata.ihpc.nus.edu.sg (Netscape Messaging Server 4.15) with ESMTP id GJ4D7203.H1D for ; Tue, 4 Sep 2001 11:47:26 +0800 Message-ID: <3B944E68.555AA8C7@ihpc.nus.edu.sg> Date: Tue, 04 Sep 2001 11:45:44 +0800 From: liyl@ihpc.nus.edu.sg (Yonglin Li) X-Mailer: Mozilla 4.78 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-user@jakarta.apache.org Subject: JDBC Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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) {} } }