Why is the Java JDBC connection pool checked during deployment

Why is the Java JDBC connection pool checked during deployment?

I have a problem deploying my Java EE application (.ear). The problem is with the JDBC connection pool that I use in my application. I cannot deploy the application to the server. This is what I get on the console:

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... 

Then I get a stack trace of SQLException and the deployment failed.

I know that because the database server is unavailable and the connection cannot be created, but I would still like to deploy the application and get a SQLException in the "application using time". This is the jdbc connection pool definition:

 <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> 

and related jdbc resource:

 <jdbc-resource enabled="true" jndi-name="jdbc/oraclePROD" object-type="user" pool-name="oracle_PROD_Pool"/> 

This issue occurs after upgrading to the new GlassFish 3.1.2.2 server version. I used to use glassFish 3.1.1 (build 12) and there were no deployment problems, I mean that the connection pool was not checked and was full during deployment, it occurs when my application tried to execute code that receives data from the database data using a connection from the jdbc connection pool depicted.

I am a little disappointed with this. Is there a way to disable jdbc connection pool creation and population during deployment? Thanks in advance for any help. --Jaroslaw

+4
source share
2 answers

The connection pool, as you understand, is not an API. It is also not a bean that can be initialized on demand. The server is trying to create a connection pool during server startup. This is similar to creating a thread pool after starting the server. For any application that uses the database to work, it is always recommended to create and initialize the pool when the server starts.

If you really need the application to be separated from the database connection pool, you need to isolate the database connection service in your application as an API. So, do not use the database connection as a service, but as an API.

This will cause the application to start initializing the service when it looks.

0
source

Avoid connection pooling to create connections by setting the minimum / initial connection pool size to zero. Check the documentation associated with the connection pool and application server. For the Apache Tomcat JDBC connection pool, this is "initialSize", for the Oracle Universal Connection Pool it can be "minPoolSize". It can sometimes be difficult to determine the exact setting, as in some cases connection pools are configured through the web admin console.

0
source

Source: https://habr.com/ru/post/1443927/


All Articles