我有一个在 tomcat 6 下运行的基于 Spring 的 Web 应用程序。现在,我想使用 c3p0 连接池而不是 tomcat 的默认 DBCP。因此,从c3p0 帮助文档中,我将数据源定义为context.xml
:
<Resource name="jdbc/sample" auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@someServer:1551:xyz"
username="userName"
password="pwd"
validationQuery="SELECT 1 FROM dual"
testOnBorrow="true"
testWhileIdle="true"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
maxPoolSize="20"
minPoolSize="5"
acquireIncrement="1"
/>
现在,文档说,我应该在以下内容中包含以下内容web.xml
:
<resource-ref>
<res-ref-name>jdbc/sample</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
我还有以下内容applicationContext.xml
:
<jee:jndi-lookup id="sampleDataSource" resource-ref="true"
jndi-name="jdbc/sample" />
当我启动tomcat时,我得到
javax.naming.NameNotFoundException:名称 jdbc 未绑定在此上下文中
没有 c3p0 并在 tomcat6 中使用默认连接池可以正常工作。
任何帮助,将不胜感激。