List of usage examples for org.apache.ibatis.datasource.pooled PooledDataSource PooledDataSource
public PooledDataSource(ClassLoader driverClassLoader, String driver, String url, Properties driverProperties)
From source file:org.activiti.upgrade.helper.UpgradeUtil.java
License:Apache License
public static ProcessEngine getProcessEngine(String configResource) { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource(configResource); // When the 'old version' tests are run, we drop the schema always once for the first test if (!DATABASE_DROPPED && isTestRunningAgainstOldVersion()) { synchronized (DATABASE_DROPPED) { if (!DATABASE_DROPPED) { LOG.info("JdbcDriver = " + processEngineConfiguration.getJdbcDriver()); LOG.info("JdbcURL = " + processEngineConfiguration.getJdbcUrl()); LOG.info("JdbcUser = " + processEngineConfiguration.getJdbcUsername()); LOG.info("JdbcPassword = " + processEngineConfiguration.getJdbcPassword()); PooledDataSource dataSource = new PooledDataSource(processEngineConfiguration.getJdbcDriver(), processEngineConfiguration.getJdbcUrl(), processEngineConfiguration.getJdbcUsername(), processEngineConfiguration.getJdbcPassword()); DatabaseConnection connection = null; Database database = null; try { connection = new JdbcConnection(dataSource.getConnection()); database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database);//from w ww. j a v a 2s . c om LOG.info("Dropping upgrade database..."); liquibase.dropAll(); } catch (Exception exception) { exception.printStackTrace(); if (connection != null) { try { connection.close(); } catch (DatabaseException e) { e.printStackTrace(); } } if (database != null) { try { database.close(); } catch (DatabaseException e) { e.printStackTrace(); } } } LOG.info("Dropping upgrade database completed"); DATABASE_DROPPED = true; } } } // Buidling the process engine will also recreate the schema (in that particular version) return processEngineConfiguration.buildProcessEngine(); }
From source file:org.flowable.upgrade.DbDropUtil.java
License:Apache License
public static boolean dropDatabaseTable(String jdbcDriver, String jdbcUrl, String jdbcUser, String jdbcPassword) {//from w ww . j a v a 2s . c o m LOGGER.info("JdbcDriver = " + jdbcDriver); LOGGER.info("JdbcURL = " + jdbcUrl); LOGGER.info("JdbcUser = " + jdbcPassword); PooledDataSource dataSource = new PooledDataSource(jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword); DatabaseConnection connection = null; Database database = null; try { connection = new JdbcConnection(dataSource.getConnection()); database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); } catch (Exception exception) { exception.printStackTrace(); if (connection != null) { try { connection.close(); } catch (DatabaseException e) { e.printStackTrace(); } } if (database != null) { try { database.close(); } catch (DatabaseException e) { e.printStackTrace(); } } } return true; }