Solved

Global Connection Pooling

Posted on 2004-04-14
4
830 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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