List of usage examples for org.apache.commons.dbcp BasicDataSource BasicDataSource
BasicDataSource
From source file:com.gs.obevo.dbmetadata.api.DbMetadataComparisonUtilTest.java
@Before public void setup() throws Exception { this.ds = new BasicDataSource(); this.ds.setDriverClassName(org.h2.Driver.class.getName()); this.ds.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", schema)); this.ds.setUsername("sa"); this.ds.setPassword(""); this.jdbc = new QueryRunner(this.ds); this.jdbc.update("DROP SCHEMA IF EXISTS " + schema); this.jdbc.update("CREATE SCHEMA " + schema); this.metadataManager = new DbMetadataManagerImpl(dbMetadataDialect, this.ds); this.dbMetadataComparisonUtil = new DbMetadataComparisonUtil(); }
From source file:com.btmatthews.mockjndi.datasource.DataSourceBinding.java
@Override protected synchronized Object createBoundObject() { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driver); dataSource.setUrl(url);/*from ww w. j ava 2s . com*/ if (user != null) { dataSource.setUsername(user); if (password != null) { dataSource.setPassword(password); } } return dataSource; }
From source file:com.gantzgulch.sharing.configuration.DataSourceContextProduction.java
@Bean(name = "sharingDS") public DataSource sharingDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUrl("jdbc:hsqldb:file:" + storageLocation + "/sharing_db"); dataSource.setUsername("sa"); dataSource.setPassword(""); return dataSource; }
From source file:cn.edu.seu.cose.jellyjolly.model.dao.jdbc.mysql.MysqlConnectionFactory.java
private void initDataSource() throws IOException { BasicDataSource ds = new BasicDataSource(); Properties cfgpp = new Properties(); cfgpp.load(MysqlConnectionFactory.class.getResourceAsStream("dbcp.jdbc.properties")); ds.setDriverClassName(cfgpp.getProperty("jdbc.driverClassName")); ds.setUrl(cfgpp.getProperty("jdbc.url")); ds.setUsername(cfgpp.getProperty("jdbc.username")); ds.setPassword(cfgpp.getProperty("jdbc.password")); dataSource = ds;/*from ww w .j av a 2 s . com*/ }
From source file:com.dangdang.ddframe.job.event.rdb.JobEventRdbStorageTest.java
@Before public void setup() throws SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.h2.Driver.class.getName()); dataSource.setUrl("jdbc:h2:mem:job_event_storage"); dataSource.setUsername("sa"); dataSource.setPassword(""); storage = new JobEventRdbStorage(dataSource); }
From source file:cn.cuizuoli.gotour.config.DataSourceConfig.java
@Bean public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(env.getRequiredProperty("gotour.jdbc.driverClassName")); dataSource.setUrl(env.getRequiredProperty("gotour.jdbc.url")); dataSource.setUsername(env.getRequiredProperty("gotour.jdbc.username")); dataSource.setPassword(env.getRequiredProperty("gotour.jdbc.password")); dataSource.setInitialSize(env.getRequiredProperty("jdbc.initialSize", Integer.class)); dataSource.setMaxActive(env.getRequiredProperty("jdbc.maxActive", Integer.class)); dataSource.setMaxIdle(env.getRequiredProperty("jdbc.maxIdle", Integer.class)); dataSource.setMinIdle(env.getRequiredProperty("jdbc.minIdle", Integer.class)); dataSource.setDefaultAutoCommit(env.getRequiredProperty("jdbc.defaultAutoCommit", Boolean.class)); dataSource.setPoolPreparedStatements(env.getRequiredProperty("jdbc.poolPreparedStatements", Boolean.class)); dataSource.setValidationQuery(env.getRequiredProperty("jdbc.validationQuery")); dataSource.setTestOnBorrow(env.getRequiredProperty("jdbc.testOnBorrow", Boolean.class)); dataSource.setTestOnReturn(env.getRequiredProperty("jdbc.testOnReturn", Boolean.class)); dataSource.setTestWhileIdle(env.getRequiredProperty("jdbc.testWhileIdle", Boolean.class)); dataSource.setTimeBetweenEvictionRunsMillis( env.getRequiredProperty("jdbc.timeBetweenEvictionRunsMillis", Long.class)); dataSource.setNumTestsPerEvictionRun(env.getRequiredProperty("jdbc.numTestsPerEvictionRun", Integer.class)); dataSource.setMinEvictableIdleTimeMillis( env.getRequiredProperty("jdbc.minEvictableIdleTimeMillis", Long.class)); return dataSource; }
From source file:au.com.jwatmuff.eventmanager.db.sqlite.SQLiteDatabaseManager.java
@Override protected TransactionalDatabase getLocalDatabase(DatabaseInfo database) { dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.sqlite.JDBC.class.getName()); dataSource.setUrl("jdbc:sqlite:" + database.localDirectory + "/database.db"); //dataSource.setUrl("jdbc:sqlite::memory:"); dataSource.setInitialSize(1); //only one connection - important if we use in memory sqlite database dataSource.setMaxActive(1);//from w w w .j av a2 s .c om dataSource.setMaxWait(0); // wait indefinitely for connection to be free SQLiteDatabase localDb = new SQLiteDatabase(); localDb.setDataSource(dataSource); localDb.afterPropertiesSet(); return localDb; }
From source file:com.dangdang.ddframe.job.statistics.rdb.StatisticRdbRepositoryTest.java
@Before public void setup() throws SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.h2.Driver.class.getName()); dataSource.setUrl("jdbc:h2:mem:"); dataSource.setUsername("sa"); dataSource.setPassword(""); repository = new StatisticRdbRepository(dataSource); }
From source file:com.thinkbiganalytics.jira.JiraSpringTestConfig.java
@Bean public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl("jdbc:mysql://localhost:3306/pipeline_db"); dataSource.setUsername("root"); dataSource.setDriverClassName("org.mariadb.jdbc.Driver"); //dataSource.setPassword("password"); return dataSource; }
From source file:net.certifi.audittablegen.HsqldbDMR.java
/** * Generate a Hsqldb DataSource from Properties * * @param props/*from ww w. j ava2 s. c om*/ * @return BasicDataSource as DataSource */ static DataSource getRunTimeDataSource(Properties props) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUsername(props.getProperty("username")); dataSource.setPassword(props.getProperty("password")); dataSource.setUrl(props.getProperty("url")); dataSource.setMaxActive(10); dataSource.setMaxIdle(5); dataSource.setInitialSize(5); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"); return dataSource; }