I know there is a way to read in the name but am unsure how to do it at this point. But there is a logistic issue with it. What if there is more than one?

You could do one of three things.

Either:
On startup read in the ds and store it. Then have each class simple grab the ds each time.


Or:
Use a properties file to store the name. It is read in during startup and stored. Each envCtx.lookup will then use the static variable in place of the name.


Or:
On startup create a static class to hold data. Have the variable initialized to the name. Then all classes ref this variable.


It depends on if you want to change it without editing the war.

Doug

----- Original Message ----- From: "Philippe Mathieu" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, January 26, 2005 2:36 AM
Subject: the default name of the local data source



I am using Tomcat 5.0.28 and my WAR uses a ConnectionPool defined in the application context (localDataSource).

To access it, the doc says that we must use these 3 lines in JSP's.
     Context initCtx = new InitialContext();
     Context envCtx = (Context) initCtx.lookup("java:comp/env");
     DataSource ds = (DataSource) envCtx.lookup("mypool");
     Connection con = ds.getConnection();

The disaventage is that if there are many WAR with the same localDataSource name, i will have to edit all the JSP/Beans to change the localDataSourceNames.

Is there any way to avoid saying the ressource name and for example telling that i want to use the localDataSource (without its name) ?

--
Phil


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to