为什么 Java JDBC 连接池会在部署时进行验证?
我在部署 Java EE 应用程序 (.ear) 时遇到问题。问题与我在我的应用程序中使用的 JDBC 连接池有关。我无法在服务器上部署应用程序。这是我在控制台上得到的:
WARNING: RAR5038:Unexpected exception while creating resource for pool oracle_PROD_Pool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: Wyjątek we-wy: The Network Adapter could not establish the connection
WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ oracle_PROD_Pool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: Wyjątek we-wy: The Network Adapter could not establish the connection
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: Wyjątek we-wy: The Network Adapter could not establish the connection]
SEVERE: Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Wyjątek we-wy: The Network Adapter could not establish the connection
Error Code: 0...
然后我得到 SQLException 堆栈跟踪并且部署失败。
我知道这是因为无法访问数据库服务器并且无法创建连接,但我还是想部署应用程序并在“应用程序使用时间”获取 SQLException。这是我的 jdbc 连接池定义:
<jdbc-connection-pool allow-non-component-callers="false"
associate-with-thread="false"
connection-creation-retry-attempts="0"
connection-creation-retry-interval-in-seconds="10"
connection-leak-reclaim="false"
connection-leak-timeout-in-seconds="0"
connection-validation-method="auto-commit"
datasource-classname="oracle.jdbc.pool.OracleConnectionPoolDataSource"
fail-all-connections="true"
idle-timeout-in-seconds="300"
is-connection-validation-required="true"
is-isolation-level-guaranteed="true"
lazy-connection-association="false"
lazy-connection-enlistment="false"
match-connections="false"
max-connection-usage-count="0"
max-pool-size="32"
max-wait-time-in-millis="60000"
name="oracle_PROD_Pool"
non-transactional-connections="false"
pool-resize-quantity="2"
res-type="javax.sql.ConnectionPoolDataSource"
statement-timeout-in-seconds="-1"
steady-pool-size="8"
validate-atmost-once-period-in-seconds="0"
wrap-jdbc-objects="true">
<property name="User" value="user"/>
<property name="DatabaseName" value="PROD"/>
<property name="Password" value="pass"/>
<property name="DataSourceName" value="OracleConnectionPoolDataSource"/>
<property name="ServerName" value="172.27.0.101"/>
<property name="DriverType" value="thin"/>
<property name="ExplicitCachingEnabled" value="false"/>
<property name="MaxStatements" value="0"/>
<property name="NetworkProtocol" value="tcp"/>
<property name="ImplicitCachingEnabled" value="false"/>
<property name="URL" value="jdbc:oracle:thin:@172.27.0.101:1521:PROD"/>
<property name="PortNumber" value="1521"/>
<property name="LoginTimeout" value="0"/>
</jdbc-connection-pool>
和相关的 jdbc 资源:
<jdbc-resource enabled="true" jndi-name="jdbc/oraclePROD" object-type="user" pool-name="oracle_PROD_Pool"/>
在我迁移到新版本的 GlassFish server 3.1.2.2 后出现此问题。早些时候我一直在使用 glassFish 3.1.1 (build 12) 并且部署没有问题,我的意思是在部署时没有检查和填充连接池,当我的应用程序尝试执行从数据库获取数据的代码时,它已经存在使用来自描述的 jdbc 连接池的连接。
我对此感到有些沮丧。有没有办法在部署时禁用创建和填充 jdbc 连接池?预先感谢您的任何帮助。——雅罗斯瓦夫