Exemplo n.º 1
0
 public DatabaseHelper(Configuration configuration) {
   super(
       configuration.getContext(),
       configuration.getDatabaseName(),
       null,
       configuration.getDatabaseVersion());
   copyAttachedDatabase(configuration.getContext(), configuration.getDatabaseName());
   mSqlParser = configuration.getSqlParser();
 }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 public void drop() {
   String dbName = configuration.getDatabaseName();
   new JdbcTemplate(superDataSource())
       .execute(String.format(DROP_DATABASE, escapeSchemaName(dbName)));
 }
Exemplo n.º 6
0
 private void alterDatabaseOwnerIfNeeded() {
   if (needsLimitedUser()) alterDatabaseOwner(configuration.getDatabaseName(), getSystemUser());
 }
Exemplo n.º 7
0
 private void createDatabaseIfNeeded() {
   if (!EXISTING_DBTYPE.equals(configuration.getDatabaseType())) {
     createDatabase(configuration.getDatabaseName());
   }
 }