?
Solved

Global Connection Pooling

Posted on 2004-04-14
4
Medium Priority
?
835 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

801 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