本文整理汇总了Java中bitronix.tm.resource.jdbc.PoolingDataSource.setMaxIdleTime方法的典型用法代码示例。如果您正苦于以下问题:Java PoolingDataSource.setMaxIdleTime方法的具体用法?Java PoolingDataSource.setMaxIdleTime怎么用?Java PoolingDataSource.setMaxIdleTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitronix.tm.resource.jdbc.PoolingDataSource
的用法示例。
在下文中一共展示了PoolingDataSource.setMaxIdleTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
TransactionManagerServices.getConfiguration().setJournal("null").setGracefulShutdownInterval(2);
TransactionManagerServices.getTransactionManager();
MockitoXADataSource.setStaticCloseXAConnectionException(null);
MockitoXADataSource.setStaticGetXAConnectionException(null);
pds = new PoolingDataSource();
pds.setMinPoolSize(1);
pds.setMaxPoolSize(2);
pds.setMaxIdleTime(1);
pds.setClassName(MockitoXADataSource.class.getName());
pds.setUniqueName("pds");
pds.setAllowLocalTransactions(true);
pds.setAcquisitionTimeout(1);
pds.init();
}
示例2: testAcquiringConnectionAfterRecoveryDoesNotMarkAsFailed
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
public void testAcquiringConnectionAfterRecoveryDoesNotMarkAsFailed() throws Exception {
PoolingDataSource poolingDataSource = new PoolingDataSource();
poolingDataSource.setClassName(MockitoXADataSource.class.getName());
poolingDataSource.setUniqueName("ds1");
poolingDataSource.setMaxPoolSize(1);
poolingDataSource.setMaxIdleTime(1); // set low shrink timeout
poolingDataSource.init();
IncrementalRecoverer.recover(poolingDataSource);
MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work"));
Thread.sleep(2000); // wait for shrink
// should not work but should not mark the pool as failed as it could recover
try {
poolingDataSource.getConnection();
fail("expected SQLException");
} catch (SQLException ex) {
assertEquals("unable to get a connection from pool of a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage());
}
poolingDataSource.close();
}
示例3: testPoolNotStartingTransactionManager
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
public void testPoolNotStartingTransactionManager() throws Exception {
if (log.isDebugEnabled()) { log.debug("*** Starting testPoolNotStartingTransactionManager"); }
// make sure TM is not running
TransactionManagerServices.getTransactionManager().shutdown();
PoolingDataSource pds = new PoolingDataSource();
pds.setMinPoolSize(1);
pds.setMaxPoolSize(2);
pds.setMaxIdleTime(1);
pds.setClassName(MockitoXADataSource.class.getName());
pds.setUniqueName("pds2");
pds.setAllowLocalTransactions(true);
pds.setAcquisitionTimeout(1);
pds.init();
assertFalse(TransactionManagerServices.isTransactionManagerRunning());
Connection c = pds.getConnection();
Statement stmt = c.createStatement();
stmt.close();
c.close();
assertFalse(TransactionManagerServices.isTransactionManagerRunning());
pds.close();
assertFalse(TransactionManagerServices.isTransactionManagerRunning());
}