本文整理汇总了Java中com.mchange.v2.c3p0.ComboPooledDataSource.setDriverClass方法的典型用法代码示例。如果您正苦于以下问题:Java ComboPooledDataSource.setDriverClass方法的具体用法?Java ComboPooledDataSource.setDriverClass怎么用?Java ComboPooledDataSource.setDriverClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mchange.v2.c3p0.ComboPooledDataSource
的用法示例。
在下文中一共展示了ComboPooledDataSource.setDriverClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: getDatasource
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public static synchronized ComboPooledDataSource getDatasource(String connectionUrl, String user, String password) {
if(dataSources.containsKey(connectionUrl)) {
return dataSources.get(connectionUrl);
}
else {
try {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass("com.mysql.jdbc.Driver"); //loads the jdbc driver
cpds.setJdbcUrl(connectionUrl);
cpds.setUser(user);
cpds.setPassword(password);
cpds.setMaxConnectionAge(18000);//5 hours
dataSources.put(connectionUrl, cpds);
return cpds;
} catch (PropertyVetoException e) {
log.error("Error while creating c3p0 ComboPooledDataSource" + e);
throw new ConnectException(e);
}
}
}
示例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: 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: 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;
}
示例8: 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());
}
示例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: upsertSchool
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Test
public void upsertSchool() throws IOException, PropertyVetoException {
final FetchData result = fetcher.fetch(schoolSelect,
ImmutableMap.of("level", "senior"));
final ScrapeData scrapeData = scraper.scrape(schoolSelect, result);
final ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass(env.getRequiredProperty("spring.datasource.driverClassName"));
dataSource.setJdbcUrl(env.getRequiredProperty("spring.datasource.url"));
dataSource.setUser(env.getRequiredProperty("spring.datasource.username"));
dataSource.setPassword(env.getRequiredProperty("spring.datasource.password"));
final DataSourceTransactionManager txMgr = new DataSourceTransactionManager(dataSource);
txMgr.afterPropertiesSet();
tableDmlGenerator.upsert("ppdbbandung2015", schoolSelect,
scrapeData, dataSource, txMgr);
} finally {
dataSource.close();
}
}
示例12: upsertFiltered
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Test
public void upsertFiltered() throws IOException, PropertyVetoException {
final FetchData result = fetcher.fetch(filteredSelect,
ImmutableMap.of("choice_id", 685));
final ScrapeData scrapeData = scraper.scrape(filteredSelect, result);
final ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass(env.getRequiredProperty("spring.datasource.driverClassName"));
dataSource.setJdbcUrl(env.getRequiredProperty("spring.datasource.url"));
dataSource.setUser(env.getRequiredProperty("spring.datasource.username"));
dataSource.setPassword(env.getRequiredProperty("spring.datasource.password"));
final DataSourceTransactionManager txMgr = new DataSourceTransactionManager(dataSource);
txMgr.afterPropertiesSet();
tableDmlGenerator.upsert("ppdbbandung2015", filteredSelect,
scrapeData, dataSource, txMgr);
} finally {
dataSource.close();
}
}
示例13: upsertStudent
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Test
public void upsertStudent() throws IOException, PropertyVetoException {
final FetchData result = fetcher.fetch(studentGet,
ImmutableMap.of("registration_id", "3004-1009afirmasi"));
final ScrapeData scrapeData = scraper.scrape(studentGet, result);
final ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass(env.getRequiredProperty("spring.datasource.driverClassName"));
dataSource.setJdbcUrl(env.getRequiredProperty("spring.datasource.url"));
dataSource.setUser(env.getRequiredProperty("spring.datasource.username"));
dataSource.setPassword(env.getRequiredProperty("spring.datasource.password"));
final DataSourceTransactionManager txMgr = new DataSourceTransactionManager(dataSource);
txMgr.afterPropertiesSet();
tableDmlGenerator.upsert("ppdbbandung2015", studentGet,
scrapeData, dataSource, txMgr);
} finally {
dataSource.close();
}
}
示例14: summarizeFixed
import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Test
public void summarizeFixed() throws IOException, PropertyVetoException {
final ComboPooledDataSource dataSource = new ComboPooledDataSource();
try {
dataSource.setDriverClass(env.getRequiredProperty("spring.datasource.driverClassName"));
dataSource.setJdbcUrl(env.getRequiredProperty("spring.datasource.url"));
dataSource.setUser(env.getRequiredProperty("spring.datasource.username"));
dataSource.setPassword(env.getRequiredProperty("spring.datasource.password"));
final DataSourceTransactionManager txMgr = new DataSourceTransactionManager(dataSource);
txMgr.afterPropertiesSet();
// Please delete this data point, we already have 2015-07-02T04:00+07:00 generated manually for reference
// summarizer.summarize("ppdbbandung2015", "optionapplicantsnapshot", dataSource,
// txMgr, new DateTime("2015-07-02T05:00+07:00"));
summarizer.summarize("ppdbbandung2015", "optionapplicantsnapshot", dataSource,
txMgr, new DateTime());
} finally {
dataSource.close();
}
}
示例15: 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;
}