Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 10260 invoked by uid 500); 5 Jul 2001 11:35:07 -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 10161 invoked from network); 5 Jul 2001 11:35:06 -0000 Received: from unknown (HELO mailserver.erunway.com) (12.40.51.200) by h31.sny.collab.net with SMTP; 5 Jul 2001 11:35:06 -0000 Received: from eipmailsvr.erunway.atc.dns (eipmailsvr [10.4.8.9]) by mailserver.erunway.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 3HBTKQH3; Thu, 5 Jul 2001 07:34:38 -0400 Received: by eipmailsvr.erunway.atc.dns with Internet Mail Service (5.5.2650.21) id <32S2ABS3>; Thu, 5 Jul 2001 17:02:18 +0530 Message-ID: From: "Rajehswar V. Rao" To: "'tomcat-user@jakarta.apache.org'" Subject: RE: JDBC Realm Questions Tomcat 3.2.2 Date: Thu, 5 Jul 2001 17:02:18 +0530 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N I am looking for same.... -----Original Message----- From: Jonathan_Pierce@seagram.com [mailto:Jonathan_Pierce@seagram.com] Sent: Thursday, July 05, 2001 4:02 AM To: TOMCAT-USER@jakarta.apache.org Subject: Fwd:JDBC Realm Questions Tomcat 3.2.2 Someone please respond to these questions so I know whether JDBC Realms are a supported feature of Tomcat3.2.2. I posted the question a few days ago and have gotten no responses. Has anyone been successful in referencing a jdbc datasource configured in the server.xml of Tomcat 3.2.2? If so, how? Jonathan ____________________Forward Header_____________________ Subject: JDBC Realm Questions Tomcat 3.2.2 Author: tomcat-dev@jakarta.apache.org Date: 7/3/2001 8:21 PM This may be a stupid question but I've found hundreds of messages from confused users on the subject of JDBC Realms and Tomcat and no good explanation or example. There is a documentation file JDBCRealm.howto but it doesn't describe how to instantiate the datasource with a code example or what additional property files need to be included to configure jndi properties. Like lots of other people, I'm trying to use the release Tomcat 3.2.2, configure multiple jdbc datasources in the server.xml file, and reference it in my servlet. I am only interested in using a shared database ID to connect to the database for all users of my servlet. The database connect info needs to be in Tomcat conf files since the passwords need to be reconfigured at deployment time outside my war file. 1. Is this behavior supported by Tomcat 3.2.2? How do I configure multiple database datasources and instantiate them in my code? 2. Assuming I setup the datasources like below, what properties do I use to assign a name to the datasource so I can reference it? 3. What do I need to add to a config file in order to access the initial context so I can retrieve the datasource? import javax.servlet.*; import javax.servlet.http.*; import javax.naming.*; import javax.sql.*; String theDataSourceName = "???"; String theNamingProviderURL = "???"; String theInitialContextNamingFactory = "???"; Properties theProperties = new Properties (); theProperties.put("java.naming.provider.url", theNamingProviderURL); theProperties.put("java.naming.factory.initial",theInitialContextNamingFacto ry); Context theInitialContext = new InitialContext(theProperties); DataSource theDataSource = (DataSource) theInitialContext.lookup (theDatasourceName);