tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Parsons Technical Services" <>
Subject Re: the default name of the local data source
Date Wed, 26 Jan 2005 13:04:59 GMT
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 

You could do one of three things.

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

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 

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.


----- Original Message ----- 
From: "Philippe Mathieu" <>
To: <>
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:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message