ds.setAccessToUnderlyingConnectionAllowed( Boolean.valueOf( value ) );
/** * This is left for public API compatibility but it's not as efficient as using the GeoPackage * internal pool * * @param params Map of connection parameter. * @return * @throws IOException */ @Override public BasicDataSource createDataSource(Map params) throws IOException { // create a datasource BasicDataSource dataSource = new BasicDataSource(); // driver dataSource.setDriverClassName(getDriverClassName()); // url dataSource.setUrl(getJDBCUrl(params)); addConnectionProperties(dataSource, params); dataSource.setAccessToUnderlyingConnectionAllowed(true); return dataSource; }
public DataSource createNewDataSource(Map params) throws IOException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName((String) DRIVERCLASS.lookUp(params)); dataSource.setUrl((String) JDBC_URL.lookUp(params)); dataSource.setUsername((String) USERNAME.lookUp(params)); dataSource.setPassword((String) PASSWORD.lookUp(params)); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMaxActive(((Integer) MAXACTIVE.lookUp(params)).intValue()); dataSource.setMaxIdle(((Integer) MAXIDLE.lookUp(params)).intValue()); // check the data source is properly setup by trying to gather a connection out of it Connection conn = null; try { conn = dataSource.getConnection(); } catch (SQLException e) { throw new DataSourceException( "Connection pool improperly set up: " + e.getMessage(), e); } finally { // close the connection at once if (conn != null) try { conn.close(); } catch (SQLException e) { } } return dataSource; }
bds.setMinEvictableIdleTimeMillis( idleConnectionsCleanupTimeoutMs); bds.setAccessToUnderlyingConnectionAllowed(true); bds.setInitialSize(1); bds.setTimeBetweenEvictionRunsMillis(60000);
@Override public synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) { delegate.setAccessToUnderlyingConnectionAllowed(allow); }
/** * Creates a data source by reading properties from a file called 'db.properties', located * paralell to the test setup instance. */ protected DataSource createDataSource() throws IOException { Properties db = fixture; BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(db.getProperty("driver")); dataSource.setUrl(db.getProperty("url")); if (db.containsKey("user")) { dataSource.setUsername(db.getProperty("user")); } else if (db.containsKey("username")) { dataSource.setUsername(db.getProperty("username")); } if (db.containsKey("password")) { dataSource.setPassword(db.getProperty("password")); } dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); initializeDataSource(dataSource, db); // return a closeable data source (DisposableDataSource interface) // so that the connection pool will be tore down on datastore dispose return new DBCPDataSource(dataSource); }
ds.setDriverClassName("org.h2.Driver"); ds.setUrl("jdbc:h2:mem:test_mem"); ds.setAccessToUnderlyingConnectionAllowed(true);
dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setAccessToUnderlyingConnectionAllowed(true);
/** * This method gets a {@link Connection} from the {@link DataSource} and checks if it is a {@link oracle.jdbc.driver.OracleConnection}. * There is a bug with commons-dbcp 1.4: if you want to create a {@link oracle.sql.BLOB} or a {@link java.sql.Clob} than you must get the inner {@link Connection} but you get another {@link Connection}. * This is fixed in this method. * @param connection * @param dataSource * @return */ public static Connection getGoodConnection(Connection connection, DataSource dataSource) { if (dataSource instanceof BasicDataSource) { BasicDataSource tempDataSource = (BasicDataSource) dataSource; if (tempDataSource.getDriverClassName().toLowerCase().contains("oracle") && connection instanceof DelegatingConnection) { boolean canAccess = tempDataSource.isAccessToUnderlyingConnectionAllowed(); if (!canAccess) { tempDataSource.setAccessToUnderlyingConnectionAllowed(true); } DelegatingConnection tempConnection = (DelegatingConnection) connection; Connection innermostDelegate = tempConnection.getInnermostDelegate(); if (!canAccess) { tempDataSource.setAccessToUnderlyingConnectionAllowed(false); } return innermostDelegate; } } return connection; } }
dataSource.setAccessToUnderlyingConnectionAllowed(true); return dataSource;
/** * Prepares a simple data source for the embedded H2 * * @param cacheDirFinder * @return * @throws ConfigurationException */ private DataSource getH2DataSource(DefaultStorageFinder cacheDirFinder) throws ConfigurationException { File storeDirectory = new File(cacheDirFinder.getDefaultPath(), "diskquota_page_store_h2"); storeDirectory.mkdirs(); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); String database = new File(storeDirectory, "diskquota").getAbsolutePath(); dataSource.setUrl("jdbc:h2:" + database); dataSource.setUsername("sa"); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(-1); // boundless dataSource.setMaxWait(5000); return dataSource; }
public DataSource createNewDataSource(Map params) throws IOException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName((String) DRIVERCLASS.lookUp(params)); dataSource.setUrl((String) JDBC_URL.lookUp(params)); dataSource.setUsername((String) USERNAME.lookUp(params)); dataSource.setPassword((String) PASSWORD.lookUp(params)); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMaxActive(((Integer) MAXACTIVE.lookUp(params)).intValue()); dataSource.setMaxIdle(((Integer) MAXIDLE.lookUp(params)).intValue()); // check the data source is properly setup by trying to gather a connection out of it Connection conn = null; try { conn = dataSource.getConnection(); } catch (SQLException e) { throw new DataSourceException("Connection pool improperly set up: " + e.getMessage(), e); } finally { // close the connection at once if (conn != null) try { conn.close(); } catch (SQLException e) { } } return dataSource; }
public DataSource createNewDataSource(Map params) throws IOException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName((String) DRIVERCLASS.lookUp(params)); dataSource.setUrl((String) JDBC_URL.lookUp(params)); dataSource.setUsername((String) USERNAME.lookUp(params)); dataSource.setPassword((String) PASSWORD.lookUp(params)); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMaxActive(((Integer) MAXACTIVE.lookUp(params)).intValue()); dataSource.setMaxIdle(((Integer) MAXIDLE.lookUp(params)).intValue()); // check the data source is properly setup by trying to gather a connection out of it Connection conn = null; try { conn = dataSource.getConnection(); } catch (SQLException e) { throw new DataSourceException("Connection pool improperly set up: " + e.getMessage(), e); } finally { // close the connection at once if (conn != null) try { conn.close(); } catch (SQLException e) { } } return dataSource; }
/** * This is left for public API compatibility but it's not as efficient as using the GeoPackage * internal pool * * @param params Map of connection parameter. * @return * @throws IOException */ @Override public BasicDataSource createDataSource(Map params) throws IOException { // create a datasource BasicDataSource dataSource = new BasicDataSource(); // driver dataSource.setDriverClassName(getDriverClassName()); // url dataSource.setUrl(getJDBCUrl(params)); addConnectionProperties(dataSource, params); dataSource.setAccessToUnderlyingConnectionAllowed(true); return dataSource; }
ds.setMaxIdle(GenericObjectPool.DEFAULT_MAX_IDLE + 10); ds.setValidationQuery(guessValidationQuery(url)); ds.setAccessToUnderlyingConnectionAllowed(true); ds.setPoolPreparedStatements(true); ds.setMaxOpenPreparedStatements(-1); // unlimited
protected BasicDataSource getDataSource() throws IOException, SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(fixtureRule.getFixture().getProperty("driver")); dataSource.setUrl(fixtureRule.getFixture().getProperty("url")); dataSource.setUsername(fixtureRule.getFixture().getProperty("username")); dataSource.setPassword(fixtureRule.getFixture().getProperty("password")); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); cleanupDatabase(dataSource); return dataSource; }
ds.setMaxIdle(GenericObjectPool.DEFAULT_MAX_IDLE + 10); ds.setValidationQuery(guessValidationQuery(url)); ds.setAccessToUnderlyingConnectionAllowed(true); ds.setPoolPreparedStatements(true); ds.setMaxOpenPreparedStatements(-1); // unlimited
ds.setMaxIdle(GenericObjectPool.DEFAULT_MAX_IDLE + 10); ds.setValidationQuery(guessValidationQuery(url)); ds.setAccessToUnderlyingConnectionAllowed(true); ds.setPoolPreparedStatements(true); ds.setMaxOpenPreparedStatements(-1); // unlimited
@Override protected Connection createConnection() throws SQLException { synchronized (this) { if (basicDataSource == null) { DriverConnectionSpec connectionSpec = getConnectionSpec(); BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setDriverClassName(connectionSpec.getDriver()); basicDataSource.setDriverClassLoader(getClassLoader()); basicDataSource.setUrl(connectionSpec.getUrl()); basicDataSource.setUsername(connectionSpec.getUsername()); basicDataSource.setPassword(connectionSpec.getPassword()); JdbcUrl jdbcUrl = connectionSpec.getJdbcUrl(); if (jdbcUrl != null) { addParameters(basicDataSource, jdbcUrl.getParameters()); } addParameters(basicDataSource, connectionSpec.getProperties()); basicDataSource.setAccessToUnderlyingConnectionAllowed(true); this.basicDataSource = basicDataSource; } } return basicDataSource.getConnection(); }
dataSource.setAccessToUnderlyingConnectionAllowed(true); return dataSource;