PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);
public PooledDataSourceFactory() { this.dataSource = new PooledDataSource(); }
public PooledDataSourceFactory() { this.dataSource = new PooledDataSource(); }
new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);
new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);
public PooledDataSourceFactory() { this.dataSource = new PooledDataSource(); }
public void afterPropertiesSet() throws Exception { dataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000;MVCC=TRUE;", "sa", "" ); // create schema in the Connection connection = dataSource.getConnection(); connection.createStatement().execute("drop schema if exists SCHEMA1"); connection.createStatement().execute("create schema SCHEMA1"); connection.close(); ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration() .setProcessEngineName("DatabaseTablePrefixTest-engine1") .setDataSource(dataSource) .setDbMetricsReporterActivate(false) .setDatabaseSchemaUpdate("NO_CHECK"); // disable auto create/drop schema config1.setDatabaseTablePrefix("SCHEMA1."); ProcessEngine engine1 = config1.buildProcessEngine(); // create the tables in SCHEMA1 connection = dataSource.getConnection(); connection.createStatement().execute("set schema SCHEMA1"); engine1.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA1"); connection.close(); engine1.close(); }
public void testTablePresentWithSchemaAndPrefix() throws SQLException { PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", ""); Connection connection = pooledDataSource.getConnection(); connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME); connection.createStatement().execute("create schema " + SCHEMA_NAME); connection.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));"); connection.close(); ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1") // disable auto create/drop schema .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK"); config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME); config1.setDatabaseSchema(SCHEMA_NAME); config1.setDbMetricsReporterActivate(false); ProcessEngine engine = config1.buildProcessEngine(); CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired(); commandExecutor.execute(new Command<Void>(){ public Void execute(CommandContext commandContext) { DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class); assertTrue(sqlSession.isTablePresent("SOME_TABLE")); return null; } }); engine.close(); }
public void testPerformDatabaseSchemaOperationCreateTwice() throws Exception { // both process engines will be using this datasource. PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", ""); Connection connection = pooledDataSource.getConnection(); connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME); connection.createStatement().execute("create schema " + SCHEMA_NAME); connection.close(); ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1") // disable auto create/drop schema .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK"); config1.setDatabaseTablePrefix(SCHEMA_NAME + "."); config1.setDatabaseSchema(SCHEMA_NAME); config1.setDbMetricsReporterActivate(false); ProcessEngine engine1 = config1.buildProcessEngine(); // create the tables for the first time connection = pooledDataSource.getConnection(); connection.createStatement().execute("set schema " + SCHEMA_NAME); engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME); connection.close(); // create the tables for the second time; here we shouldn't crash since the // session should tell us that the tables are already present and // databaseSchemaUpdate is set to noop connection = pooledDataSource.getConnection(); connection.createStatement().execute("set schema " + SCHEMA_NAME); engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME); engine1.close(); }
public static DataSource getDataSource() { String driver = PROPERTIES.getProperty("jdbc.driverClassName"); String url = PROPERTIES.getProperty("jdbc.url"); String username = PROPERTIES.getProperty("jdbc.username"); String password = PROPERTIES.getProperty("jdbc.password"); PooledDataSource dataSource = new PooledDataSource(driver, url, username, password); return dataSource; }
PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000",
@Override protected boolean doLoad() throws ModuleException { Properties driverProperties = new Properties(); driverProperties.setProperty("driver.encoding", "UTF-8"); //******* driverProperties ***** //poolMaximumActiveConnections //poolMaximumIdleConnections //poolMaximumCheckoutTime //poolTimeToWait //poolPingQuery //poolPingEnabled //poolPingConnectionsNotUsedFor ////////////////////////////////// PooledDataSource dataSource = new PooledDataSource(derbyEmbeddedDriver, dbPath, driverProperties); org.apache.ibatis.mapping.Environment environment = new org.apache.ibatis.mapping.Environment("ID", new JdbcTransactionFactory(), dataSource); Configuration configuration = new Configuration(environment); if(mapperFileList != null){ for(URL mapperFile : mapperFileList){ addSqlMappings(configuration, mapperFile); } } sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration); logger.info("DBModule[{}] Loaded! with {}", dbPath, mapperFileList); return true; }
new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword );
new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword );
PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);
new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);
public void afterPropertiesSet() throws Exception { dataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000;MVCC=TRUE;", "sa", "" ); // create schema in the Connection connection = dataSource.getConnection(); connection.createStatement().execute("drop schema if exists SCHEMA1"); connection.createStatement().execute("create schema SCHEMA1"); connection.close(); ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration() .setProcessEngineName("DatabaseTablePrefixTest-engine1") .setDataSource(dataSource) .setDbMetricsReporterActivate(false) .setDatabaseSchemaUpdate("NO_CHECK"); // disable auto create/drop schema config1.setDatabaseTablePrefix("SCHEMA1."); ProcessEngine engine1 = config1.buildProcessEngine(); // create the tables in SCHEMA1 connection = dataSource.getConnection(); connection.createStatement().execute("set schema SCHEMA1"); engine1.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA1"); connection.close(); engine1.close(); }
public void testTablePresentWithSchemaAndPrefix() throws SQLException { PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", ""); Connection connection = pooledDataSource.getConnection(); connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME); connection.createStatement().execute("create schema " + SCHEMA_NAME); connection.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));"); connection.close(); ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1") // disable auto create/drop schema .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK"); config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME); config1.setDatabaseSchema(SCHEMA_NAME); config1.setDbMetricsReporterActivate(false); ProcessEngine engine = config1.buildProcessEngine(); CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired(); commandExecutor.execute(new Command<Void>(){ public Void execute(CommandContext commandContext) { DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class); assertTrue(sqlSession.isTablePresent("SOME_TABLE")); return null; } }); engine.close(); }
public void testPerformDatabaseSchemaOperationCreateTwice() throws Exception { // both process engines will be using this datasource. PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", ""); Connection connection = pooledDataSource.getConnection(); connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME); connection.createStatement().execute("create schema " + SCHEMA_NAME); connection.close(); ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1") // disable auto create/drop schema .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK"); config1.setDatabaseTablePrefix(SCHEMA_NAME + "."); config1.setDatabaseSchema(SCHEMA_NAME); config1.setDbMetricsReporterActivate(false); ProcessEngine engine1 = config1.buildProcessEngine(); // create the tables for the first time connection = pooledDataSource.getConnection(); connection.createStatement().execute("set schema " + SCHEMA_NAME); engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME); connection.close(); // create the tables for the second time; here we shouldn't crash since the // session should tell us that the tables are already present and // databaseSchemaUpdate is set to noop connection = pooledDataSource.getConnection(); connection.createStatement().execute("set schema " + SCHEMA_NAME); engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME); engine1.close(); }
public DBManager(AppConfiguration appConfig) { this.appConfig = appConfig; boolean isDev = appConfig.getBool(CONFIG_KEY_APP_DEV_MODE, true); String dbHost = appConfig.get(CONFIG_KEY_MYSQL_HOST, DEFAULT_MYSQL_HOST); int dbPort = appConfig.getInt(CONFIG_KEY_MYSQL_PORT, DEFAULT_MYSQL_PORT); String dbName = appConfig.get(CONFIG_KEY_MYSQL_DBNAME, DEFAULT_MEYSQL_DBNAME); String dbUser = appConfig.get(CONFIG_KEY_MYSQL_USER, ""); String dbPass = appConfig.get(CONFIG_KEY_MYSQL_PASS, ""); String dbDriver = "com.mysql.cj.jdbc.Driver"; String connString = "jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName + "?autoReconnect=true&useSSL=false&useUnicode=true"; DataSource dataSource = new PooledDataSource(dbDriver, connString, dbUser, dbPass); TransactionFactory transactionFactory = new JdbcTransactionFactory(); Environment environment = new Environment(isDev ? "development" : "production", transactionFactory, dataSource); configuration = new Configuration(environment); configuration.addMappers("com.elune.dao"); sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration); }