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