Solved

Global Connection Pooling

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

16 Experts available now in Live!

Get 1:1 Help Now