本文整理汇总了Java中org.apache.tomcat.jdbc.pool.DataSource.createPool方法的典型用法代码示例。如果您正苦于以下问题:Java DataSource.createPool方法的具体用法?Java DataSource.createPool怎么用?Java DataSource.createPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.jdbc.pool.DataSource
的用法示例。
在下文中一共展示了DataSource.createPool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDataSource
import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Override
public DataSource createDataSource(Properties properties, Context context, boolean xa) throws SQLException {
PoolConfiguration poolProperties = EncryptedDataSourceFactory.parsePoolProperties(properties);
poolProperties.setPassword(decode(poolProperties.getPassword()));
if (poolProperties.getDataSourceJNDI() != null && poolProperties.getDataSource() == null) {
performJNDILookup(context, poolProperties);
}
DataSource dataSource = xa ? new XADataSource(poolProperties) : new DataSource(poolProperties);
dataSource.createPool();
return dataSource;
}
示例2: testCloseDataSource
import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Test
public void testCloseDataSource() throws Exception {
TomcatJdbcDataSourceFactory tomcatJdbcDataSourceFactory = new TomcatJdbcDataSourceFactory();
tomcatJdbcDataSourceFactory.setInitialSize(0);
DataSourceInformation dataSourceInformation = new DataSourceInformation(DatabaseType.MYSQL,
"localhost", 3306, "test", "user", "password");
DataSource dataSource = tomcatJdbcDataSourceFactory.createDataSource(dataSourceInformation);
assertNotNull(dataSource);
ConnectionPool pool = dataSource.createPool();
assertFalse(pool.isClosed());
tomcatJdbcDataSourceFactory.closeDataSource(dataSource);
assertTrue(pool.isClosed());
}
示例3: setup
import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Before
public void setup() throws SQLException, StorageException {
dataSource = new DataSource();
dataSource.setDriverClassName(databaseClass);
dataSource.setUrl(databaseUrl);
dataSource.createPool();
dbi = new DBI(dataSource);
snapshotsStore = new OnDiskSnapshotsStore(dbi, snapshotsDirectory.getAbsolutePath());
snapshotsStore.initialize();
}
示例4: start
import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Override
public void start() {
PoolProperties p = new PoolProperties();
p.setUrl(this.conURL);
p.setDriverClassName(this.driverName);
p.setUsername(this.username);
p.setPassword(this.password);
p.setJmxEnabled(false);
if (this.testSql != null && this.testSql.trim().length() > 0) {
p.setValidationQuery(this.testSql);
p.setTestWhileIdle(true);
p.setTimeBetweenEvictionRunsMillis(15 * 1000);
boolean tbf = AppProperties.getAsBoolean(
"TomcatJdbcPool_TestOnBorrow", false);
p.setTestOnBorrow(tbf);// 获取之前是否校验
p.setTestOnReturn(false);
p.setValidationInterval(30000);
}
p.setMaxActive(this.max);
p.setMaxIdle(this.max);
p.setInitialSize(this.min);
p.setMinIdle(min);
int maxwaitfornoconn = AppProperties.getAsInt("TomcatJdbcPool_MaxWait",
30 * 1000);
p.setMaxWait(maxwaitfornoconn);
boolean removeAbandonedFlag = AppProperties.getAsBoolean(
"TomcatJdbcPool_RemoveAbandoned", false);
if (removeAbandonedFlag) {
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setRemoveAbandonedTimeout(AppProperties.getAsInt(
"TomcatJdbcPool_RemoveAbandonedTimeout", 60));
}
// p.setMinEvictableIdleTimeMillis(30000);
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
datasource = new DataSource();
datasource.setPoolProperties(p);
try {
datasource.createPool();
} catch (SQLException e) {
datasource.close();
throw new AppRuntimeException("start tomcat pool err", e);
}
}