【发布时间】:2013-12-24 05:21:10
【问题描述】:
我在 java 中创建了一个 mavenized web 应用程序。如果我使用 maven jetty 插件运行 Web 应用程序,我能够从连接池初始化数据源,也能够从数据源获取连接。但是当我在 tomcat 服务器上部署应用程序时,它能够初始化数据源,但在尝试连接时抛出异常:
java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
即使我在 server.xml 中对 web.xml 中的资源和资源引用进行了更改,但我仍然无法获得连接。
**Server.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>
尝试在 tomcat 服务器上运行应用程序时,我在这种情况下缺少什么?
【问题讨论】:
标签: java maven tomcat connection-pooling c3p0