public DatabaseHelper(Configuration configuration) { super( configuration.getContext(), configuration.getDatabaseName(), null, configuration.getDatabaseVersion()); copyAttachedDatabase(configuration.getContext(), configuration.getDatabaseName()); mSqlParser = configuration.getSqlParser(); }
private void prepareConfiguration() throws IOException { databaseConfiguration.setDatabaseUrl( String.format( "jdbc:postgresql://%1$s:%2$s/%3$s", configuration.getHost(), configuration.getPort(), configuration.getDatabaseName())); databaseConfiguration.setDatabaseUser(getSystemUser()); databaseConfiguration.setDatabasePassword(getSystemPassword()); }
public DataSource systemDataSource() { final PGSimpleDataSource dataSource = new PGSimpleDataSource(); dataSource.setServerName(configuration.getHost()); dataSource.setPortNumber(configuration.getPort()); dataSource.setUser(getSystemUser()); dataSource.setPassword(getSystemPassword()); dataSource.setDatabaseName(configuration.getDatabaseName()); return dataSource; }
private DataSource sharkDataSource() { final PGSimpleDataSource dataSource = new PGSimpleDataSource(); dataSource.setServerName(configuration.getHost()); dataSource.setPortNumber(configuration.getPort()); dataSource.setUser(SHARK_USERNAME); dataSource.setPassword(SHARK_PASSWORD); dataSource.setDatabaseName(configuration.getDatabaseName()); return dataSource; }
public void drop() { String dbName = configuration.getDatabaseName(); new JdbcTemplate(superDataSource()) .execute(String.format(DROP_DATABASE, escapeSchemaName(dbName))); }
private void alterDatabaseOwnerIfNeeded() { if (needsLimitedUser()) alterDatabaseOwner(configuration.getDatabaseName(), getSystemUser()); }
private void createDatabaseIfNeeded() { if (!EXISTING_DBTYPE.equals(configuration.getDatabaseType())) { createDatabase(configuration.getDatabaseName()); } }