private EmbeddedConnectionPoolDataSource createDerbyDataSource() throws SQLException { if (isInTestMode()) { EmbeddedConnectionPoolDataSource dataSource = new EmbeddedConnectionPoolDataSource(); dataSource.setDatabaseName("memory:ehourDb"); return dataSource; } else { EmbeddedConnectionPoolDataSource dataSource = new EmbeddedConnectionPoolDataSource(); dataSource.setDatabaseName("ehourDb"); return dataSource; } }
/** * Return whether the database should be created if it does not already exist. * * @return true if the database should be created */ public Boolean getCreateDatabase() { return "create".equals(connectionPoolDataSource.getCreateDatabase()); }
/** * Return the database name. * * @return the database name */ public String getDatabaseName() { return connectionPoolDataSource.getDatabaseName(); }
private void createInMemoryDb() throws SQLException { EmbeddedConnectionPoolDataSource csDataSource = new EmbeddedConnectionPoolDataSource(); csDataSource.setDatabaseName("memory:ehourDb;create=true"); csDataSource.getPooledConnection().close(); }
/** * Default constructor for a Derby Embedded Local DataSource. */ public EmbeddedLocalMCF() { super(new EmbeddedConnectionPoolDataSource(), new NoExceptionsAreFatalSorter()); }
/** * Set the database name. * * @param name the database name */ public void setDatabaseName(String name) { connectionPoolDataSource.setDatabaseName(name); }
/** * Return the password credential used to establish the connection. * * @return the password credential used to establish the connection */ public String getPassword() { return connectionPoolDataSource.getPassword(); }
@Override public ConnectionPoolDataSource createConnectionPoolDataSource(Properties props) throws SQLException { EmbeddedConnectionPoolDataSource ds = new EmbeddedConnectionPoolDataSource(); setProperties(ds, props); return ds; }
@Test public void shouldAlter() throws IOException { EmbeddedConnectionPoolDataSource dataSource = new EmbeddedConnectionPoolDataSource(); dataSource.setDatabaseName("memory:db;create=true"); DerbyDbValidator prevalidator = new DerbyDbValidator("1.4", dataSource); prevalidator.checkDatabaseState(); DerbyDbValidator validator = new DerbyDbValidator("99", dataSource); DerbyDbValidator.DdlType state = validator.checkDatabaseState(); assertEquals(DerbyDbValidator.DdlType.ALTER_TABLE, state); } }
@Override public ConnectionPoolDataSource createConnectionPoolDataSource(Properties props) throws SQLException { EmbeddedConnectionPoolDataSource ds = new EmbeddedConnectionPoolDataSource(); setProperties(ds, props); return ds; }