Tomcat 6.0 connection pool configuration
1. Configure the files under conf under tomcat and add the connection pool configuration between them:
<Resource name="jdbc/oracle"
auth="Container"
type=""
driverClassName=""
url=" jdbc:oracle:thin:@host:port:databse"
username=" user "
password="password"
maxActive="100"
maxIdle="30"
maxWait="10000" />
2. Configure the addition between the middle and middle under your application:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/oracle</res-ref-name>
<res-type></res-type>
<res-auth>Container</res-auth>
</resource-ref>
3. Put the third-party driver connecting to the database into common/lib and it will be OK
4. I won't write the test program
Tomcat5.5x connection pool configuration
Method 1: Global database connection pool
1. Configure the connection pool through the management interface, or directly add it in the GlobalNamingResources of tomcat\conf\
<Resource name="jdbc/mydb"
type=""
password="mypwd"
driverClassName=""
maxIdle="2"
maxWait="5000"
validationQuery="select 1"
username="sa"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb"
maxActive="4"/>
2. Add to the Context of tomcat\webapps\myapp\META-INF\:
<ResourceLink global="jdbc/mydb" name="jdbc/mydb" type=""/>
That's all.
Method 2: Global database connection pool
1. Same as above
2. Add to the Context of tomcat\conf\:
<ResourceLink global="jdbc/mydb" name="jdbc/mydb" type=""/>
Method 3: Local database connection pool
Just add in the Context of tomcat\webapps\myapps\META-INF\:
<Resource name="jdbc/mydb" type="" password="mypwd" driverClassName="" maxIdle="2" maxWait="5000" validationQuery="select 1" username="sa" url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb" maxActive="4"/>
Parameter description:
driveClassName: the complete name of the JDBC driver class;
maxActive: The maximum number of available instances that can be allocated from the connection pool at the same time;
maxIdle: the maximum number of connections that can be idle in the connection pool at the same time;
maxWait: Maximum timeout, measured in milliseconds;
password: user password;
url: URL connection to JDBC;
user: user name;
validationQuery: used to query the idle connections in the pool.
The above three methods are OK under tomcat 5.5.4. In addition, the jdbc driver of SQL Server is a sql server jdbc (sp3) downloaded from the Microsoft website.
Tomcat5.0 connection pool configuration
Create an xml file under the path below tomcat (Tomcat \conf\Catalina\localhost), the content is as follows
<Resource name="jdbc/test" auth="Container" type=""/>
<ResourceParams name="jdbc/test">
<parameter>
<name>factory</name>
<value></value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value>test</value>
</parameter>
<!-- Class name for JDBC driver -->
<parameter>
<name>driverClassName</name>
<value></value>
</parameter>
<!-- Autocommit setting. This setting is required to make
Hibernate work. Or you can remove calls to commit(). -->
<parameter>
<name>defaultAutoCommit</name>
<value>true</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:jtds:sqlserver://url/filedb;charset=gb2312;autoReconnect=true</value>
</parameter>
<!-- Recover abandoned connections -->
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<!-- Set the number of seconds a dB connection has been idle
before it is considered abandoned.
-->
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<!-- Log a stack trace of the code which abandoned the dB
connection resources.
-->
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
</ResourceParams>
1. Configure the files under conf under tomcat and add the connection pool configuration between them:
Copy the codeThe code is as follows:
<Resource name="jdbc/oracle"
auth="Container"
type=""
driverClassName=""
url=" jdbc:oracle:thin:@host:port:databse"
username=" user "
password="password"
maxActive="100"
maxIdle="30"
maxWait="10000" />
2. Configure the addition between the middle and middle under your application:
Copy the codeThe code is as follows:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/oracle</res-ref-name>
<res-type></res-type>
<res-auth>Container</res-auth>
</resource-ref>
3. Put the third-party driver connecting to the database into common/lib and it will be OK
4. I won't write the test program
Tomcat5.5x connection pool configuration
Method 1: Global database connection pool
1. Configure the connection pool through the management interface, or directly add it in the GlobalNamingResources of tomcat\conf\
Copy the codeThe code is as follows:
<Resource name="jdbc/mydb"
type=""
password="mypwd"
driverClassName=""
maxIdle="2"
maxWait="5000"
validationQuery="select 1"
username="sa"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb"
maxActive="4"/>
2. Add to the Context of tomcat\webapps\myapp\META-INF\:
<ResourceLink global="jdbc/mydb" name="jdbc/mydb" type=""/>
That's all.
Method 2: Global database connection pool
1. Same as above
2. Add to the Context of tomcat\conf\:
Copy the codeThe code is as follows:
<ResourceLink global="jdbc/mydb" name="jdbc/mydb" type=""/>
Method 3: Local database connection pool
Just add in the Context of tomcat\webapps\myapps\META-INF\:
Copy the codeThe code is as follows:
<Resource name="jdbc/mydb" type="" password="mypwd" driverClassName="" maxIdle="2" maxWait="5000" validationQuery="select 1" username="sa" url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb" maxActive="4"/>
Parameter description:
driveClassName: the complete name of the JDBC driver class;
maxActive: The maximum number of available instances that can be allocated from the connection pool at the same time;
maxIdle: the maximum number of connections that can be idle in the connection pool at the same time;
maxWait: Maximum timeout, measured in milliseconds;
password: user password;
url: URL connection to JDBC;
user: user name;
validationQuery: used to query the idle connections in the pool.
The above three methods are OK under tomcat 5.5.4. In addition, the jdbc driver of SQL Server is a sql server jdbc (sp3) downloaded from the Microsoft website.
Tomcat5.0 connection pool configuration
Create an xml file under the path below tomcat (Tomcat \conf\Catalina\localhost), the content is as follows
Copy the codeThe code is as follows:
<Resource name="jdbc/test" auth="Container" type=""/>
<ResourceParams name="jdbc/test">
<parameter>
<name>factory</name>
<value></value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value>test</value>
</parameter>
<!-- Class name for JDBC driver -->
<parameter>
<name>driverClassName</name>
<value></value>
</parameter>
<!-- Autocommit setting. This setting is required to make
Hibernate work. Or you can remove calls to commit(). -->
<parameter>
<name>defaultAutoCommit</name>
<value>true</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:jtds:sqlserver://url/filedb;charset=gb2312;autoReconnect=true</value>
</parameter>
<!-- Recover abandoned connections -->
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<!-- Set the number of seconds a dB connection has been idle
before it is considered abandoned.
-->
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<!-- Log a stack trace of the code which abandoned the dB
connection resources.
-->
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
</ResourceParams>