1、tomcat安装目录\conf\ server.xml
<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"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource
name="jdbc/VoteDB"
type="javax.sql.DataSource"
password="test"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxIdle="3"
maxWait="5000"
username="test"
url="jdbc:oracle:thin:@10.10.0.1:1901:hccdb"
maxActive="10"/>
</GlobalNamingResources>
2、tomcat安装目录\conf\context.xml
<Resource
name="jdbc/VoteDB"
type="javax.sql.DataSource"
password="test"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxIdle="3"
maxWait="5000"
username="test"
url="jdbc:oracle:thin:@10.10.0.1:1901:hccdb"
maxActive="10"/>
3、spring 的applicationContext.xml
<bean id="myDateSourece" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/VoteDB</value>
</property>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true"/>
<property name="proxyInterface" value="javax.sql.DataSource"/>
</bean>