Tomcat+oracle Connection Pool

Source: Internet
Author: User

Tomcat 5.5.23
Oracle 10g

Global configuration
A. Tomcat directory \common\lib add package Ojdbc14.jar.

Two. The Tomcat directory \conf\server.xml <GlobalNamingResources> tags are inserted
Connection parameters for Oracle:
<resource name= "Jdbc/oracle"
Type= "Javax.sql.DataSource"
Driverclassname= "Oracle.jdbc.driver.OracleDriver"
Maxidle= "10"
maxwait= "5000"
Maxactive= "20"
Username= "OnePiece"
Password= "12345"
Url= "Jdbc:oracle:thin: @localhost: 1521:orcl"
/>
(the name is also used after jdbc/oracle)

Three. The Web configuration file for the Tomcat directory \catalina\localhost, such as Hello.xml,
The original is:
<context path= "Hello" docbase= "D:\workspace\HelloOracle\web" reloadable= "true"
Privileged= "true" antiresourcelocking= "false" antijarlocking= "false" >
</Context>
Switch
<context path= "Hello" docbase= "D:\workspace\HelloOracle\web" reloadable= "true"
Privileged= "true" antiresourcelocking= "false" antijarlocking= "false" >
<resourcelink global= "jdbc/oracle" name= "jdbc/oracle" type= "Javax.sql.DataSource"/>
</Context>
That is, join:
<resourcelink global= "jdbc/oracle" name= "jdbc/oracle" type= "Javax.sql.DataSource"/>

Four. Application (note name jdbc/oracle):
InitialContext Icont = new InitialContext ();
DataSource DataSource = (DataSource) icont.lookup ("java:comp/env/jdbc/oracle");
conn = Datasource.getconnection ();
You can get the connection

Local configuration (only hello application can be applied)
I. First step above
Two. See the third step, but not the same
The original is:
<context path= "Hello" docbase= "D:\workspace\HelloOracle\web" reloadable= "true"
Privileged= "true" antiresourcelocking= "false" antijarlocking= "false"/>
Switch
<context path= "Hello" docbase= "D:\workspace\HelloOracle\web" reloadable= "true"
Privileged= "true" antiresourcelocking= "false" antijarlocking= "false" >

<resource name= "Jdbc/oracle"
Type= "Javax.sql.DataSource"
Driverclassname= "Oracle.jdbc.driver.OracleDriver"
Maxidle= "10"
maxwait= "5000"
Maxactive= "20"
Username= "OnePiece"
Password= "12345"
Url= "Jdbc:oracle:thin: @localhost: 1521:orcl"
/>
</Context>

Tomcat+oracle Connection Pool

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.