当前位置: 首页>>代码示例>>Java>>正文


Java PooledDataSource.forceCloseAll方法代码示例

本文整理汇总了Java中org.apache.ibatis.datasource.pooled.PooledDataSource.forceCloseAll方法的典型用法代码示例。如果您正苦于以下问题:Java PooledDataSource.forceCloseAll方法的具体用法?Java PooledDataSource.forceCloseAll怎么用?Java PooledDataSource.forceCloseAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.datasource.pooled.PooledDataSource的用法示例。


在下文中一共展示了PooledDataSource.forceCloseAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldProperlyMaintainPoolOf3ActiveAnd2IdleConnections

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
@Test
public void shouldProperlyMaintainPoolOf3ActiveAnd2IdleConnections() throws Exception {
  PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
  try {
    runScript(ds, JPETSTORE_DDL);
    ds.setDefaultAutoCommit(false);
    ds.setDriverProperties(new Properties() {
      {
        setProperty("username", "sa");
        setProperty("password", "");
      }
    });
    ds.setPoolMaximumActiveConnections(3);
    ds.setPoolMaximumIdleConnections(2);
    ds.setPoolMaximumCheckoutTime(10000);
    ds.setPoolPingConnectionsNotUsedFor(1);
    ds.setPoolPingEnabled(true);
    ds.setPoolPingQuery("SELECT * FROM PRODUCT");
    ds.setPoolTimeToWait(10000);
    ds.setLogWriter(null);
    List<Connection> connections = new ArrayList<Connection>();
    for (int i = 0; i < 3; i++) {
      connections.add(ds.getConnection());
    }
    assertEquals(3, ds.getPoolState().getActiveConnectionCount());
    for (Connection c : connections) {
      c.close();
    }
    assertEquals(2, ds.getPoolState().getIdleConnectionCount());
    assertEquals(4, ds.getPoolState().getRequestCount());
    assertEquals(0, ds.getPoolState().getBadConnectionCount());
    assertEquals(0, ds.getPoolState().getHadToWaitCount());
    assertEquals(0, ds.getPoolState().getAverageOverdueCheckoutTime());
    assertEquals(0, ds.getPoolState().getClaimedOverdueConnectionCount());
    assertEquals(0, ds.getPoolState().getAverageWaitTime());
    assertNotNull(ds.getPoolState().toString());
  } finally {
    ds.forceCloseAll();
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:41,代码来源:PooledDataSourceTest.java

示例2: assertProductsTableExistsAndLoaded

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
private void assertProductsTableExistsAndLoaded() throws IOException, SQLException {
  PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
  try {
    Connection conn = ds.getConnection();
    SqlRunner executor = new SqlRunner(conn);
    List<Map<String, Object>> products = executor.selectAll("SELECT * FROM PRODUCT");
    assertEquals(16, products.size());
  } finally {
    ds.forceCloseAll();
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:12,代码来源:ScriptRunnerTest.java

示例3: testForceCloseMybatisConnectionPoolFalse

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

  // given
  // that the process engine is configured with forceCloseMybatisConnectionPool = false
  ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration()
   .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
   .setProcessEngineName("engine-forceclose")
   .setForceCloseMybatisConnectionPool(false);

  ProcessEngine processEngine = configurationImpl
   .buildProcessEngine();

  PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource();
  PoolState state = pooledDataSource.getPoolState();
  int idleConnections = state.getIdleConnectionCount();


  // then
  // if the process engine is closed
  processEngine.close();

  // the idle connections are not closed
  Assert.assertEquals(state.getIdleConnectionCount(), idleConnections);

  pooledDataSource.forceCloseAll();

  Assert.assertTrue(state.getIdleConnectionCount() == 0);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:30,代码来源:ForceCloseMybatisConnectionPoolTest.java

示例4: assertProductsTableExistsAndLoaded

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
private void assertProductsTableExistsAndLoaded() throws IOException, SQLException {
  PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
  try {
    Connection conn = ds.getConnection();
    SqlRunner executor = new SqlRunner(conn);
    List<Map<String, Object>> products = executor.selectAll("SELECT * FROM PRODUCT");
    assertEquals(16, products.size());
    conn.close();
  } finally {
    ds.forceCloseAll();
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:13,代码来源:ScriptRunnerTest.java


注:本文中的org.apache.ibatis.datasource.pooled.PooledDataSource.forceCloseAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。