本文整理汇总了Java中com.jolbox.bonecp.BoneCPConfig.setAcquireRetryDelayInMs方法的典型用法代码示例。如果您正苦于以下问题:Java BoneCPConfig.setAcquireRetryDelayInMs方法的具体用法?Java BoneCPConfig.setAcquireRetryDelayInMs怎么用?Java BoneCPConfig.setAcquireRetryDelayInMs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jolbox.bonecp.BoneCPConfig
的用法示例。
在下文中一共展示了BoneCPConfig.setAcquireRetryDelayInMs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConnectionPool
import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
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));
}
}
示例2: DBPool
import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
/**
* 创建一个数据库连接池
* @param poolName
* @param host
* @param port
* @param dbName
* @param username
* @param password
* @param partitionCount
* @param minConnCountPerPar
* @param maxConnCountPerPar
* @throws Exception
*/
protected DBPool(String poolName, String host, String port, String dbName, String username, String password, int partitionCount, int minConnCountPerPar,
int maxConnCountPerPar) throws Exception
{
dbUrl = String.format(URL, host, port, dbName);
this.poolName = poolName;
this.partitionCount = partitionCount;
this.maxConnCountPerPar = maxConnCountPerPar;
this.minConnCountPerPar = minConnCountPerPar;
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(dbUrl);
config.setUsername(username);
config.setPassword(password);
// 分区数
config.setPartitionCount(partitionCount);
// 每次创建的新连接个数
config.setAcquireIncrement(2);
// 处理释放后的conn线程数
config.setReleaseHelperThreads(3);
// 分区最大连接数
config.setMaxConnectionsPerPartition(maxConnCountPerPar);
// 分区最小连接数
config.setMinConnectionsPerPartition(minConnCountPerPar);
// 空闲连接存活时间
config.setIdleMaxAgeInMinutes(10);
// 测试连接时间
config.setIdleConnectionTestPeriodInMinutes(10);
// 设置重新获取连接的次数。这个参数默认为5
config.setAcquireRetryAttempts(5);
// 重新获取连接的间隔时间
config.setAcquireRetryDelayInMs(3000);
boneCP = new BoneCP(config);
}
示例3: setUp
import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
@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);
}