connection = Context.getProcessEngineConfiguration().getDataSource().getConnection(); prepStat = connection.prepareStatement(selectTableNamesFromOracle); prepStat.setString(1, databaseTablePrefix + "ACT_%");
connection = Context.getProcessEngineConfiguration().getDataSource().getConnection(); prepStat = connection.prepareStatement(selectTableNamesFromOracle); prepStat.setString(1, databaseTablePrefix + "ACT_%");
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given // that the process engine is configured with forceCloseMybatisConnectionPool = true ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration() .setJdbcUrl("jdbc:h2:mem:camunda-forceclose") .setProcessEngineName("engine-forceclose") .setForceCloseMybatisConnectionPool(true); ProcessEngine processEngine = configurationImpl .buildProcessEngine(); PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource(); PoolState state = pooledDataSource.getPoolState(); // then // if the process engine is closed processEngine.close(); // the idle connections are closed Assert.assertTrue(state.getIdleConnectionCount() == 0); }
connection = Context.getProcessEngineConfiguration().getDataSource().getConnection(); prepStat = connection.prepareStatement(selectTableNamesFromOracle); prepStat.setString(1, databaseTablePrefix + "ACT_%");
@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); }
/** * initialize the {@link ProcessEngineConfiguration} from an existing one, * just using the database settings and initialize the database / MyBatis * stuff. */ public void initFromProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration, List<String> mappings) { this.mappingFiles = mappings; setDatabaseType(processEngineConfiguration.getDatabaseType()); setDataSource(processEngineConfiguration.getDataSource()); setDatabaseTablePrefix(processEngineConfiguration.getDatabaseTablePrefix()); setHistoryLevel(processEngineConfiguration.getHistoryLevel()); setHistory(processEngineConfiguration.getHistory()); initDataSource(); initVariableTypes(); initCommandContextFactory(); initTransactionFactory(); initTransactionContextFactory(); initCommandExecutors(); initIdentityProviderSessionFactory(); initSqlSessionFactory(); initSessionFactories(); }
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given // that the process engine is configured with forceCloseMybatisConnectionPool = true ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration() .setJdbcUrl("jdbc:h2:mem:camunda-forceclose") .setProcessEngineName("engine-forceclose") .setForceCloseMybatisConnectionPool(true); ProcessEngine processEngine = configurationImpl .buildProcessEngine(); PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource(); PoolState state = pooledDataSource.getPoolState(); // then // if the process engine is closed processEngine.close(); // the idle connections are closed Assert.assertTrue(state.getIdleConnectionCount() == 0); }
@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); }