Techie:Techie Main/Java/Tomcat/Connection Pool: Difference between revisions

From FFL Wiki
Jump to navigation Jump to search
Created page with '== Define pool in conf/context.xml == <Resource name="jdbc/FantacyDS" auth="Container" type="javax.sql.DataSource" maxActive="10" maxIdle="3" …'
 
Line 1: Line 1:
== Define pool in conf/context.xml ==
== Define pool in <tomcat_install>/conf/context.xml ==


  <Resource name="jdbc/FantacyDS"
  <Resource name="jdbc/FantacyDS"
Line 12: Line 12:
         validationQuery="SELECT 1"
         validationQuery="SELECT 1"
         url="jdbc:mysql://localhost/fantacy?autoReconnect=true"/>
         url="jdbc:mysql://localhost/fantacy?autoReconnect=true"/>
== Create a datasource in the application's web.xml ==
        <!-- DataSource resource -->
        <resource-ref>
                <description>FFL DataSource</description>
                <res-ref-name>jdbc/FantacyDS</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
        </resource-ref>
* Resouce name and res-ref-name must match
* Connection pool datasource now available using JNDI at 'java:comp/env/jdbc/FantacyDS'

Revision as of 16:37, 26 May 2010

Define pool in <tomcat_install>/conf/context.xml

<Resource name="jdbc/FantacyDS"
       auth="Container"
       type="javax.sql.DataSource"
       maxActive="10"
       maxIdle="3"
       maxWait="10000"
       username="xxxx"
       password="yyyy"
       driverClassName="com.mysql.jdbc.Driver"
       validationQuery="SELECT 1"
       url="jdbc:mysql://localhost/fantacy?autoReconnect=true"/>


Create a datasource in the application's web.xml

       <resource-ref>
               <description>FFL DataSource</description>
               <res-ref-name>jdbc/FantacyDS</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
       </resource-ref>
  • Resouce name and res-ref-name must match
  • Connection pool datasource now available using JNDI at 'java:comp/env/jdbc/FantacyDS'