[b]1.设置数据源[/b]
apache-tomcat-6.0.29\conf\context.xml
[b]2.修改war包中的web.xml[/b]
myApp\WEB-INF\web.xml
[b]3.修改war包中引用数据源的方式[/b]
在WAS中使用,配置成jdbc/test即可,在tomcat中需要修改为java:comp/env/jdbc/test
[b]4.添加驱动[/b]
apache-tomcat-6.0.29\lib\ojdbc14-10.2.0.3.0.jar
apache-tomcat-6.0.29\conf\context.xml
<?xml version='1.0' encoding='utf-8'?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource url="jdbc:oracle:thin:@192.168.0.5:1521:test" driverClassName="oracle.jdbc.OracleDriver" password="username" username="password" logAbandoned="true" maxWait="10000" maxIdle="30" maxActive="50" type="javax.sql.DataSource" auth="Container" name="jdbc/test" testOnBorrow="true" validationQuery="select 1 from dual" />
</Context>
[b]2.修改war包中的web.xml[/b]
myApp\WEB-INF\web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
... ...
<resource-ref>
<description>test</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
[b]3.修改war包中引用数据源的方式[/b]
在WAS中使用,配置成jdbc/test即可,在tomcat中需要修改为java:comp/env/jdbc/test
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/test"></property>
</bean>
... ...
<beans>
[b]4.添加驱动[/b]
apache-tomcat-6.0.29\lib\ojdbc14-10.2.0.3.0.jar