简体   繁体   中英

JDBC: Oracle Universal Connection Pool Error UCP-45060 Invalid life cycle state

I am using Oracle UCP (Universal Connection Pool). I am getting the following error after processing around 100K records.

    oracle.ucp.UniversalConnectionPoolException: Invalid life cycle state. Check the status of the Universal Connection Pool
        at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:488) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:163) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:943) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:873) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:863) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
 Caused by: oracle.ucp.UniversalConnectionPoolException: Invalid life cycle state. Check the status of the Universal Connection Pool
            at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:368) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:49) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:80) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:131) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:304) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:168) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:143) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:157) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:931) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            ... 15 more

Here is the code snippet to create the DataSource

PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();


    dataSource.setURL("jdbc.url"));
    dataSource.setUser("jdbc.user"));
    dataSource.setPassword("jdbc.password"));
    dataSource.setMaxConnectionReuseCount(100);

    dataSource.setInitialPoolSize(50);
    dataSource.setMinPoolSize(50);

    dataSource.setMaxPoolSize(100);

    dataSource.setValidateConnectionOnBorrow(true);

    dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");

And then I get the connection from data source as

datasource.getConnection();

就我而言,我使用了错误的密码:|

In my case I encountered this exception during a routine upgrade of a tomcat application. When attempting to interact with an Oracle database (and so getting a connection from the UniversalConnectionPool) the application kept getting this exception.

After reading up on the UniversalConnectionPool ( overview-using-ucp-manager ), I found this line in some Oracle documentation: " a life cycle state exception occurs if an application attempts to start a pool that has been previously started or if the pool is in a state other than stopped or failed. " That is the closest thing I could find for something related to this exception.

I ended up finding that a mistake in my build config meant that I have an OJDBC driver placed in both my application and externally in the Tomcat and somehow these were then interacting with my datasource and the UCP together at the same time, causing the one initialized last to give this error. Removing the OJDBC driver from the classpath in my application fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM