我喜欢在${TOMCAT_HOME}\conf\Catalina\localhost中添加一个xml文件来配置。
<context><resource><context> </context></resource></context>
xml 代码
- xml version="1.0" encoding="UTF-8"?>
- <Context
- path="/corpcs"
- docBase="D:\eclipse-workspace\corpcs\WebContent"
- reloadable="true"
- workDir="D:\eclipse-workspace\corpcs\WebContent\work">
- <Resource
- auth="Container"
- name="jdbc/corpcs"
- description="DB Connection"
- factory="org.apache.naming.factory.BeanFactory"
- type="com.mchange.v2.c3p0.ComboPooledDataSource"
- driverClass="oracle.jdbc.driver.OracleDriver"
- user="portal"
- password="portal"
- jdbcUrl="jdbc:oracle:thin:@192.168.91.41:1521:dev2sz"
- maxPoolSize="10000"
- minPoolSize="100"
- acquireIncrement="1" />
- Context>
修改WEB-INF\web.xml文件,在 <o:p></o:p> 其中添加JNDI引用
xml 代码
- <resource-ref>
- <res-ref-name>jdbc/OracleDBres-ref-name>
- <res-type>javax.sql.DataSourceres-type>
- <res-auth>Containerres-auth>
- <res-sharing-scope>Shareableres-sharing-scope>
- resource-ref>
测试 jndi_oracle.jsp