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