tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Marshall" <dizzyj...@hotmail.com>
Subject Accessing the connection pool
Date Thu, 06 Sep 2007 16:37:36 GMT
Greetings

I have web applications running connection pools under the name 
jdbc/connectionPool, and these web applications can connect without any 
problems. Now Iím working on a security application, to be run as a client 
jar to the webapps. This jar does the lookup onto the multiple 
authentication data sources we have. Can the ConnectionFactory within the 
jar file access the Connection Pools set up by one of the  web applications 
?  If not, any ideas how I can get a Connection Pool on the server that the 
jar file can access ?

The jar file sits in the Tomcat 5.5\shared directory.

At the moment, when I try it I get a naming exception : 
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

Code in the connection factory :


try

            {

                Context ctx = new InitialContext();



                DataSource ds =

                        (DataSource)ctx.lookup(

                        "java:comp/env/jdbc/connectionPool");



                if (ds != null)

                {

                    conn = ds.getConnection();



                    if(conn != null)

                    {

                        LogManager.getInstance().logDebug(this.getClass(), 
"Connection retrieved from jdbc/connectionPool.");

                    }

                }

            }

            catch (SQLException ex)

            {

                throw new DAORuntimeException("DBConnectionFactory 
getConnection()", ex);

            }

            catch (NamingException ex)

            {

                throw new DAORuntimeException("DBConnectionFactory 
getConnection()", ex);

            }



Code in the Context file :



<Context crossContext="true" debug="5" path="/ipsl_app" 
docBase="C:\dev\ipsl_app\build\web" reloadable="true">

    <Resource

          name="jdbc/connectionPool"

                        auth="Container"

          type="javax.sql.DataSource"

          driverClassName="net.sourceforge.jtds.jdbc.Driver"

          factory="org.apache.commons.dbcp.BasicDataSourceFactory"

          user="<removed> "

          password="<removed> "

          maxIdle="2"

          maxWait="5000"

          url="<removed> "

          maxActive="4"

          removeAbandoned="true" removeAbandonedTimeout="60" 
logAbandoned="true"/>


   </Context>


Thanks very much


Scott

_________________________________________________________________
Can you see your house from the sky? Try Live Search Maps 
http://maps.live.com


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message