title: Using c3p0 connection Pooling in a tomcat Spring based App
body: <p>I have a Spring Based Web App running under tomcat 6. Now, I want to use c3p0 connection pooling instead of tomcat's default DBCP. So, from the <a href="http://www.mchange.com/projects/c3p0/index.html#tomcat-specific" rel="nofollow">c3p0 help</a> doc, I have defined the data source in <code>context.xml</code> something like:</p>
  
  <pre><code>&lt;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" 
     /&gt;
  </code></pre>
  
  <p>Now, the documentation says, I should Include the following in <code>web.xml</code>:</p>
  
  <pre><code>&lt;resource-ref&gt;
    &lt;res-ref-name&gt;jdbc/sample&lt;/res-ref-name&gt;
    &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
    &lt;res-auth&gt;Container&lt;/res-auth&gt;
  &lt;/resource-ref&gt; 
  </code></pre>
  
  <p>I also have the following in <code>applicationContext.xml</code>:</p>
  
  <pre><code>&lt;jee:jndi-lookup id="sampleDataSource" resource-ref="true"
      jndi-name="jdbc/sample" /&gt;
  </code></pre>
  
  <p>When I start the tomcat, I get </p>
  
  <blockquote>
    <p>javax.naming.NameNotFoundException: Name jdbc is not bound in this Context</p>
  </blockquote>
  
  <p>Without c3p0 and using default connection pooling in tomcat6 works fine.</p>
  
  <p>Any help would be appreciated.</p>