@Override public void shutdown(DataSource dataSource, String databaseName) { try { new EmbeddedDriver().connect( String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties()); } catch (SQLException ex) { // Error code that indicates successful shutdown if (!"08006".equals(ex.getSQLState())) { LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex); } } }
@Override public boolean acceptsURL(String url) throws SQLException { url = url.replace("sderby", "derby"); return super.acceptsURL(url); }
/** * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a * directory called "jpaserver_derby_files". * * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource. */ @Bean(destroyMethod = "close") public DataSource dataSource() { String url = "jdbc:derby:directory:target/jpaserver_derby_files;create=true"; if (isNotBlank(ContextHolder.getDatabaseUrl())) { url = ContextHolder.getDatabaseUrl(); } BasicDataSource retVal = new BasicDataSource(); retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver()); retVal.setUrl(url); retVal.setUsername(""); retVal.setPassword(""); return retVal; }
@Override public Connection connect(String url, Properties info) throws SQLException { url = url.replace("sderby", "derby"); return new StatementVerifyingDerby.StatementVerifyingConnection(super.connect(url, info)); }
@Override public Driver createDriver(Properties props) throws SQLException { EmbeddedDriver driver = new EmbeddedDriver(); return driver; }
@Override public Connection connect(java.lang.String url, java.util.Properties info) throws SQLException { TestObjectStoreInitRetry.misbehave(); url = url.replace("fderby","derby"); return new FakeDerby.Connection(super.connect(url, info)); }
@Override public void shutdown(DataSource dataSource, String databaseName) { try { new EmbeddedDriver().connect( String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties()); } catch (SQLException ex) { // Error code that indicates successful shutdown if (!"08006".equals(ex.getSQLState())) { LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex); } } }
@Override public Driver createDriver(Properties props) throws SQLException { EmbeddedDriver driver = new EmbeddedDriver(); return driver; }
@Override public boolean acceptsURL(String url) throws SQLException { url = url.replace("fderby","derby"); return super.acceptsURL(url); }
public void shutdown(DataSource dataSource, String databaseName) { try { new EmbeddedDriver().connect( String.format(URL_TEMPLATE, databaseName, SHUTDOWN_COMMAND), new Properties()); } catch (SQLException ex) { if (!SHUTDOWN_CODE.equals(ex.getSQLState())) { logger.warn("Could not shutdown in-memory Derby database", ex); return; } if (!IS_AT_LEAST_DOT_SIX) { // Explicitly purge the in-memory database, to prevent it // from hanging around after being shut down. try { VFMemoryStorageFactory.purgeDatabase(new File(databaseName).getCanonicalPath()); } catch (IOException ex2) { logger.warn("Could not purge in-memory Derby database", ex2); } } } }
public void doStart() throws Exception { // set up the system property for the database home actualHome = System.getProperty(SYSTEM_HOME); if (actualHome == null) { actualHome = serverInfo.resolveServerPath(systemHome); } System.setProperty(SYSTEM_HOME, actualHome); // set the magic system property that causes derby to use explicity // file sync instead of relying on vm support for file open rws System.setProperty("derby.storage.fileSyncTransactionLog", "true"); // load the Embedded driver to initialize the home new org.apache.derby.jdbc.EmbeddedDriver(); log.debug("Started in " + actualHome); }
private void startDatabase() throws SQLException { registerDriver(new org.apache.derby.jdbc.EmbeddedDriver()); }