Java Code Examples for com.jolbox.bonecp.BoneCPConfig#setAcquireRetryAttempts()
The following examples show how to use
com.jolbox.bonecp.BoneCPConfig#setAcquireRetryAttempts() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseConnections.java From StatsAgg with Apache License 2.0 | 6 votes |
public static void createConnectionPool() { BoneCPConfig config = new BoneCPConfig(); config.setMaxConnectionsPerPartition(DatabaseConfiguration.getCpMaxConnections()); config.setAcquireRetryAttempts(DatabaseConfiguration.getCpAcquireRetryAttempts()); config.setAcquireRetryDelayInMs(DatabaseConfiguration.getCpAcquireRetryDelay()); config.setConnectionTimeoutInMs(DatabaseConfiguration.getCpConnectionTimeout()); config.setStatisticsEnabled(DatabaseConfiguration.isCpEnableStatistics()); config.setDisableConnectionTracking(true); // set this to true to avoid bonecp closing connections erroniously config.setJdbcUrl(jdbc_); config.setUsername(DatabaseConfiguration.getUsername()); config.setPassword(DatabaseConfiguration.getPassword()); config.setDefaultAutoCommit(DatabaseConfiguration.getCpDefaultAutoCommit()); try { connectionPool_ = new BoneCP(config); } catch (Exception e) { connectionPool_ = null; logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); } }
Example 2
Source File: DbTest.java From netcrusher-java with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { reactor = new NioReactor(); crusher = TcpCrusherBuilder.builder() .withReactor(reactor) .withBindAddress("127.0.0.1", CRUSHER_PORT) .withConnectAddress("127.0.0.1", DB_PORT) .buildAndOpen(); hsqlServer = new Server(); hsqlServer.setAddress("127.0.0.1"); hsqlServer.setPort(DB_PORT); hsqlServer.setDaemon(true); hsqlServer.setErrWriter(new PrintWriter(System.err)); hsqlServer.setLogWriter(new PrintWriter(System.out)); hsqlServer.setNoSystemExit(true); hsqlServer.setDatabasePath(0, "mem:testdb"); hsqlServer.setDatabaseName(0, "testdb"); hsqlServer.start(); Class.forName("org.hsqldb.jdbc.JDBCDriver"); BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(String.format("jdbc:hsqldb:hsql://127.0.0.1:%d/testdb", CRUSHER_PORT)); config.setUsername("sa"); config.setPassword(""); config.setInitSQL(SQL_CHECK); config.setConnectionTestStatement(SQL_CHECK); config.setAcquireIncrement(1); config.setAcquireRetryAttempts(1); config.setAcquireRetryDelayInMs(1000); config.setConnectionTimeoutInMs(1000); config.setQueryExecuteTimeLimitInMs(1000); config.setDefaultAutoCommit(false); config.setDefaultReadOnly(true); config.setDefaultTransactionIsolation("NONE"); config.setPartitionCount(1); config.setMinConnectionsPerPartition(1); config.setMaxConnectionsPerPartition(1); config.setLazyInit(true); config.setDetectUnclosedStatements(true); connectionPool = new BoneCP(config); }