本文整理汇总了Java中org.apache.tomcat.jdbc.pool.PoolProperties.setConnectionProperties方法的典型用法代码示例。如果您正苦于以下问题:Java PoolProperties.setConnectionProperties方法的具体用法?Java PoolProperties.setConnectionProperties怎么用?Java PoolProperties.setConnectionProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.jdbc.pool.PoolProperties
的用法示例。
在下文中一共展示了PoolProperties.setConnectionProperties方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoolProperties
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static PoolProperties getPoolProperties() {
Endpoint locatorEndPoint = (Endpoint) (NetworkServerHelper.getNetworkLocatorEndpoints()).get(0);
String hostname = getHostNameFromEndpoint(locatorEndPoint);
int port = getPortFromEndpoint(locatorEndPoint);
connProp.putAll(getExtraConnProp());
PoolProperties p = new PoolProperties();
StringBuilder sb = new StringBuilder();
for (Iterator iter = connProp.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<String, String> entry = (Map.Entry<String, String>) iter.next();
sb.append(entry.getKey() + "=" + entry.getValue() +";");
}
int lastIndex = sb.lastIndexOf(";");
if (lastIndex != -1) sb.deleteCharAt(lastIndex);
p.setConnectionProperties(sb.toString());
Log.getLogWriter().info("Tomcat data source setting the following connection prop: " + sb.toString());
p.setUrl(protocol + hostname+ ":" + port);
p.setDriverClassName(driver);
return p;
}
示例2: getDatabasePoolConfig
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public DatabasePoolConfig getDatabasePoolConfig(String name) {
DataSourceConfigure configure = DataSourceConfigureLocator.getInstance().getDataSourceConfigure(name);
PoolProperties poolProperties = new PoolProperties();
poolProperties.setTestWhileIdle(configure.getBooleanProperty(TESTWHILEIDLE, DEFAULT_TESTWHILEIDLE));
poolProperties.setTestOnBorrow(configure.getBooleanProperty(TESTONBORROW, DEFAULT_TESTONBORROW));
poolProperties.setTestOnReturn(configure.getBooleanProperty(TESTONRETURN, DEFAULT_TESTONRETURN));
poolProperties.setValidationQuery(configure.getProperty(VALIDATIONQUERY, DEFAULT_VALIDATIONQUERY));
poolProperties.setValidationQueryTimeout(
configure.getIntProperty(VALIDATIONQUERYTIMEOUT, DEFAULT_VALIDATIONQUERYTIMEOUT));
poolProperties.setValidationInterval(configure.getLongProperty(VALIDATIONINTERVAL, DEFAULT_VALIDATIONINTERVAL));
poolProperties.setTimeBetweenEvictionRunsMillis(
configure.getIntProperty(TIMEBETWEENEVICTIONRUNSMILLIS, DEFAULT_TIMEBETWEENEVICTIONRUNSMILLIS));
poolProperties.setMinEvictableIdleTimeMillis(DEFAULT_MINEVICTABLEIDLETIMEMILLIS);
poolProperties.setMaxAge(configure.getIntProperty(MAX_AGE, DEFAULT_MAXAGE));
poolProperties.setMaxActive(configure.getIntProperty(MAXACTIVE, DEFAULT_MAXACTIVE));
poolProperties.setMinIdle(configure.getIntProperty(MINIDLE, DEFAULT_MINIDLE));
poolProperties.setMaxWait(configure.getIntProperty(MAXWAIT, DEFAULT_MAXWAIT));
poolProperties.setInitialSize(configure.getIntProperty(INITIALSIZE, DEFAULT_INITIALSIZE));
poolProperties.setRemoveAbandonedTimeout(
configure.getIntProperty(REMOVEABANDONEDTIMEOUT, DEFAULT_REMOVEABANDONEDTIMEOUT));
poolProperties.setRemoveAbandoned(configure.getBooleanProperty(REMOVEABANDONED, DEFAULT_REMOVEABANDONED));
poolProperties.setLogAbandoned(configure.getBooleanProperty(LOGABANDONED, DEFAULT_LOGABANDONED));
poolProperties
.setConnectionProperties(configure.getProperty(CONNECTIONPROPERTIES, DEFAULT_CONNECTIONPROPERTIES));
poolProperties.setValidatorClassName(configure.getProperty(VALIDATORCLASSNAME, DEFAULT_VALIDATORCLASSNAME));
poolProperties.setJmxEnabled(DEFAULT_JMXENABLED);
poolProperties.setJdbcInterceptors(DEFAULT_JDBCINTERCEPTORS);
return new DatabasePoolConfig(poolProperties);
}
示例3: convert
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public PoolProperties convert(DataSourceConfigure config) {
PoolProperties properties = new PoolProperties();
/**
* It is assumed that user name/password/url/driver class name are provided in pool config If not, it should be
* provided by the config provider
*/
properties.setUrl(config.getConnectionUrl());
properties.setUsername(config.getUserName());
properties.setPassword(config.getPassword());
properties.setDriverClassName(config.getDriverClass());
properties.setTestWhileIdle(config.getBooleanProperty(TESTWHILEIDLE, DEFAULT_TESTWHILEIDLE));
properties.setTestOnBorrow(config.getBooleanProperty(TESTONBORROW, DEFAULT_TESTONBORROW));
properties.setTestOnReturn(config.getBooleanProperty(TESTONRETURN, DEFAULT_TESTONRETURN));
properties.setValidationQuery(config.getProperty(VALIDATIONQUERY, DEFAULT_VALIDATIONQUERY));
properties.setValidationQueryTimeout(
config.getIntProperty(VALIDATIONQUERYTIMEOUT, DEFAULT_VALIDATIONQUERYTIMEOUT));
properties.setValidationInterval(config.getLongProperty(VALIDATIONINTERVAL, DEFAULT_VALIDATIONINTERVAL));
properties.setTimeBetweenEvictionRunsMillis(
config.getIntProperty(TIMEBETWEENEVICTIONRUNSMILLIS, DEFAULT_TIMEBETWEENEVICTIONRUNSMILLIS));
properties.setMinEvictableIdleTimeMillis(
config.getIntProperty(MINEVICTABLEIDLETIMEMILLIS, DEFAULT_MINEVICTABLEIDLETIMEMILLIS));
properties.setMaxAge(config.getIntProperty(MAX_AGE, DEFAULT_MAXAGE));
properties.setMaxActive(config.getIntProperty(MAXACTIVE, DEFAULT_MAXACTIVE));
properties.setMinIdle(config.getIntProperty(MINIDLE, DEFAULT_MINIDLE));
properties.setMaxWait(config.getIntProperty(MAXWAIT, DEFAULT_MAXWAIT));
properties.setInitialSize(config.getIntProperty(INITIALSIZE, DEFAULT_INITIALSIZE));
properties.setRemoveAbandonedTimeout(
config.getIntProperty(REMOVEABANDONEDTIMEOUT, DEFAULT_REMOVEABANDONEDTIMEOUT));
properties.setRemoveAbandoned(config.getBooleanProperty(REMOVEABANDONED, DEFAULT_REMOVEABANDONED));
properties.setLogAbandoned(config.getBooleanProperty(LOGABANDONED, DEFAULT_LOGABANDONED));
properties.setConnectionProperties(config.getProperty(CONNECTIONPROPERTIES, DEFAULT_CONNECTIONPROPERTIES));
properties.setValidatorClassName(config.getProperty(VALIDATORCLASSNAME, DEFAULT_VALIDATORCLASSNAME));
String initSQL = config.getProperty(INIT_SQL);
if (initSQL != null && !initSQL.isEmpty())
properties.setInitSQL(initSQL);
String initSQL2 = config.getProperty(INIT_SQL2);
if (initSQL2 != null && !initSQL2.isEmpty())
properties.setInitSQL(initSQL2);
// This are current hard coded as default value
properties.setJmxEnabled(DEFAULT_JMXENABLED);
properties.setJdbcInterceptors(DEFAULT_JDBCINTERCEPTORS);
return properties;
}
示例4: setAllPoolProperties
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public void setAllPoolProperties() throws Exception {
poolProperties = new PoolProperties();
//todo: probably more ifs to provide more information of which wasn't defined.
if (url == null || driverClassName == null || userName == null || password == null) {
throw new Exception("A mandatory item wasn't defined correctly");
} else {
//Mandatory items.
poolProperties.setUrl(url);
poolProperties.setDriverClassName(driverClassName);
poolProperties.setUsername(userName);
poolProperties.setPassword(password);
//Not Mandatory Items.
if (abandonWhenPercentageFull != null)
poolProperties.setAbandonWhenPercentageFull(abandonWhenPercentageFull);
if (accessToUnderlyingConnectionAllowed != null)
poolProperties.setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
if (alternateUsernameAllowed != null) poolProperties.setAlternateUsernameAllowed(alternateUsernameAllowed);
if (commitOnReturn != null) poolProperties.setCommitOnReturn(commitOnReturn);
if (connectionProperties != null) poolProperties.setConnectionProperties(connectionProperties);
if (dataSource != null) poolProperties.setDataSource(dataSource); //todo: probably a problem.
if (dataSourceJNDI != null) poolProperties.setDataSourceJNDI(dataSourceJNDI);
if (dbProperties != null) poolProperties.setDbProperties(dbProperties);
if (defaultAutoCommit != null) poolProperties.setDefaultAutoCommit(defaultAutoCommit);
if (defaultCatalog != null) poolProperties.setDefaultCatalog(defaultCatalog);
if (defaultReadOnly != null) poolProperties.setDefaultReadOnly(defaultReadOnly);
if (defaultTranslationIsolation != null)
poolProperties.setDefaultTransactionIsolation(defaultTranslationIsolation);
if (fairQueue != null) poolProperties.setFairQueue(fairQueue);
if (ignoreExceptionOnPreLoad != null) poolProperties.setIgnoreExceptionOnPreLoad(ignoreExceptionOnPreLoad);
if (initialSize != null) poolProperties.setInitialSize(initialSize);
if (initSQL != null) poolProperties.setInitSQL(initSQL);
if (jdbcInterceptors != null) poolProperties.setJdbcInterceptors(jdbcInterceptors);
if (jmxEnabled != null) poolProperties.setJmxEnabled(jmxEnabled);
if (logAbandoned != null) poolProperties.setLogAbandoned(logAbandoned);
if (logValidationErrors != null) poolProperties.setLogValidationErrors(logValidationErrors);
if (maxActive != null) poolProperties.setMaxActive(maxActive);
if (maxAge != null) poolProperties.setMaxAge(maxAge);
if (maxIdle != null) poolProperties.setMaxIdle(maxIdle);
if (maxWait != null) poolProperties.setMaxWait(maxWait);
if (minEvictableIdleTimeMillis != null)
poolProperties.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
if (minIdle != null) poolProperties.setMinIdle(minIdle);
if (name != null) poolProperties.setName(name);
if (numTestsPerEvictionRun != null) poolProperties.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
if (propagateInterruptState != null) poolProperties.setPropagateInterruptState(propagateInterruptState);
if (removeAbandoned != null) poolProperties.setRemoveAbandoned(removeAbandoned);
if (removeAbandonedTimeout != null) poolProperties.setRemoveAbandonedTimeout(removeAbandonedTimeout);
if (rollbackOnReturn != null) poolProperties.setRollbackOnReturn(rollbackOnReturn);
if (suspectTimeout != null) poolProperties.setSuspectTimeout(suspectTimeout);
if (testOnBorrow != null) poolProperties.setTestOnBorrow(testOnBorrow);
if (testOnConnect != null) poolProperties.setTestOnConnect(testOnConnect);
if (testOnReturn != null) poolProperties.setTestOnReturn(testOnReturn);
if (testWhileIdle != null) poolProperties.setTestWhileIdle(testWhileIdle);
if (timeBetweenEvictionsRunMillis != null)
poolProperties.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionsRunMillis);
if (useDisposableConnectionFacade != null)
poolProperties.setUseDisposableConnectionFacade(useDisposableConnectionFacade);
if (useEquals != null) poolProperties.setUseEquals(useEquals);
if (useLock != null) poolProperties.setUseLock(useLock);
if (validationInterval != null) poolProperties.setValidationInterval(validationInterval);
if (validationQuery != null) poolProperties.setValidationQuery(validationQuery);
if (validationQueryTimeout != null) poolProperties.setValidationQueryTimeout(validationQueryTimeout);
if (validator != null) poolProperties.setValidator(validator);
if (validatorClassName != null) poolProperties.setValidatorClassName(validatorClassName);
//Set the DataSource Provider's Properties.
dataSourceProvider = new DataSource();
dataSourceProvider.setPoolProperties(poolProperties);
}
}