本文整理汇总了Java中com.mchange.v2.c3p0.ComboPooledDataSource.setInitialPoolSize方法的典型用法代码示例。如果您正苦于以下问题:Java ComboPooledDataSource.setInitialPoolSize方法的具体用法?Java ComboPooledDataSource.setInitialPoolSize怎么用?Java ComboPooledDataSource.setInitialPoolSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mchange.v2.c3p0.ComboPooledDataSource
的用法示例。
在下文中一共展示了ComboPooledDataSource.setInitialPoolSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pooled
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private static PooledDataSource pooled(String hostname, int port, String username, String password, String database, String driver, int maxPoolsize) {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl(format("jdbc:mysql://%s:%d/%s?rewriteBatchedStatements=true",
hostname,
port,
database));
dataSource.setUser(username);
dataSource.setPassword(password);
dataSource.setIdleConnectionTestPeriod(60 * 5);
dataSource.setMinPoolSize(3);
dataSource.setInitialPoolSize(3);
dataSource.setAcquireIncrement(1);
dataSource.setMaxPoolSize(maxPoolsize);
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
return dataSource;
}
示例2: defualtDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Bean
public DataSource defualtDataSource() {
ComboPooledDataSource defualtDatasource = new ComboPooledDataSource();
try {
defualtDatasource.setJdbcUrl(environment.getProperty("db.url"));
defualtDatasource.setUser(environment.getProperty("db.user"));
defualtDatasource.setPassword(environment.getProperty("db.pass"));
defualtDatasource.setDriverClass(environment.getProperty("db.driver"));
defualtDatasource.setInitialPoolSize(Integer.valueOf("1"));
defualtDatasource.setMaxPoolSize(Integer.parseInt("5"));
defualtDatasource.setMinPoolSize(Integer.parseInt("5"));
defualtDatasource.setMaxConnectionAge(Integer.parseInt("100"));
} catch (PropertyVetoException e) {
e.printStackTrace();
}
return defualtDatasource;
}
示例3: defualtDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Bean
public DataSource defualtDataSource() {
ComboPooledDataSource defualtDatasource = new ComboPooledDataSource();
defualtDatasource.setJdbcUrl(properties.getUrl());
defualtDatasource.setUser(properties.getUsername());
defualtDatasource.setPassword(properties.getPassword());
try {
defualtDatasource.setDriverClass(properties.getDriver());
} catch (PropertyVetoException e) {
e.printStackTrace();
}
defualtDatasource.setInitialPoolSize(Integer.valueOf(defultPoolProp.getInitialPoolSize()));
defualtDatasource.setMaxPoolSize(Integer.parseInt(defultPoolProp.getMaxPoolSize()));
defualtDatasource.setMinPoolSize(Integer.parseInt(defultPoolProp.getMinPoolSize()));
defualtDatasource.setMaxConnectionAge(Integer.parseInt(defultPoolProp.getPoolMaxConnectionAge()));
return defualtDatasource;
}
示例4: initialize
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public static boolean initialize(String url, String user, String password, int minPoolSize, int maxPoolSize,
int poolIncrement) {
try {
cpds = new ComboPooledDataSource();
cpds.setDriverClass("com.mysql.cj.jdbc.Driver");
cpds.setJdbcUrl(url);
cpds.setUser(user);
cpds.setPassword(password);
cpds.setInitialPoolSize(minPoolSize);
cpds.setMinPoolSize(minPoolSize);
cpds.setAcquireIncrement(poolIncrement);
cpds.setMaxPoolSize(maxPoolSize);
cpds.setNumHelperThreads(Nomad.DB_WORKERS);
cpds.setTestConnectionOnCheckout(true);
} catch (Exception e) {
logger.error("Failed to initialize DB.", e);
return false;
}
logger.debug("Initialized DB.");
return true;
}
示例5: start
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public boolean start() {
if (isStarted)
return true;
dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setUser(user);
dataSource.setPassword(password);
try {
dataSource.setDriverClass(driverClass);
} catch (PropertyVetoException e) {
dataSource = null;
logger.error("C3p0Plugin start error");
throw new RuntimeException(e);
}
dataSource.setMaxPoolSize(maxPoolSize);
dataSource.setMinPoolSize(minPoolSize);
dataSource.setInitialPoolSize(initialPoolSize);
dataSource.setMaxIdleTime(maxIdleTime);
dataSource.setAcquireIncrement(acquireIncrement);
isStarted = true;
return true;
}
示例6: h2DataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
* @return the h2 database data source
*/
@Bean
public DataSource h2DataSource() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass("org.h2.Driver");
} catch (PropertyVetoException e) {
e.printStackTrace();
}
dataSource.setJdbcUrl("jdbc:h2:mem:bootstrap;mode=mysql;INIT=runscript from 'classpath:sql/bootstrap.h2.sql'\\;" +
"runscript from 'classpath:sql/bootstrap.insert.sql'");
dataSource.setUser("sa");
dataSource.setPassword("");
dataSource.setAcquireIncrement(10);
dataSource.setIdleConnectionTestPeriod(60);
dataSource.setMaxPoolSize(30);
dataSource.setMinPoolSize(3);
dataSource.setInitialPoolSize(5);
dataSource.setMaxStatements(10);
return dataSource;
}
示例7: mysqlDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
* @return the mysql data source
*/
@Bean
public DataSource mysqlDataSource() {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass("com.mysql.jdbc.Driver");
} catch (PropertyVetoException e) {
return null;
}
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/bootstrap");
dataSource.setUser("bootstrap");
dataSource.setPassword("bootstrap");
dataSource.setAcquireIncrement(50);
dataSource.setIdleConnectionTestPeriod(60);
dataSource.setMaxPoolSize(50);
dataSource.setMinPoolSize(10);
dataSource.setInitialPoolSize(20);
dataSource.setMaxStatements(50);
return dataSource;
}
示例8: createConnection
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private ComboPooledDataSource createConnection() {
try {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass("com.mysql.jdbc.Driver");
cpds.setJdbcUrl("jdbc:mysql://" + MYSQL_DATA.HOST + ":" + MYSQL_DATA.PORT + "/" + MYSQL_DATA.DATABASE);
cpds.setProperties(connectionProperties);
cpds.setInitialPoolSize(POOL_DATA.INITIAL_POOL_SIZE);
cpds.setMinPoolSize(POOL_DATA.MIN_POOL_SIZE);
cpds.setMaxPoolSize(POOL_DATA.MAX_POOL_SIZE);
cpds.setTestConnectionOnCheckin(POOL_DATA.TEST_CONNECTION_ON_CHECKIN);
cpds.setIdleConnectionTestPeriod(POOL_DATA.IDLE_CONNECTION_TEST_PERIOD);
return cpds;
} catch (PropertyVetoException e) {
e.printStackTrace();
}
return null;
}
示例9: wrap
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
public DataSource wrap(ReportDataSource rptDs) {
try {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass(rptDs.getDriverClass());
dataSource.setJdbcUrl(rptDs.getJdbcUrl());
dataSource.setUser(rptDs.getUser());
dataSource.setPassword(rptDs.getPassword());
dataSource.setInitialPoolSize(MapUtils.getInteger(rptDs.getOptions(), "initialPoolSize", 3));
dataSource.setMinPoolSize(MapUtils.getInteger(rptDs.getOptions(), "minPoolSize", 1));
dataSource.setMaxPoolSize(MapUtils.getInteger(rptDs.getOptions(), "maxPoolSize", 20));
dataSource.setMaxStatements(MapUtils.getInteger(rptDs.getOptions(), "maxStatements", 50));
dataSource.setMaxIdleTime(MapUtils.getInteger(rptDs.getOptions(), "maxIdleTime", 1800));
dataSource.setAcquireIncrement(MapUtils.getInteger(rptDs.getOptions(), "acquireIncrement", 3));
dataSource.setAcquireRetryAttempts(MapUtils.getInteger(rptDs.getOptions(), "acquireRetryAttempts", 30));
dataSource.setIdleConnectionTestPeriod(
MapUtils.getInteger(rptDs.getOptions(), "idleConnectionTestPeriod", 60));
dataSource.setBreakAfterAcquireFailure(
MapUtils.getBoolean(rptDs.getOptions(), "breakAfterAcquireFailure", false));
dataSource.setTestConnectionOnCheckout(
MapUtils.getBoolean(rptDs.getOptions(), "testConnectionOnCheckout", false));
return dataSource;
} catch (Exception ex) {
throw new RuntimeException("C3p0DataSourcePool Create Error", ex);
}
}
示例10: get
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
public DataSource get() throws PropertyVetoException {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass( "com.mysql.cj.jdbc.Driver" );
cpds.setJdbcUrl( "jdbc:mysql://localhost:3306/db_example" );
cpds.setUser("tully");
cpds.setPassword("tully");
cpds.setInitialPoolSize(10);
cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(1);
cpds.setMaxPoolSize(20);
return cpds;
}
示例11: DAOFactory
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
protected DAOFactory(String driverClassName, String jdbcURL, String userName, String userPassword, int initPoolSize,
int MinPoolSize, int MaxPoolSize, int maxIdleTime, int idleConnectionTestPeriod, String testQuerySQL) {
ds = new ComboPooledDataSource();
// 设置JDBC的Driver类
try {
ds.setDriverClass(driverClassName);
}
catch (PropertyVetoException e) {
throw new RuntimeException(e);
}
// 设置JDBC的URL
ds.setJdbcUrl(jdbcURL);
// 设置数据库的登录用户名
ds.setUser(userName);
// 设置数据库的登录用户密码
ds.setPassword(userPassword);
// 设置连接池的最大连接数
ds.setMaxPoolSize(MaxPoolSize);
// 设置连接池的最小连接数
ds.setMinPoolSize(MinPoolSize);
// 设置初始化连接数
ds.setInitialPoolSize(initPoolSize);
// 设置最大闲置时间
ds.setMaxIdleTime(maxIdleTime);
// 设置测试SQL
ds.setPreferredTestQuery(testQuerySQL);
// 设置闲置测试周期
ds.setIdleConnectionTestPeriod(idleConnectionTestPeriod);
// 增加单个连接的Statements数量
ds.setMaxStatements(0);
ds.setMaxStatementsPerConnection(200);
}
示例12: DAOFactory
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
protected DAOFactory(String facName, String driverClassName, String jdbcURL, String userName, String userPassword,
int initPoolSize, int MinPoolSize, int MaxPoolSize, int maxIdleTime, int idleConnectionTestPeriod,
String testQuerySQL) {
this.facName = facName;
ds = new ComboPooledDataSource();
// 设置JDBC的Driver类
try {
ds.setDriverClass(driverClassName);
}
catch (PropertyVetoException e) {
throw new RuntimeException(e);
}
// 设置JDBC的URL
ds.setJdbcUrl(jdbcURL);
// 设置数据库的登录用户名
ds.setUser(userName);
// 设置数据库的登录用户密码
ds.setPassword(userPassword);
// 设置连接池的最大连接数
ds.setMaxPoolSize(MaxPoolSize);
// 设置连接池的最小连接数
ds.setMinPoolSize(MinPoolSize);
// 设置初始化连接数
ds.setInitialPoolSize(initPoolSize);
// 设置最大闲置时间
ds.setMaxIdleTime(maxIdleTime);
// 设置测试SQL
ds.setPreferredTestQuery(testQuerySQL);
// 设置闲置测试周期
ds.setIdleConnectionTestPeriod(idleConnectionTestPeriod);
// 增加单个连接的Statements数量
ds.setMaxStatements(0);
// 连接池内单个连接所拥有的最大缓存statements数
ds.setMaxStatementsPerConnection(200);
// 获取空闲连接超时时间
ds.setCheckoutTimeout(10 * 1000);
}
示例13: proccessDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private PooledDataSource proccessDataSource(String tenantIdentifier) {
System.out.println("connection is null, start process " + tenantIdentifier);
DataSourceWrapper sourceWrapper = DataSourceRegistery.getInstance().get(tenantIdentifier);
if (sourceWrapper == null) {
System.out.println("datasource is null for tenantid in map " + tenantIdentifier);
sourceWrapper = restTemplate.getForObject("http://localhost:8888/database-management/tenant/{tenantId}", DataSourceWrapper.class, tenantIdentifier);
System.out.println("get datasurce in database management " + tenantIdentifier);
sourceWrapper.setTenantId(tenantIdentifier);
DataSourceRegistery.getInstance().put(sourceWrapper.getTenantId(), sourceWrapper);
System.out.println("put datasource in map " + tenantIdentifier);
}
System.out.println("create connection for tenantId " + tenantIdentifier);
ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource(sourceWrapper.getTenantId());
comboPooledDataSource.setJdbcUrl(sourceWrapper.getUrl());
comboPooledDataSource.setUser(sourceWrapper.getUsername());
comboPooledDataSource.setPassword(sourceWrapper.getPassword());
comboPooledDataSource.setInitialPoolSize(sourceWrapper.getInitialPoolSize());
comboPooledDataSource.setMinPoolSize(sourceWrapper.getMinPoolSize());
comboPooledDataSource.setMaxPoolSize(sourceWrapper.getMaxPoolSize());
comboPooledDataSource.setMaxConnectionAge(sourceWrapper.getPoolMaxConnectionAge());
try {
comboPooledDataSource.setDriverClass(sourceWrapper.getDriver());
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("finish process for tenantId " + tenantIdentifier);
return comboPooledDataSource;
}
示例14: createDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public static ProxyDataSource createDataSource(String driverClass, String jdbcUrl, String user, String password, int maxPoolSize) {
if (StringUtils.isEmpty(driverClass)) {
// System.err.println("驱动程序没有设置.");
driverClass = "oracle.jdbc.driver.OracleDriver";
}
logger.info("createDataSource jdbcUrl:" + jdbcUrl);
// ComboPooledDataSource dataSource = new ComboPooledDataSource();
ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
// dataSource.setDriverClass("org.mariadb.jdbc.Driver");
// dataSource.setDriverClass("org.gjt.mm.mysql.Driver");
dataSource.setDriverClass(driverClass);
}
catch (PropertyVetoException e) {
throw new RuntimeException(e.getMessage(), e);
}
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setUser(user);
dataSource.setPassword(password);
dataSource.setTestConnectionOnCheckout(false);
dataSource.setInitialPoolSize(1);
dataSource.setMinPoolSize(1);
dataSource.setMaxPoolSize(maxPoolSize);
dataSource.setAcquireIncrement(1);
dataSource.setAcquireRetryAttempts(1);
dataSource.setMaxIdleTime(7200);
dataSource.setMaxStatements(0);
return new OracleProxyDataSource(dataSource);
}
示例15: start
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
* 使用指定配置文件初始化 C3P0。
*
* @param file
* 配置文件路径
*/
public void start(String file) {
if (isStarted) {
return;
}
if (file.equals("")) {
file = "dbconfig.properties";
}
init(file);
dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setUser(user);
dataSource.setPassword(password);
try {
dataSource.setDriverClass(driverClass);
} catch (PropertyVetoException e) {
dataSource = null;
throw new RuntimeException(e);
}
dataSource.setMaxPoolSize(maxPoolSize);
dataSource.setMinPoolSize(minPoolSize);
dataSource.setInitialPoolSize(initialPoolSize);
dataSource.setMaxIdleTime(maxIdleTime);
dataSource.setAcquireIncrement(acquireIncrement);
isStarted = true;
}