List of usage examples for org.apache.commons.dbcp BasicDataSource setUrl
public synchronized void setUrl(String url)
Sets the #url .
Note: this method currently has no effect once the pool has been initialized.
From source file:org.plista.kornakapi.core.storage.MySqlStorage.java
public MySqlStorage(StorageConfiguration storageConf, String label, BasicDataSource dataSource) { dataSource.setDriverClassName(storageConf.getJdbcDriverClass()); dataSource.setUrl(storageConf.getJdbcUrl()); dataSource.setUsername(storageConf.getUsername()); dataSource.setPassword(storageConf.getPassword()); //TODO should be made configurable dataSource.setMaxActive(10);/*w w w . j a va2 s.c o m*/ dataSource.setMinIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1;"); dataSource.setTestOnBorrow(false); dataSource.setTestOnReturn(false); dataSource.setTestWhileIdle(true); dataSource.setTimeBetweenEvictionRunsMillis(5000); dataModel = new LabeledMySQLJDBCDataModel(dataSource, "taste_preferences", "user_id", "item_id", "preference", "timestamp", "taste_candidates", "label", label); this.dataSource = dataSource; this.timeWindow = storageConf.getTimeWindow(); if (timeWindow % 6 != 0 || timeWindow == 0) { timeWindow = 24; } }
From source file:org.polyjdbc.core.infrastructure.DataSourceFactory.java
public static DataSource create(Dialect dialect, String databaseUrl, String user, String password) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(DIALECT_DRIVER_CLASS.get(dialect.getCode())); dataSource.setUrl(databaseUrl); dataSource.setUsername(user);//from w ww . j ava 2s. c om dataSource.setPassword(password); dataSource.setDefaultAutoCommit(false); return dataSource; }
From source file:org.polymap.catalog.h2.data.H2DataStoreFactory.java
protected DataSource createDataSource(Map params, SQLDialect dialect) throws IOException { String database = (String) DATABASE.lookUp(params); String host = (String) HOST.lookUp(params); BasicDataSource dataSource = new BasicDataSource(); if (host != null && !host.equals("")) { Integer port = (Integer) PORT.lookUp(params); if (port != null && !port.equals("")) { dataSource.setUrl("jdbc:h2:tcp://" + host + ":" + port + "/" + database); } else {/* ww w . ja v a2 s. c om*/ dataSource.setUrl("jdbc:h2:tcp://" + host + "/" + database); } } else if (baseDirectory == null) { //use current working directory dataSource.setUrl("jdbc:h2:" + database); } else { //use directory specified if the patch is relative String location; if (!new File(database).isAbsolute()) { location = new File(baseDirectory, database).getAbsolutePath(); } else { location = database; } // falko: add support for NIO String osName = System.getProperty("os.name"); Boolean nio = (Boolean) NIO.lookUp(params); Boolean nioMapped = (Boolean) NIO_MAPPED.lookUp(params); String url = null; if ((nio != null && nio.booleanValue()) /*|| osName.toLowerCase().contains( "linux" )*/) { url = "jdbc:h2:nio:" + location; } else if ((nioMapped != null && nioMapped.booleanValue())) { url = "jdbc:h2:nioMapped:" + location; } else { url = "jdbc:h2:file:" + location; } // falko: multi threaded on //url += ";MULTI_THREADED=1"; dataSource.setUrl(url); } String username = (String) USER.lookUp(params); if (username != null) { dataSource.setUsername(username); } String password = (String) PASSWD.lookUp(params); if (password != null) { dataSource.setPassword(password); } dataSource.setDriverClassName("org.h2.Driver"); dataSource.setPoolPreparedStatements(false); return dataSource; }
From source file:org.projectforge.continuousdb.demo.DemoMain.java
private DemoMain() { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUsername("sa"); // dataSource.setPassword("password"); dataSource.setUrl("jdbc:hsqldb:testdatabase"); configuration = new UpdaterConfiguration().setDialect(DatabaseDialect.HSQL).setDataSource(dataSource); databaseUpdateDao = configuration.getDatabaseUpdateDao(); // TableAttribute.register(new TableAttributeHookImpl()); // final SortedSet<UpdateEntry> updateEntries = new TreeSet<UpdateEntry>(); // updateEntries.addAll(DatabaseCoreUpdates.getUpdateEntries(this)); // getSystemUpdater().setUpdateEntries(updateEntries); }
From source file:org.projectforge.continuousdb.demo.UpdateEntryDemoMain.java
private UpdateEntryDemoMain() { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUsername("sa"); // dataSource.setPassword("password"); dataSource.setUrl("jdbc:hsqldb:testdatabase"); configuration = new UpdaterConfiguration().setDialect(DatabaseDialect.HSQL).setDataSource(dataSource); databaseUpdateDao = configuration.getDatabaseUpdateDao(); // TableAttribute.register(new TableAttributeHookImpl()); // final SortedSet<UpdateEntry> updateEntries = new TreeSet<UpdateEntry>(); // updateEntries.addAll(DatabaseCoreUpdates.getUpdateEntries(this)); // getSystemUpdater().setUpdateEntries(updateEntries); }
From source file:org.qi4j.entitystore.sql.ImportedDataSourceServiceTest.java
@SuppressWarnings("unchecked") public void assemble(ModuleAssembly module) throws AssemblyException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(CONNECTION_STRING); try {/*from www . j a va 2 s .co m*/ new DerbySQLEntityStoreAssembler(new DataSourceAssembler(new ImportableDataSourceService(dataSource))) .assemble(module); } catch (AssemblyException e) { Assume.assumeNoException(e); } }
From source file:org.qi4j.library.sql.datasource.ExternalDataSourceTest.java
@Override public void assemble(ModuleAssembly module) throws AssemblyException { BasicDataSource externalDataSource = new BasicDataSource(); externalDataSource.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver"); externalDataSource.setUrl("jdbc:derby:memory:testdbexternal;create=true"); // START SNIPPET: assembly new ExternalDataSourceAssembler(externalDataSource).visibleIn(Visibility.module) .identifiedBy("datasource-external-id") .withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(module); // END SNIPPET: assembly }
From source file:org.raistlic.spring.test.flyway.FlywayTestConfiguration.java
@Bean public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver"); dataSource.setUrl("jdbc:derby:test;create=true"); dataSource.setUsername("sa"); dataSource.setPassword(""); return dataSource; }
From source file:org.runway.utils.ServerBean.java
public static void main(String[] args) { //String propFileName = args[0]; Properties props = new Properties(); props.put("server.port", "9101"); props.put("server.database.0", "emarket.db"); props.put("server.dbname.0", "shark"); BasicDataSource datasource = new BasicDataSource(); datasource.setDriverClassName("org.hsqldb.jdbcDriver"); datasource.setUrl("jdbc:hsqldb:hsql://localhost:9101/shark"); datasource.setUsername("sa"); datasource.setPassword(""); ServerBean server = new ServerBean(); server.setServerProperties(props);//from w ww . j a va 2 s . co m server.setDataSource(datasource); try { server.initialize(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.sbq.batch.configurations.DatabaseConfiguration.java
@Bean(destroyMethod = "close") public DataSource dbcpDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/batch_db"); dataSource.setUsername("root"); dataSource.setPassword(""); dataSource.setMaxActive(20);//from w w w.ja v a2s . c o m dataSource.setMaxIdle(20); dataSource.setMaxWait(10000); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1"); dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); return dataSource; }