Solved

Global Connection Pooling

Posted on 2004-04-14
4
826 Views
Last Modified: 2011-10-03
I have Tomcat 5.0.19 running with more than 100 virtual hosts.  I want to create a single global JNDI JDBC pool (mysql) for all of these websites.  According to Tomcat Documentation, I have to put the following code between the <Context ...> </Context> tags.  This works fine for a single web application.  However, that's not what I want, because all of our 100 virtual hosts basically need the same DB connection.  I think I need to place this configuration in the <GlobalNamingResources> section.  However it doesn't work like that.  Here is configuration I'm referring to:

<Resource name="jdbc/myDB" auth="Container" type="javax.sql.DataSource" />
                  <ResourceParams name="jdbc/myDB">
                        <parameter>
                              <name>factory</name>
                              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                        </parameter>
                        <parameter>
                              <name>maxActive</name>
                              <value>100</value>
                        </parameter>
                        <parameter>
                              <name>maxIdle</name>
                              <value>30</value>
                        </parameter>
                        <parameter>
                              <name>maxWait</name>
                              <value>10000</value>
                        </parameter>
                        <parameter>
                              <name>removeAbandoned</name>
                              <value>true</value>
                        </parameter>                  
                        <parameter>
                              <name>removeAbandonedTimeout</name>
                              <value>60</value>
                        </parameter>
                        <parameter>
                              <name>logAbandoned</name>
                              <value>true</value>
                        </parameter>
                        <parameter>
                              <name>username</name>
                              <value>xxx</value>
                        </parameter>
                        <parameter>
                              <name>password</name>
                              <value>xxx</value>
                        </parameter>
                        <parameter>
                              <name>driverClassName</name>
                              <value>com.mysql.jdbc.Driver</value>
                        </parameter>
                        <parameter>
                              <name>url</name>
                              <value>jdbc:mysql://localhost:3306/mydb?autoReconnect=true</value>
                        </parameter>
                  </ResourceParams>

Is there a way to accomplish this?

Thanks,

Asim
0
Comment
Question by:asimalp
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:vzilka
ID: 10846750
Define it in the GlobalNamingResource section, and add resourcelink tags in your host/app.
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/manager-howto.html
0
 

Author Comment

by:asimalp
ID: 10849301
Could you please give an example of adding resourcelink tags?
0
 
LVL 9

Accepted Solution

by:
vzilka earned 500 total points
ID: 10853892
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
<Resource name="jdbc/ItcDS" type="oracle.jdbc.pool.OracleConnectionPoolDataSource" auth="Container"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value> org.apache.catalina.users.MemoryUserDatabaseFactory
</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>

</ResourceParams>

<ResourceParams name="jdbc/ItcDS">

<parameter>
<name>factory</name>
<value> org.apache.commons.dbcp.BasicDataSourceFactory
</value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>*******</value>
</parameter>

<parameter>
<name>username</name>
<value>cape_admin</value>
</parameter>

<parameter>
<name>password</name>
< value>admin</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>

<parameter>
<name>maxActive</name>

<value>4</value>
</parameter>

<parameter>
<name> maxIdle </name>
<value>2</value>
</parameter>

</ResourceParams>

</GlobalNamingResources>

<Service name="Catalina">

<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443">
</Connector>

<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>

<Engine defaultHost="localhost" name="Catalina">

<Host appBase="webapps" name="localhost">

<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>

<Context path="/anketa_new" docBase="/anketa_new" debug="0" privileged="true" useNaming="true">

<ResourceLink global="jdbc\ItcDS" name="ItcDS"/>

</Context>
</Host>
<Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>

</Engine>
</Service>
</Server>
0
 

Author Comment

by:asimalp
ID: 10928869
Thank you very  much!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now