本文整理匯總了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;
}