public static DataSource createDataSource(String homeDir, String dbName) throws IOException { // Setup the Derby datasource. System.setProperty("derby.system.home", homeDir); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName(dbName); ds.setCreateDatabase("create"); return ds; }
@Override protected DataSource createInstance() throws Exception { File directory = new File(dataDirectory); System.setProperty("derby.system.home", directory.getCanonicalPath()); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName("build/derbydb"); ds.setCreateDatabase("create"); return ds; }
@Override protected DataSource createInstance() throws Exception { File directory = new File(dataDirectory); System.setProperty("derby.system.home", directory.getCanonicalPath()); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName("build/derbydb"); ds.setCreateDatabase("create"); logger.info("Created instance of " + ds.toString()); return ds; }
@Override DataSource createDataSource() { EmbeddedDataSource dataSource = new EmbeddedDataSource(); dataSource.setUser(""); dataSource.setPassword(""); dataSource.setDatabaseName("dbtest"); dataSource.setCreateDatabase("create"); dataSource.setConnectionAttributes("upgrade=true"); return dataSource; } };
/** * Default constructor for a Derby Embedded Local DataSource. */ public EmbeddedLocalMCF() { super(new EmbeddedDataSource(), new NoExceptionsAreFatalSorter(), false); ds = (EmbeddedDataSource) super.dataSource; }
@Override public DataSource createDataSource(Properties props) throws SQLException { EmbeddedDataSource ds = new EmbeddedDataSource(); setProperties(ds, props); return ds; }
@Override public DataSource createDataSource(Properties props) throws SQLException { EmbeddedDataSource ds = new EmbeddedDataSource(); setProperties(ds, props); return ds; }
public static DataSource createDataSource(String homeDir, String dbName) throws IOException { // Setup the Derby datasource. System.setProperty("derby.system.home", homeDir); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName(dbName); ds.setCreateDatabase("create"); return ds; }
public static DataSource createDataSource(String homeDir, String dbName) throws IOException { // Setup the Derby datasource. System.setProperty("derby.system.home", homeDir); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName(dbName); ds.setCreateDatabase("create"); return ds; }
public static DataSource createDataSource(String homeDir, String dbName) throws IOException { // Setup the Derby datasource. System.setProperty("derby.system.home", homeDir); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName(dbName); ds.setCreateDatabase("create"); return ds; }
protected DataSource createDataSource() throws IOException { // Setup the Derby datasource. System.setProperty("derby.system.home", getDataDirectoryFile().getCanonicalPath()); System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.pageCacheSize", "100"); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName("derbydb"); ds.setCreateDatabase("create"); return ds; }
Connection getConnection() throws SQLException, DAOConnection { EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName(dbUri); ds.setPassword(password); ds.setUser(username); Connection conn = null; try { conn = ds.getConnection(); } catch (SQLException e) { // check if cannot connect due to "Another instance of // Derby may have already booted the database". // The error code of this exception is 45000. if (e.getNextException().getErrorCode() == 45000) { throw new DAOConnection(e.getNextException().getMessage()); } throw new SQLException(e); } conn.setSchema(schema); return conn; }
/** * Creates the data source. * * @param name * the name * @return the data source */ protected DataSource createDataSource(String name) { logger.debug("Creating an embedded Derby datasource..."); synchronized (DerbyDatabase.class) { try { DataSource dataSource = new EmbeddedDataSource(); String derbyRoot = prepareRootFolder(name); ((EmbeddedDataSource) dataSource).setDatabaseName(derbyRoot); ((EmbeddedDataSource) dataSource).setCreateDatabase("create"); logger.warn(String.format("Embedded Derby at: %s", derbyRoot)); WrappedDataSource wrappedDataSource = new WrappedDataSource(dataSource); DATASOURCES.put(name, wrappedDataSource); return wrappedDataSource; } catch (IOException e) { logger.error(e.getMessage(), e); throw new DerbyDatabaseException(e); } } }
public DatabaseUtil(Credential cred, String baseDir, String bootPassword) { this.baseDir = baseDir; dataSource = new EmbeddedDataSource(); dataSource.setUser(cred.getUsername()); dataSource.setPassword(cred.getPassword()); dataSource.setDatabaseName(baseDir); if (!bootPassword.equals(NOT_ENCRYPTED)) { String connAtts = "dataEncryption=true;bootPassword=" + bootPassword; dataSource.setConnectionAttributes(connAtts); } jdbcTemplate = new JdbcTemplate(dataSource); }
public void start() throws SQLException, IOException { if (!running) { System.setProperty("derby.system.home", DERBY_SYSTEM_HOME); File db = new File("target/test-db"); db.mkdirs(); EmbeddedDataSource newDataSource = new EmbeddedDataSource(); newDataSource.setCreateDatabase("create"); newDataSource.setDatabaseName(dbName); dataSource = newDataSource; final Connection conn = dataSource.getConnection(); conn.close(); running = true; } }
public void start() throws SQLException, IOException { if (!running) { System.setProperty("derby.system.home", DERBY_SYSTEM_HOME); File db = new File("target/test-db"); db.mkdirs(); EmbeddedDataSource newDataSource = new EmbeddedDataSource(); newDataSource.setCreateDatabase("create"); newDataSource.setDatabaseName(dbName); dataSource = newDataSource; final Connection conn = dataSource.getConnection(); conn.close(); running = true; } }
return new TestDatabase(TEST_DATABASE); final EmbeddedDataSource ds = new EmbeddedDataSource(); ds.setDatabaseName("memory:" + name); ds.setDataSourceName("Apache SIS test database");