Using the c3p0 Connection Integrating into a tomcat Spring Application

I have a Spring based web application running under tomcat 6. Now I want to use the c3p0 connection pool instead of the default tomcat DBCP. So, from the c3p0 help doc, I defined the data source in context.xmlsomething like:

<Resource name="jdbc/sample" auth="Container"
     driverClassName="oracle.jdbc.driver.OracleDriver"
     url="jdbc:oracle:thin:@someServer:1551:xyz"
     username="userName"
     password="pwd"
     validationQuery="SELECT 1 FROM dual"
     testOnBorrow="true"
     testWhileIdle="true"
     factory="org.apache.naming.factory.BeanFactory" 
     type="com.mchange.v2.c3p0.ComboPooledDataSource" 
     maxPoolSize="20" 
     minPoolSize="5" 
     acquireIncrement="1" 
   />

Now the documentation says that I should include the following in web.xml:

<resource-ref>
  <res-ref-name>jdbc/sample</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref> 

I also have the following in applicationContext.xml:

<jee:jndi-lookup id="sampleDataSource" resource-ref="true"
    jndi-name="jdbc/sample" />

When I start tomcat, I get

javax.naming.NameNotFoundException: jdbc name is not related in this context

Without c3p0 and using the default connection pool in tomcat6 works fine.

Any help would be appreciated.

+5
2

context.xml, :

<Context antiJARLocking="true" swallowOutput="true">

    <ResourceLink
     global="jdbc/sample"
     name="jdbc/sample"
     type="javax.sql.DataSource" />
</Context>

, J2EE . , context.xml "conf" Tomcat, METAP-INF webapp ( , , - ). context.xml ref-ref web.xml.

0

All Articles