ds.setInitialSize(Integer.parseInt(defaultIfNull(val, "10")));
@SuppressWarnings( "deprecation" ) private static void setPoolProperties( BasicDataSource ds, Properties properties, int initialSize, int maxSize ) { ds.setInitialSize( initialSize ); ds.setMaxActive( maxSize ); ds.setInitialSize( Integer.valueOf( value ) );
BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("username"); dataSource.setPassword("password"); dataSource.setUrl("jdbc:mysql://<host>:<port>/<database>"); dataSource.setMaxActive(10); dataSource.setMaxIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1");
@PostConstruct public void init() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl("jdbc:derby:" + NACOS_HOME + File.separator + DERBY_BASE_DIR + ";create=true"); ds.setUsername(USER_NAME); ds.setPassword(PASSWORD); ds.setInitialSize(20); ds.setMaxActive(30); ds.setMaxIdle(50); ds.setMaxWait(10000L); ds.setPoolPreparedStatements(true); ds.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES .toMillis(10L)); ds.setTestWhileIdle(true); jt = new JdbcTemplate(); jt.setMaxRows(50000); jt.setQueryTimeout(5000); jt.setDataSource(ds); DataSourceTransactionManager tm = new DataSourceTransactionManager(); tjt = new TransactionTemplate(tm); tm.setDataSource(ds); tjt.setTimeout(5000); if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) { reload(); } }
idleConnectionsCleanupTimeoutMs); bds.setAccessToUnderlyingConnectionAllowed(true); bds.setInitialSize(1); bds.setTimeBetweenEvictionRunsMillis(60000); if (catalog != null) {
@Override public synchronized void setInitialSize(int initialSize) { delegate.setInitialSize(initialSize); }
dbcpDataSource.setInitialSize(getIntProperty(config, "initialPoolSize", 5)); dbcpDataSource.setMaxActive(getIntProperty(config, "maxPoolSize", 30)); dbcpDataSource.setMinIdle(getIntProperty(config, "minPoolSize", 5));
@ManagedAttribute @Description("Set the initial number of connections that are created when the pool is started.") public void setInitialSize(final int size) { ds.setInitialSize(size); }
BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUsername(username); ds.setPassword(password); ds.setUrl(jdbcUrl); ds.setInitialSize(4);
BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(DATABASE_DRIVER_CLASS); ds.setUsername(DATABASE_USERNAME); ds.setPassword(DATABASE_PASSWORD); ds.setUrl(DATABASE_URL); ds.setInitialSize(1); ds.setMaxActive(50); ds.setDefaultAutoCommit(false);
BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBCDriver); ds.setUrl(JDBCUrl); ds.setUsername(JDBCUser); ds.setPassword(JDBCPassword); ds.setInitialSize(initSize); ds.setTestOnBorrow(false); ds.setTestWhileIdle(true);
BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(DATABASE_DRIVER_CLASS); ds.setUsername(DATABASE_USERNAME); ds.setPassword(DATABASE_PASSWORD); ds.setUrl(DATABASE_URL); ds.setInitialSize(1); ds.setMaxActive(50); ds.setDefaultAutoCommit(false);
public class PGService { private final Sql2o connectionPool; public PGService() throws ConfigurationException, IOException { Config cfg = loadConfig("dbconfig.json"); if (cfg == null) { throw new ConfigurationException("Could not load dbconfig."); } BasicDataSource bds = new BasicDataSource(); bds.setUsername(cfg.getUsername()); bds.setPassword(cfg.getPassword()); bds.setDriverClassName("org.postgresql.Driver"); bds.setUrl(cfg.getUrl()); bds.setInitialSize(1); connectionPool = new Sql2o(bds); } public Connection getConnection() { return this.connectionPool.open(); } }
BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("username"); dataSource.setPassword("password"); dataSource.setUrl("jdbc:mysql://<host>:<port>/<database>"); dataSource.setMaxActive(50); dataSource.setMaxIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1");
BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBCDriver); ds.setUrl(JDBCUrl); ds.setUsername(JDBCUser); ds.setPassword(JDBCPassword); ds.setInitialSize(initSize); ds.setMaxTotal(maxTotal);//negative for no limit ds.setTestOnBorrow(false); ds.setTestWhileIdle(true); Connection con = ds.getConnection();
@Bean(destroyMethod = "close", name = "dataSource") public DataSource dataSource(DataSourceProperties properties) { log.info("*************************dataSource***********************"); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(properties.driverClassName); dataSource.setUrl(properties.url); dataSource.setUsername(properties.username); dataSource.setPassword(properties.password); dataSource.setMaxIdle(properties.maxIdle); dataSource.setMaxActive(properties.maxActive); dataSource.setMaxWait(properties.maxWait); dataSource.setInitialSize(properties.initialSize); dataSource.setValidationQuery(properties.validationQuery); dataSource.setRemoveAbandoned(true); dataSource.setTestWhileIdle(true); dataSource.setTimeBetweenEvictionRunsMillis(30000); dataSource.setNumTestsPerEvictionRun(30); dataSource.setMinEvictableIdleTimeMillis(1800000); return dataSource; }
protected void setupDbcp() { org.apache.commons.dbcp.BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setUrl(jdbcUrl); ds.setUsername("brettw"); ds.setPassword(""); ds.setInitialSize(MIN_POOL_SIZE); ds.setMinIdle(MIN_POOL_SIZE); ds.setMaxIdle(maxPoolSize); ds.setMaxActive(maxPoolSize); ds.setDefaultAutoCommit(false); ds.setTestOnBorrow(true); ds.setValidationQuery("SELECT 1"); DS = ds; }
private void setupDataSource() { setDerbyPaths(); dataSource = new BasicDataSource(); dataSource.setDriverClassName(databaseConfiguration.getDriverClassName()); System.setProperty("hibernate.dialect", databaseConfiguration.getHibernateDialect()); dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); dataSource.setMaxActive(databaseConfiguration.getPoolMaxActive()); dataSource.setMinIdle(databaseConfiguration.getPoolMinIdle()); dataSource.setMaxIdle(databaseConfiguration.getPoolMaxIdle()); dataSource.setDefaultAutoCommit(true); dataSource.setInitialSize(databaseConfiguration.getPoolMinIdle()); //Derby blows up if the username of password is empty (even an empty string thats not null). if (databaseConfiguration.getUsername()!=null && databaseConfiguration.getUsername().length()>=1) dataSource.setUsername(databaseConfiguration.getUsername()); if (databaseConfiguration.getPassword()!=null && databaseConfiguration.getPassword().length()>=1) dataSource.setPassword(databaseConfiguration.getPassword()); dataSource.setUrl(databaseConfiguration.getJDBCUri()); }
import org.apache.commons.dbcp.BasicDataSource; static BasicDataSource bds = new BasicDataSource(); @BeforeClass public void setUp() throws Exception { bds.setDefaultAutoCommit(false); bds.setDriverClassName("org.h2.Driver"); bds.setInitialSize(0); bds.setMaxActive(2); bds.setMaxWait(10000); bds.setPassword(null); bds.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); bds.setUsername("sa"); bds.setValidationQuery("select 1 as test"); } @AfterClass public void tearDown() throws Exception { bds.close(); }
private static DataSource setupDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(getDriver()); ds.setUsername(getUser()); ds.setPassword(getPassword()); ds.setUrl(getConnectionString()); ds.setDefaultAutoCommit(false); ds.setInitialSize(4); ds.setMaxActive(60); ds.setMaxIdle(10); ds.setValidationQuery("/* ping */ SELECT 1");//config to validate against mysql ds.setValidationQueryTimeout(3); ds.setTestOnBorrow(true); ds.setTestOnReturn(true); return ds; }