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:com.dangdang.ddframe.rdb.transaction.soft.integrate.storage.RdbTransactionLogStorageOperationsTest.java
@Test public void assertRdbTransactionLogStorageOperations() throws SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.h2.Driver.class.getName()); dataSource.setUrl("jdbc:h2:mem:db_transaction_storage"); dataSource.setUsername("sa"); dataSource.setPassword(""); createTable(dataSource);/*from w w w .ja v a 2 s . c om*/ TransactionLogStorage storage = new RdbTransactionLogStorage(dataSource); assertTransactionLogStorageOperations(storage); }
From source file:jp.go.nict.langrid.serviceexecutor.db.ConnectionManager.java
private void initWithBasicDataSource(String driverClassName, String connectionUrl, String userName, String password, int maxActive, int maxIdle, int maxWait, int maxPSActive) { BasicDataSource bds = new BasicDataSource(); bds.setDriverClassName(driverClassName); bds.setUrl(connectionUrl); bds.setUsername(userName);//from w w w.ja v a 2s . co m bds.setPassword(password); bds.setMaxActive(maxActive); bds.setMaxIdle(maxIdle); bds.setMaxWait(maxWait); if (maxPSActive != -1) { bds.setMaxOpenPreparedStatements(maxPSActive); } this.dataSource = bds; }
From source file:com.alibaba.druid.pool.DBCPTest.java
public void test_dbcp() throws Exception { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(MockDriver.class.getName()); dataSource.setUrl("jdbc:mock:xxx"); dataSource.setMaxOpenPreparedStatements(100); dataSource.setPoolPreparedStatements(true); final String sql = "selelct 1"; {/*from w w w. j av a 2 s .c o m*/ Connection conn = dataSource.getConnection(); CallableStatement stmt = conn.prepareCall(sql); stmt.close(); conn.close(); } { Connection conn = dataSource.getConnection(); CallableStatement stmt = conn.prepareCall(sql); stmt.close(); conn.close(); } }
From source file:com.infodev.fcgorole.configuration.AppConfig.java
@Bean(name = "dataSource") public BasicDataSource dataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUrl("jdbc:mysql://localhost:3306/fcgorecondb"); ds.setUsername("root"); return ds;/*from w ww. j a va 2s .co m*/ }
From source file:com.googlecode.jdbcproc.daofactory.guice.SimpleModule.java
@Provides @Singleton/*w w w .j av a 2 s . co m*/ DataSource provideDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://localhost:3306/jdbcprocdb"); dataSource.setUsername("jdbcproc"); dataSource.setPassword("jdbcproc"); dataSource.setDefaultAutoCommit(true); dataSource.setValidationQuery("call create_collections()"); return dataSource; }
From source file:com.lawulu.bdc.etl.batch.config.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/test"); dataSource.setUsername("root"); dataSource.setPassword("root"); dataSource.setMaxActive(20);/*from w w w. ja v a 2 s .c o m*/ dataSource.setMaxIdle(20); dataSource.setMaxWait(10000); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1"); dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); return dataSource; }
From source file:com.alibaba.cobar.manager.dao.delegate.DataSourceCreator.java
@Override public DataSource createDataSource(String ip, int port, String user, String password) { BasicDataSource ds = new BasicDataSource(); ds.setUsername(user);/*from www. j a v a 2 s . com*/ ds.setPassword(password); ds.setUrl(new StringBuilder().append("jdbc:mysql://").append(ip).append(":").append(port).append("/") .toString()); ds.setDriverClassName(driverClassName); ds.setMaxActive(maxActive); ds.setMinIdle(minIdle); ds.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); ds.setNumTestsPerEvictionRun(numTestsPerEvictionRun); ds.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); return ds; }
From source file:gov.nih.nci.cacis.xds.authz.config.JpaConfig.java
/** * Will return the Data source./*from w ww .jav a2 s . com*/ * * @return the data source */ @Bean(destroyMethod = "close") public DataSource dataSource() { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(url); dataSource.setPassword(password); dataSource.setUsername(username); dataSource.setDriverClassName(driverClassName); return dataSource; }
From source file:cput.codez.angorora.eventstar.app.conf.ConnectionConfig.java
@Bean public DataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUrl("jdbc:mysql://localhost:3306/eventstar"); ds.setUsername("root"); ds.setPassword(null);//w w w. j a v a 2 s . c om return ds; }
From source file:com.abixen.platform.module.configuration.PlatformModuleDataSourceConfiguration.java
@Profile("dev") @Bean(destroyMethod = "close") public DataSource devDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driverClassName); dataSource.setUrl(databaseUrl); dataSource.setUsername(username);//w w w . ja va 2 s . c om dataSource.setPassword(password); return dataSource; }