public void setConnectionCacheName(String s) throws SQLException { // the following have to be set together in this exact order dataSource.setConnectionCachingEnabled(true); dataSource.setFastConnectionFailoverEnabled(true); dataSource.setConnectionCacheName(s); }
ods.setConnectionCacheName(source);
OracleDataSource ods = new OracleDataSource(); // set cache properties java.util.Properties prop = new java.util.Properties(); prop.setProperty("MinLimit", "2"); prop.setProperty("MaxLimit", "10"); // set DataSource properties String url = "jdbc:oracle:oci8:@"; ods.setURL(url); ods.setUser("hr"); ods.setPassword("hr"); ods.setConnectionCachingEnabled(true); // be sure set to true ods.setConnectionCacheProperties (prop); ods.setConnectionCacheName("ImplicitCache01"); // this cache's name // We need to create a connection to create the cache Connection conn = ds.getConnection(user, pass); Statement stmt = conn1.createStatement(); ResultSet rset = stmt.executeQuery("select user from dual"); conn1.close(); ods.close();
/** * Creates a database connection pool object using JDBC 2.0. */ private OracleDataSource createConnectionPool() { try { // Create a OracleConnectionPoolDataSource instance. OracleDataSource ds = new OracleDataSource(); ds.setConnectionCacheName("oraCache"); ds.setConnectionCachingEnabled(true); ds.setURL(TestConfig.tab().stringAt(DBParms.jdbcUrl)); ds.setUser(TestConfig.tab().stringAt(DBParms.rdbUser)); ds.setPassword(TestConfig.tab().stringAt(DBParms.rdbPassword)); Properties cacheProps = new Properties(); cacheProps.setProperty("MinLimit", String.valueOf(TestConfig.tab().intAt(DBParms.poolMinLimit))); ds.setConnectionCacheProperties(cacheProps); return ds; } catch (Exception ex) { Log.getLogWriter().info("Unable to create connection pool: " + ex, ex); throw new HydraRuntimeException("Problem creating connection pool", ex); } }
/** * Creates a database connection pool object using JDBC 2.0. */ private OracleDataSource createConnectionPool() { try { // Create a OracleConnectionPoolDataSource instance. OracleDataSource ds = new OracleDataSource(); ds.setConnectionCacheName("oraCache"); ds.setConnectionCachingEnabled(true); ds.setURL(TestConfig.tab().stringAt(JtaPrms.jdbcUrl)); ds.setUser(TestConfig.tab().stringAt(JtaPrms.rdbUser)); ds.setPassword(TestConfig.tab().stringAt(JtaPrms.rdbPassword)); Properties cacheProps = new Properties(); cacheProps.setProperty("MinLimit", String.valueOf(TestConfig.tab().intAt(JtaPrms.poolMinLimit))); ds.setConnectionCacheProperties(cacheProps); return ds; } catch (Exception ex) { Log.getLogWriter().info("Unable to create connection pool: " + ex, ex); throw new HydraRuntimeException("Problem creating Oracle connection pool", ex); } }