ds.setMaxIdle(Integer.parseInt(defaultIfNull(val, "50"))); ds.setMaxWait(3000L); ds.setPoolPreparedStatements(true);
ds.setMaxWait( Long.valueOf( value ) );
@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(); } }
dataSource.setMaxWait(maxWaitMillis); dataSource.setMaxActive(maxTotal);
dataSource.setMaxWait(maxWaitMillis); dataSource.setMaxActive(maxTotal);
@Override public synchronized void setMaxWait(long maxWait) { delegate.setMaxWait(maxWait); }
/** * Creates a data source by reading properties from a file called 'db.properties', located * paralell to the test setup instance. */ protected DataSource createDataSource() throws IOException { Properties db = fixture; BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(db.getProperty("driver")); dataSource.setUrl(db.getProperty("url")); if (db.containsKey("user")) { dataSource.setUsername(db.getProperty("user")); } else if (db.containsKey("username")) { dataSource.setUsername(db.getProperty("username")); } if (db.containsKey("password")) { dataSource.setPassword(db.getProperty("password")); } dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); initializeDataSource(dataSource, db); // return a closeable data source (DisposableDataSource interface) // so that the connection pool will be tore down on datastore dispose return new DBCPDataSource(dataSource); }
public void setMaxWait(final int maxWait) { final ReentrantLock l = lock; l.lock(); try { super.setMaxWait((long) maxWait); } finally { l.unlock(); } }
/** * Set the maxWait property. * <p/> * <p>Use -1 to make the pool wait indefinitely.</p> * * @param maxWait the new value for maxWait. * @see #getMaxWait() */ @Managed(description = "Set the maxWait property. Use -1 to make the pool wait indefinitely.") public synchronized void setMaxWait(long maxWait) { super.setMaxWait(maxWait); }
dbcpDataSource.setMinIdle(getIntProperty(config, "minPoolSize", 5)); dbcpDataSource.setMaxIdle(getIntProperty(config, "maxPoolSize", 20)); dbcpDataSource.setMaxWait(getIntProperty(config, "checkoutTimeout", 1000)); dbcpDataSource.setValidationQuery(getStringProperty(config, "preferredTestQuery", "SELECT 1")); dbcpDataSource.setMinEvictableIdleTimeMillis(getIntProperty(config, "minEvictableIdleTimeMillis", 1800000));// 30min
@ManagedAttribute @Description("Set the maximum number of milliseconds that the pool will wait (when there are no available connections) " + "for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.") public void setMaxWait(final long max) { ds.setMaxWait(max); }
dataSource.setMaxWait(maxWait * 1000);
/** * Prepares a simple data source for the embedded H2 * * @param cacheDirFinder * @return * @throws ConfigurationException */ private DataSource getH2DataSource(DefaultStorageFinder cacheDirFinder) throws ConfigurationException { File storeDirectory = new File(cacheDirFinder.getDefaultPath(), "diskquota_page_store_h2"); storeDirectory.mkdirs(); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); String database = new File(storeDirectory, "diskquota").getAbsolutePath(); dataSource.setUrl("jdbc:h2:" + database); dataSource.setUsername("sa"); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(-1); // boundless dataSource.setMaxWait(5000); return dataSource; }
private DataSource buildDataSource(DatabaseConfiguration config) { BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(config.getDbUrl().trim()); basicDataSource.setDriverClassName(config.getDriverName().trim()); basicDataSource.setUsername(config.getUserName().trim()); basicDataSource.setPassword(config.getPassword().trim()); basicDataSource.setMaxActive(config.getMaxActive()); basicDataSource.setMaxIdle(config.getMaxIdle()); basicDataSource.setMaxWait(config.getMaxWait()); basicDataSource.setMinIdle(config.getMinIdle()); basicDataSource.setValidationQuery(config.getValidationQuery()); return basicDataSource; }
@Primary @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; }
@Bean(destroyMethod = "close", name = "readOnlyDataSource") public DataSource dataSource(@Qualifier("readOnlyDataSourceProperties") DataSourceProperties readOnlyDataSourceProperties) { log.info("*************************dataSource***********************"); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(readOnlyDataSourceProperties.driverClassName); dataSource.setUrl(readOnlyDataSourceProperties.url); dataSource.setUsername(readOnlyDataSourceProperties.username); dataSource.setPassword(readOnlyDataSourceProperties.password); dataSource.setMaxIdle(readOnlyDataSourceProperties.maxIdle); dataSource.setMaxActive(readOnlyDataSourceProperties.maxActive); dataSource.setMaxWait(readOnlyDataSourceProperties.maxWait); dataSource.setInitialSize(readOnlyDataSourceProperties.initialSize); dataSource.setValidationQuery(readOnlyDataSourceProperties.validationQuery); dataSource.setRemoveAbandoned(true); dataSource.setTestWhileIdle(true); dataSource.setTimeBetweenEvictionRunsMillis(30000); dataSource.setNumTestsPerEvictionRun(30); dataSource.setMinEvictableIdleTimeMillis(1800000); return dataSource; }
public class DataTransaction { private final static BasicDataSource dataSource; static { dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/registrationtest"); dataSource.setUsername("root"); dataSource.setPassword("root"); dataSource.setMaxActive(100); dataSource.setMaxWait(10000); dataSource.setMaxIdle(10); } private DataTransaction() { } public static DataSource getDataSource() { return dataSource; } }
@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 BasicDataSource getDataSource() throws IOException, SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(fixtureRule.getFixture().getProperty("driver")); dataSource.setUrl(fixtureRule.getFixture().getProperty("url")); dataSource.setUsername(fixtureRule.getFixture().getProperty("username")); dataSource.setPassword(fixtureRule.getFixture().getProperty("password")); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); cleanupDatabase(dataSource); return dataSource; }
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(); }