本文整理匯總了Java中com.mchange.v2.c3p0.ComboPooledDataSource.setAcquireIncrement方法的典型用法代碼示例。如果您正苦於以下問題:Java ComboPooledDataSource.setAcquireIncrement方法的具體用法?Java ComboPooledDataSource.setAcquireIncrement怎麽用?Java ComboPooledDataSource.setAcquireIncrement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.mchange.v2.c3p0.ComboPooledDataSource
的用法示例。
在下文中一共展示了ComboPooledDataSource.setAcquireIncrement方法的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: 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);
}
示例3: createC3P0DataSource
import com.mchange.v2.c3p0.ComboPooledDataSource; //導入方法依賴的package包/類
private DataSource createC3P0DataSource() throws PropertyVetoException {
ComboPooledDataSource ds = new ComboPooledDataSource();
ds.setDriverClass(configuration.getDriverClassName());
ds.setJdbcUrl(configuration.getJdbcUrl());
ds.setUser(configuration.getJdbcUsername());
ds.setPassword(configuration.getJdbcPassword());
ds.setAcquireIncrement(3);
ds.setMinPoolSize(configuration.getMinPoolSize());
ds.setMaxPoolSize(configuration.getMaxPoolSize());
ds.setIdleConnectionTestPeriod(1800);
ds.setConnectionTesterClassName(MidPointConnectionTester.class.getName());
ds.setConnectionCustomizerClassName(MidPointConnectionCustomizer.class.getName());
return ds;
}
示例4: 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());
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: setUp
import com.mchange.v2.c3p0.ComboPooledDataSource; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
if (rdb == null) {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass("com.mysql.jdbc.Driver");
dataSource.setJdbcUrl("jdbc:mysql://localhost/test_rdb");
dataSource.setUser("test_rdb");
dataSource.setPassword("test_rdb");
dataSource.setMinPoolSize(2);
dataSource.setAcquireIncrement(2);
dataSource.setMaxPoolSize(32);
JdbcDataSourceManager dataSourceManager = new JdbcDataSourceManager(dataSource);
rdb = new Rdb(dataSourceManager);
rdb.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter());
rdb.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter());
rdb.registerTypeAdapter(Timestamp.class, new TimestampTypeAdapter());
rdb.registerTypeAdapter(java.sql.Date.class, new SqlDateTypeAdapter());
}
Connection conn = rdb.getDataSourceManager().getConnection();
Statement stmt = conn.createStatement();
stmt.execute("delete from User;");
stmt.execute("delete from Book;");
stmt.close();
conn.close();
}
示例13: 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);
}
}
示例14: 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);
}
示例15: SqlConnectionPool
import com.mchange.v2.c3p0.ComboPooledDataSource; //導入方法依賴的package包/類
public SqlConnectionPool(SqlConfig cfg) {
ds = new ComboPooledDataSource();
ds.setJdbcUrl("jdbc:" + cfg.getType() + ":" + cfg.getConnection());
ds.setMinPoolSize(1);
ds.setMaxPoolSize(10);
ds.setAcquireIncrement(2);
}