本文整理汇总了Java中org.apache.commons.dbcp2.BasicDataSource.setMaxTotal方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.setMaxTotal方法的具体用法?Java BasicDataSource.setMaxTotal怎么用?Java BasicDataSource.setMaxTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.dbcp2.BasicDataSource
的用法示例。
在下文中一共展示了BasicDataSource.setMaxTotal方法的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: AbstractMysqlHandler
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public AbstractMysqlHandler() throws Exception{
shardCount = Integer.parseInt(System.getProperty(PROP_SHARD_CNT));
for(int i=0; i<shardCount; i++){
final BasicDataSource ds = new BasicDataSource();
ds.setMaxTotal(1024);
ds.setMaxIdle(1024);
ds.setMinIdle(0);
ds.setUrl(System.getProperty(String.format(PROP_SHARD_URL, i)));
ds.setUsername(System.getProperty(String.format(PROP_SHARD_USERNAME, i)));
ds.setPassword(System.getProperty(String.format(PROP_SHARD_PASSWORD, i)));
dataSourceList.add(ds);
}
// final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
// scriptEngine = scriptEngineManager.getEngineByName(SCRIPT_ENGINE_NAME);
// scriptEngine.eval(System.getProperty(PROP_SCRIPT));
}
示例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: initialize
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static void initialize(String driverName, String driverUrl, String userName, String password) throws SQLException {
dataSource = new BasicDataSource();
dataSource.setDriverClassName(driverName);
dataSource.setUsername(userName);
dataSource.setPassword(password);
dataSource.setUrl(driverUrl);
dataSource.setDefaultReadOnly(false);
dataSource.setDefaultAutoCommit(false);
// enable detection and logging of connection leaks
dataSource.setRemoveAbandonedOnBorrow(true);
dataSource.setRemoveAbandonedOnMaintenance(true);
dataSource.setRemoveAbandonedTimeout(3600); // 1 hour
dataSource.setLogAbandoned(true);
dataSource.setMaxWaitMillis(60000);
dataSource.setMaxTotal(20);
INITDATE = new Date();
}
示例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: getPooledDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static BasicDataSource getPooledDataSource(String connectUrl,
int maxTotal,
int maxWaitTimeMillis) {
BasicDataSource bds = new BasicDataSource();
bds.setUrl(connectUrl);
bds.setMaxTotal(maxTotal);
bds.setMaxWaitMillis(maxWaitTimeMillis);
return bds;
}
示例11: 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;
}
示例12: sqlSessionFactory
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public SqlSessionFactory sqlSessionFactory(String configXml) {
GlobalConfiguration global = this.globalConfiguration();
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/mybatis-plus?characterEncoding=UTF-8");
dataSource.setUsername("root");
dataSource.setPassword("521");
dataSource.setMaxTotal(1000);
GlobalConfigUtils.setMetaData(dataSource, global);
// 加载配置文件
InputStream inputStream = CrudTest.class.getClassLoader().getResourceAsStream(configXml);
MybatisSessionFactoryBuilder factoryBuilder = new MybatisSessionFactoryBuilder();
factoryBuilder.setGlobalConfig(global);
return factoryBuilder.build(inputStream);
}
示例13: createDataSourceMetadata
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private CommonsDbcp2DataSourcePoolMetadata createDataSourceMetadata(int minSize,
int maxSize) {
BasicDataSource dataSource = createDataSource();
dataSource.setMinIdle(minSize);
dataSource.setMaxTotal(maxSize);
return new CommonsDbcp2DataSourcePoolMetadata(dataSource);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:CommonsDbcp2DataSourcePoolMetadataTests.java
示例14: TestDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public TestDataSource(String connUrl, String user, String password) {
dataSource = new BasicDataSource();
dataSource.setUrl(connUrl);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setMaxTotal(20);
}
示例15: setupDataSourcePool
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
protected BasicDataSource setupDataSourcePool( DataSourceConfiguration config )
throws Exception
{
BasicDataSource pool = new BasicDataSource();
Class.forName( config.driver().get() );
pool.setDriverClassName( config.driver().get() );
pool.setUrl( config.url().get() );
if ( !config.username().get().equals( "" ) ) {
pool.setUsername( config.username().get() );
pool.setPassword( config.password().get() );
}
if ( config.minPoolSize().get() != null ) {
pool.setMinIdle( config.minPoolSize().get() );
}
if ( config.maxPoolSize().get() != null ) {
pool.setMaxTotal( config.maxPoolSize().get() );
}
if ( config.loginTimeoutSeconds().get() != null ) {
pool.setLoginTimeout( config.loginTimeoutSeconds().get() );
}
if ( config.maxConnectionAgeSeconds().get() != null ) {
pool.setMinEvictableIdleTimeMillis( config.maxConnectionAgeSeconds().get() * 1000 );
}
if ( config.validationQuery().get() != null ) {
pool.setValidationQuery( config.validationQuery().get() );
}
return pool;
}