本文整理汇总了Java中org.apache.commons.dbcp2.BasicDataSource.setInitialSize方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.setInitialSize方法的具体用法?Java BasicDataSource.setInitialSize怎么用?Java BasicDataSource.setInitialSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.dbcp2.BasicDataSource
的用法示例。
在下文中一共展示了BasicDataSource.setInitialSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBasicDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static BasicDataSource getBasicDataSource(DatasourceConfiguration configuration) {
BasicDataSource dbcpDataSource = new BasicDataSource();
dbcpDataSource.setDriverClassName(configuration.getDriverClassname());
dbcpDataSource.setUrl(configuration.getUrl());
dbcpDataSource.setUsername(configuration.getUser());
dbcpDataSource.setPassword(configuration.getPassword());
// Enable statement caching (Optional)
dbcpDataSource.setPoolPreparedStatements(true);
dbcpDataSource.setValidationQuery("Select 1 ");
dbcpDataSource.setMaxOpenPreparedStatements(50);
dbcpDataSource.setLifo(true);
dbcpDataSource.setMaxTotal(10);
dbcpDataSource.setInitialSize(2);
return dbcpDataSource;
}
示例2: invokeGetDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public DataSource invokeGetDataSource() {
BasicDataSource bds = new BasicDataSource();
bds.setDriverClassName("com.mysql.jdbc.Driver");
bds.setUrl("jdbc:mysql://127.0.0.1:3306/inst02");
bds.setUsername("root");
bds.setPassword("123456");
bds.setMaxTotal(50);
bds.setInitialSize(20);
bds.setMaxWaitMillis(60000);
bds.setMinIdle(6);
bds.setLogAbandoned(true);
bds.setRemoveAbandonedOnBorrow(true);
bds.setRemoveAbandonedOnMaintenance(true);
bds.setRemoveAbandonedTimeout(1800);
bds.setTestWhileIdle(true);
bds.setTestOnBorrow(false);
bds.setTestOnReturn(false);
bds.setValidationQuery("select 'x' ");
bds.setValidationQueryTimeout(1);
bds.setTimeBetweenEvictionRunsMillis(30000);
bds.setNumTestsPerEvictionRun(20);
return bds;
}
示例3: invokeGetDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public DataSource invokeGetDataSource() {
BasicDataSource bds = new BasicDataSource();
bds.setDriverClassName("com.mysql.jdbc.Driver");
bds.setUrl("jdbc:mysql://127.0.0.1:3306/inst01");
bds.setUsername("root");
bds.setPassword("123456");
bds.setMaxTotal(50);
bds.setInitialSize(20);
bds.setMaxWaitMillis(60000);
bds.setMinIdle(6);
bds.setLogAbandoned(true);
bds.setRemoveAbandonedOnBorrow(true);
bds.setRemoveAbandonedOnMaintenance(true);
bds.setRemoveAbandonedTimeout(1800);
bds.setTestWhileIdle(true);
bds.setTestOnBorrow(false);
bds.setTestOnReturn(false);
bds.setValidationQuery("select 'x' ");
bds.setValidationQueryTimeout(1);
bds.setTimeBetweenEvictionRunsMillis(30000);
bds.setNumTestsPerEvictionRun(20);
return bds;
}
示例4: dbcp
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@SneakyThrows
private static CloseableDatasource dbcp(Config config) {
int threads = config.getInt("threads");
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(config.getString("driver"));
dataSource.setUrl(config.getString("url"));
dataSource.setUsername(config.getString("user"));
dataSource.setPassword(config.getString("pwd"));
dataSource.setInitialSize(threads);
dataSource.setMinEvictableIdleTimeMillis(120 * 1000);//seconds
DBCPCloseableDataSource ds = new DBCPCloseableDataSource(dataSource);
return ds;
}
示例5: newDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static BasicDataSource newDataSource(String id, String driver, String db, String user, String pswd, int initial, int max)
{
LOG.info("Initializing a fresh pool for Id=" + id + ", DB=" + db + ", User=" + user + ", and Pswd=Shhhhhhh!");
BasicDataSource BDS = new BasicDataSource();
BDS.setDriverClassName(driver);
BDS.setUrl(db);
if (TextUtil.isNullOrEmpty(pswd) == false && TextUtil.isNullOrEmpty(user) == false)
{
BDS.setUsername(user);
BDS.setPassword(pswd);
}
BDS.setInitialSize(initial);
BDS.setMaxTotal(max);
BDS.setDefaultAutoCommit(false);
BDS.setDefaultTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED);
BDS.setDefaultQueryTimeout(20000);
return BDS;
}
示例6: init
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@PostConstruct
/**
* Creates security data-source to be used with the sample DB
*/
public void init() {
securityDataSource = new BasicDataSource();
securityDataSource.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
securityDataSource.setUrl("jdbc:mysql://localhost:3306/java_one_2014");
securityDataSource.setUsername("java_one");
securityDataSource.setPassword("");
securityDataSource.setInitialSize(5);
securityDataSource.setMaxTotal(30);
securityDataSource.setMaxIdle(15);
securityDataSource.setMaxWaitMillis(3000);
securityDataSource.setLogAbandoned(true);
securityDataSource.setTestWhileIdle(true);
securityDataSource.setTestOnBorrow(true);
securityDataSource.setValidationQuery("select 1");
}
示例7: wrap
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
public DataSource wrap(final ReportDataSource rptDs) {
try {
final BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(rptDs.getDriverClass());
dataSource.setUrl(rptDs.getJdbcUrl());
dataSource.setUsername(rptDs.getUser());
dataSource.setPassword(rptDs.getPassword());
dataSource.setInitialSize(MapUtils.getInteger(rptDs.getOptions(), "initialSize", 3));
dataSource.setMaxIdle(MapUtils.getInteger(rptDs.getOptions(), "maxIdle", 20));
dataSource.setMinIdle(MapUtils.getInteger(rptDs.getOptions(), "minIdle", 1));
dataSource.setLogAbandoned(MapUtils.getBoolean(rptDs.getOptions(), "logAbandoned", true));
dataSource.setRemoveAbandonedTimeout(
MapUtils.getInteger(rptDs.getOptions(), "removeAbandonedTimeout", 180));
dataSource.setMaxWaitMillis(MapUtils.getInteger(rptDs.getOptions(), "maxWait", 1000));
return dataSource;
} catch (final Exception ex) {
throw new RuntimeException("C3p0DataSourcePool Create Error", ex);
}
}
示例8: get
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
public DataSource get() throws PropertyVetoException {
BasicDataSource ds = new org.apache.commons.dbcp2.BasicDataSource();
ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
ds.setUsername("tully");
ds.setPassword("tully");
ds.setUrl("jdbc:mysql://localhost:3306/db_example");
ds.setInitialSize(10);
ds.setMaxTotal(20);
return ds;
}
示例9: getDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean(name = "dataSource")
public DataSource getDataSource(){
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&aut");
dataSource.setUsername("root");
dataSource.setPassword("");
dataSource.setInitialSize(3);
dataSource.setMinIdle(3);
dataSource.setMaxIdle(5);
dataSource.setMaxTotal(10);
return dataSource;
}
示例10: initializeConnectionPool
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private void initializeConnectionPool(BasicDataSource connectionPool, URI databaseUri) {
final String dbUrl = "jdbc:postgresql://" + databaseUri.getHost() + databaseUri.getPath();
if (databaseUri.getUserInfo() != null) {
connectionPool.setUsername(databaseUri.getUserInfo().split(":")[0]);
connectionPool.setPassword(databaseUri.getUserInfo().split(":")[1]);
}
connectionPool.setDriverClassName("org.postgresql.Driver");
connectionPool.setUrl(dbUrl);
connectionPool.setInitialSize(1);
}
示例11: initConnectionPool
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private void initConnectionPool() {
connectionPool = new BasicDataSource();
connectionPool.setUsername(username);
connectionPool.setPassword(password);
connectionPool.setDriverClassName("org.postgresql.Driver");
connectionPool.setUrl(url);
connectionPool.setInitialSize(5);
}
示例12: getDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
protected BasicDataSource getDataSource(String jdbcDriver, String jdbcUrl, String username, String password) {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(jdbcDriver);
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setMaxIdle(5);
dataSource.setMinIdle(1);
dataSource.setMaxWaitMillis(5000);
dataSource.setMaxTotal(40);
dataSource.setInitialSize(10);
dataSource.setUrl(jdbcUrl);
return dataSource;
}
示例13: createDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static DataSource createDataSource(String host, int port, String name, String user, String password) {
BasicDataSource bds = new BasicDataSource();
bds.setDriverClassName("com.mysql.jdbc.Driver");
bds.setUrl(String.format("jdbc:mysql://%s:%d/%s", host, port, name));
bds.setUsername(user);
bds.setPassword(password);
bds.setInitialSize(5);
return bds;
}
示例14: buildDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private DataSource buildDataSource() {
BasicDataSource connectionPool = new BasicDataSource();
connectionPool.setDriverClassName(env.getProperty("auth.providers.jdbc.driver"));
connectionPool.setUsername(env.getProperty("auth.providers.jdbc.username"));
connectionPool.setPassword(env.getProperty("auth.providers.jdbc.password"));
connectionPool.setUrl(env.getProperty("auth.providers.jdbc.url"));
connectionPool.setInitialSize(1);
return connectionPool;
}
示例15: buildDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static DataSource buildDataSource() {
BasicDataSource connectionPool = new BasicDataSource();
connectionPool.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
connectionPool.setUsername("sa");
connectionPool.setPassword("");
connectionPool.setUrl("jdbc:hsqldb:mem:testdb");
connectionPool.setInitialSize(1);
return connectionPool;
}