本文整理汇总了Java中com.mchange.v2.c3p0.ComboPooledDataSource.setMaxStatements方法的典型用法代码示例。如果您正苦于以下问题:Java ComboPooledDataSource.setMaxStatements方法的具体用法?Java ComboPooledDataSource.setMaxStatements怎么用?Java ComboPooledDataSource.setMaxStatements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mchange.v2.c3p0.ComboPooledDataSource
的用法示例。
在下文中一共展示了ComboPooledDataSource.setMaxStatements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
* Method load properties and get connection pool to database.
* Use c3p0 library.
*/
public void connect() {
pool = new ComboPooledDataSource();
try {
pool.setDriverClass(dbPROP.getProperty("driver"));
} catch (PropertyVetoException ex) {
ex.printStackTrace();
}
pool.setJdbcUrl(dbPROP.getProperty("url"));
pool.setUser(dbPROP.getProperty("username"));
pool.setPassword(dbPROP.getProperty("password"));
pool.setMinPoolSize(2);
pool.setAcquireIncrement(1);
pool.setMaxPoolSize(5);
pool.setMaxStatements(50);
pool.setMaxStatementsPerConnection(10);
}
示例2: registerC3P0DataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Test
public void registerC3P0DataSource() throws Exception {
MetricCollector metricCollector = MonitoringCenter.getMetricCollector(MonitoringCenterTest.class);
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass("com.mysql.jdbc.Driver");
cpds.setMinPoolSize(2);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);
cpds.setMaxStatements(180);
cpds.setBreakAfterAcquireFailure(true);
metricCollector.registerC3P0DataSource(cpds, "testDB");
C3P0PooledDataSourceMetricSet c3P0PooledDataSourceMetricSet = new C3P0PooledDataSourceMetricSet(cpds);
String[] startsWithFilters = {"MonitoringCenterTest."};
Assert.assertEquals(c3P0PooledDataSourceMetricSet.getMetrics().size(), MonitoringCenter.getMetricsByNames(false, startsWithFilters).size());
}
示例3: getSpecificDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@ConfigurationProperties(prefix="system.datasource")
private DataSource getSpecificDataSource(String dbname) {
try {
System.out.println("CONNECTING TO DB ---------------> " + dbname.replaceAll("discoursedb_ext", ""));
ComboPooledDataSource ds = new ComboPooledDataSource();
ds.setDriverClass(environment.getRequiredProperty("jdbc.driverClassName"));
String host = environment.getRequiredProperty("jdbc.host");
String port = environment.getRequiredProperty("jdbc.port");
String database = "discoursedb_ext_" + dbname.replaceAll("discoursedb_ext_", "");
ds.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/" + database+ "?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&useSSL=false");
ds.setUser(environment.getRequiredProperty("jdbc.username"));
ds.setPassword(environment.getRequiredProperty("jdbc.password"));
ds.setAcquireIncrement(Integer.parseInt(environment.getRequiredProperty("c3p0.acquireIncrement").trim()));
ds.setIdleConnectionTestPeriod(
Integer.parseInt(environment.getRequiredProperty("c3p0.idleConnectionTestPeriod").trim()));
ds.setMaxStatements(Integer.parseInt(environment.getRequiredProperty("c3p0.maxStatements").trim()));
ds.setMinPoolSize(Integer.parseInt(environment.getRequiredProperty("c3p0.minPoolSize").trim()));
ds.setMaxPoolSize(Integer.parseInt(environment.getRequiredProperty("c3p0.maxPoolSize").trim()));
return ds;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: systemDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Bean(name = "systemDataSource")
@ConfigurationProperties(prefix="system.datasource")
public DataSource systemDataSource() {
try {
ComboPooledDataSource ds = new ComboPooledDataSource();
ds.setDriverClass(environment.getRequiredProperty("jdbc.driverClassName"));
String host = environment.getRequiredProperty("jdbc.host");
String port = environment.getRequiredProperty("jdbc.port");
String database = environment.getRequiredProperty("jdbc.system_database").replaceAll("discoursedb_ext_", "");
ds.setJdbcUrl("jdbc:mysql://" + host + ":" + port + "/discoursedb_ext_" + database+ "?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&useSSL=false");
ds.setUser(environment.getRequiredProperty("jdbc.username"));
ds.setPassword(environment.getRequiredProperty("jdbc.password"));
ds.setAcquireIncrement(Integer.parseInt(environment.getRequiredProperty("c3p0.acquireIncrement").trim()));
ds.setIdleConnectionTestPeriod(
Integer.parseInt(environment.getRequiredProperty("c3p0.idleConnectionTestPeriod").trim()));
ds.setMaxStatements(Integer.parseInt(environment.getRequiredProperty("c3p0.maxStatements").trim()));
ds.setMinPoolSize(Integer.parseInt(environment.getRequiredProperty("c3p0.minPoolSize").trim()));
ds.setMaxPoolSize(Integer.parseInt(environment.getRequiredProperty("c3p0.maxPoolSize").trim()));
return ds;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例5: 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;
}
示例6: 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;
}
示例7: createNewDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private ComboPooledDataSource createNewDataSource() throws Exception {
ComboPooledDataSource c3p0DataSource = new ComboPooledDataSource();
c3p0DataSource.setDriverClass(config.getDriverClassName()); //loads the jdbc driver
c3p0DataSource.setJdbcUrl(config.getJdbcUrl());
c3p0DataSource.setUser(config.getUserName());
c3p0DataSource.setPassword(config.getPassword());
// the settings below are optional -- c3p0 can work with defaults
c3p0DataSource.setMinPoolSize(config.getMinPoolSize());
c3p0DataSource.setMaxPoolSize(config.getMaxPoolSize());
c3p0DataSource.setAcquireIncrement(config.getAcquireIncrement());
c3p0DataSource.setMaxStatements(config.getMaxStatements());
c3p0DataSource.setIdleConnectionTestPeriod(config.getIdleTestPeriod());
c3p0DataSource.setMaxIdleTime(config.getMaxIdleTime());
return c3p0DataSource;
}
示例8: datasource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Bean(name = "NextRTCDataSource", destroyMethod = "close")
public ComboPooledDataSource datasource() throws PropertyVetoException {
ComboPooledDataSource ds = new ComboPooledDataSource();
ds.setMinPoolSize(1);
ds.setMaxPoolSize(10);
ds.setCheckoutTimeout(30 * 60 * 100);
ds.setMaxIdleTime(30 * 60); // 30 minutes
ds.setMaxStatements(10);
ds.setMaxStatementsPerConnection(10);
ds.setAutoCommitOnClose(true);
ds.setDriverClass(environment.getRequiredProperty("nextrtc.db.driverClassName"));
ds.setJdbcUrl(environment.getRequiredProperty("nextrtc.db.url"));
ds.setUser(environment.getRequiredProperty("nextrtc.db.username"));
ds.setPassword(environment.getRequiredProperty("nextrtc.db.password"));
return ds;
}
示例9: configDataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public static DataSource configDataSource(RepDatabase cfg)
throws PropertyVetoException {
ComboPooledDataSource ds = new ComboPooledDataSource();
ds.setDriverClass(cfg.getDriverclass().trim());
// loads the jdbc driver
ds.setJdbcUrl(cfg.getUrl().trim());
ds.setUser(cfg.getUsername().trim());
ds.setPassword(cfg.getPassword().trim());
ds.setMaxStatements(20);//
ds.setMaxIdleTime(cfg.getMaxidletime());// 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃
ds.setMaxPoolSize(cfg.getMaxpoolsize());// 池最大连接数
ds.setMinPoolSize(cfg.getMinpoolsize());// 池最小连接数
// 检查有效性
if(StringHelper.isNotEmpty(cfg.getTestquerysql())&&cfg.getTestoeriod()!=null){
ds.setPreferredTestQuery(cfg.getTestquerysql());
ds.setIdleConnectionTestPeriod(cfg.getTestoeriod());// 每隔10分钟检查一次空闲连接的有效性
}
//获取连接超时
ds.setCheckoutTimeout(10000);
return ds;
}
示例10: 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);
}
}
示例11: C3P0DataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private C3P0DataSource() throws IOException, SQLException,
PropertyVetoException {
cpds = new ComboPooledDataSource();
cpds.setDriverClass("org.h2.Driver"); // loads the jdbc driver
cpds.setJdbcUrl("jdbc:h2:./target/test;AUTO_SERVER=TRUE");
cpds.setUser("sa");
cpds.setPassword("");
// the settings below are optional -- c3p0 can work with defaults
cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);
cpds.setMaxStatements(180);
this.setDataSource(cpds);
}
示例12: 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);
}
示例13: 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);
}
示例14: Initialize
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
* Initializes the pool.
*DriverClass - The JDBC driver class.
*JdbcUrl - JDBC connection url.
*User / Password - Connection credentials.
*/
public void Initialize(String DriverClass, String JdbcUrl, String User, String Password) throws PropertyVetoException {
final ComboPooledDataSource pool = new ComboPooledDataSource();
setObject(pool);
pool.setDriverClass(DriverClass);
pool.setJdbcUrl(JdbcUrl);
pool.setUser(User);
pool.setPassword(Password);
pool.setMaxStatements(150);
pool.setMaxIdleTime(1800);
pool.setIdleConnectionTestPeriod(600);
pool.setCheckoutTimeout(20000);
pool.setTestConnectionOnCheckout(true);
}
示例15: 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);
}