注意:将ojdbc14.jar(与oracle版本对应,此处应该是oracle11g)和tomcat-jdbc-7.0.37.jar 拷贝到工程的WEB-INF\lib 下面
一、在Tomcat的配置文件Tomcat7.0\conf\context.xml中添加信息:
<Resource name="platformDataSource" auth="Container" type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
maxActive="20"
maxIdle="1"
maxWait="100"
username="anlianebusiness"
password="anlianebusiness"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.168.11.201:1521:orcl">
</Resource>
注意这里的driverClassName写的是oracle.jdbc.OracleDriver。oracle10之前的driverClassName写的oracle.jdbc.driver.OracleDriver
二、 在$CATALINA_HOME/webapps/应用名称/WEB-INF/web.xml的前添加如下信息:
<resource-ref >
<description >platformDataSource</description >
<res-ref-name >platformDataSource </res-ref-name >
<res-type >javax.sql.DataSource</res-type >
<res-auth >Container</res-auth >
</resource-ref >
其中中的参数名必须和context.xml中声明的连接名一样。