Oracle Connection Pool Class

前端 未结 3 1588
轻奢々
轻奢々 2021-01-07 00:07

I want to setup a connection pool for a Oracle DB in a Helper class.

public class DbConnection {

// Data source for the pooled connection
private static Ora         


        
3条回答
  •  离开以前
    2021-01-07 00:53

    oracle.jdbc.pool.OracleDataSource.setConnectionCachingEnabled documentation state the following:

    Deprecated. Use Oracle Universal Connection Pool instead.

    You can download Oracle Database UCP and create your DataSource as follows:

    import oracle.jdbc.pool.OracleDataSource;
    import oracle.ucp.jdbc.PoolDataSource;
    import oracle.ucp.jdbc.PoolDataSourceFactory;
    
    PoolDataSource poolDataSource = PoolDataSourceFactory.getPoolDataSource();
    poolDataSource.setConnectionFactoryClassName(OracleDataSource.class.getName());
    poolDataSource.setURL("jdbc:oracle:thin:@localhost:1521:XE");
    poolDataSource.setUser("SYSTEM");
    poolDataSource.setPassword("****");
    

提交回复
热议问题