[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Global Connection Pooling

Posted on 2004-04-14
4
Medium Priority
?
836 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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 …
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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