本文整理汇总了Java中org.apache.tomcat.jdbc.pool.PoolProperties.setLogValidationErrors方法的典型用法代码示例。如果您正苦于以下问题:Java PoolProperties.setLogValidationErrors方法的具体用法?Java PoolProperties.setLogValidationErrors怎么用?Java PoolProperties.setLogValidationErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.jdbc.pool.PoolProperties
的用法示例。
在下文中一共展示了PoolProperties.setLogValidationErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: ArtifactoryTomcatDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public ArtifactoryTomcatDataSource(StorageProperties s) {
// see org.apache.tomcat.jdbc.pool.DataSourceFactory.parsePoolProperties()
PoolProperties p = new PoolProperties();
p.setUrl(s.getConnectionUrl());
p.setDriverClassName(s.getDriverClass());
p.setUsername(s.getUsername());
p.setPassword(s.getPassword());
p.setDefaultAutoCommit(false);
p.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
p.setInitialSize(s.getIntProperty("initialSize", 1));
p.setMaxAge(s.getIntProperty("maxAge", 0));
p.setMaxActive(s.getMaxActiveConnections());
p.setMaxWait(s.getIntProperty("maxWait", (int) TimeUnit.SECONDS.toMillis(120)));
p.setMaxIdle(s.getMaxIdleConnections());
p.setMinIdle(s.getIntProperty("minIdle", 1));
p.setMinEvictableIdleTimeMillis(
s.getIntProperty("minEvictableIdleTimeMillis", 300000));
p.setTimeBetweenEvictionRunsMillis(
s.getIntProperty("timeBetweenEvictionRunsMillis", 30000));
p.setInitSQL(s.getProperty("initSQL", null));
// validation query for all kind of tests (connect, borrow etc.)
p.setValidationQuery(s.getProperty("validationQuery", getDefaultValidationQuery(s)));
p.setValidationQueryTimeout(s.getIntProperty("validationQueryTimeout", 30));
p.setValidationInterval(s.getLongProperty("validationInterval", 30000));
p.setTestOnBorrow(s.getBooleanProperty("testOnBorrow", true));
p.setTestWhileIdle(s.getBooleanProperty("testWhileIdle", false));
p.setTestOnReturn(s.getBooleanProperty("testOnReturn", false));
p.setTestOnConnect(s.getBooleanProperty("testOnConnect", false));
p.setRemoveAbandoned(s.getBooleanProperty("removeAbandoned", false));
p.setRemoveAbandonedTimeout(s.getIntProperty("removeAbandonedTimeout", 600));
p.setSuspectTimeout(s.getIntProperty("suspectTimeout", 600));
p.setLogAbandoned(s.getBooleanProperty("logAbandoned", false));
p.setLogValidationErrors(s.getBooleanProperty("logValidationErrors", false));
p.setJmxEnabled(s.getBooleanProperty("jmxEnabled", true));
// only applicable if auto commit is false. has high performance penalty and only protects bugs in the code
p.setRollbackOnReturn(s.getBooleanProperty("rollbackOnReturn", false));
p.setCommitOnReturn(s.getBooleanProperty("commitOnReturn", false));
p.setIgnoreExceptionOnPreLoad(s.getBooleanProperty("ignoreExceptionOnPreLoad", false));
//p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", "ConnectionState;StatementFinalizer"));
p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", null));
p.setDefaultCatalog(s.getProperty("defaultCatalog", null));
setPoolProperties(p);
}
示例3: createUniqueIdDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public static DataSource createUniqueIdDataSource(StorageProperties s) {
// see org.apache.tomcat.jdbc.pool.DataSourceFactory.parsePoolProperties()
PoolProperties p = new PoolProperties();
p.setUrl(s.getConnectionUrl());
p.setDriverClassName(s.getDriverClass());
p.setUsername(s.getUsername());
p.setPassword(s.getPassword());
// auto commit is true for the unique id generator
p.setDefaultAutoCommit(true);
p.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
// only one connection is required for the id generator
p.setInitialSize(1);
p.setMinIdle(1);
p.setMaxIdle(1);
p.setMaxActive(1);
p.setMaxAge(s.getIntProperty("maxAge", 0));
p.setMaxWait(s.getIntProperty("maxWait", (int) TimeUnit.SECONDS.toMillis(120)));
p.setMinEvictableIdleTimeMillis(
s.getIntProperty("minEvictableIdleTimeMillis", 300000));
p.setTimeBetweenEvictionRunsMillis(
s.getIntProperty("timeBetweenEvictionRunsMillis", 30000));
p.setInitSQL(s.getProperty("initSQL", null));
// validation query for all kind of tests (connect, borrow etc.)
p.setValidationQuery(s.getProperty("validationQuery", getDefaultValidationQuery(s)));
p.setValidationQueryTimeout(s.getIntProperty("validationQueryTimeout", 30));
p.setValidationInterval(s.getLongProperty("validationInterval", 30000));
p.setTestOnBorrow(s.getBooleanProperty("testOnBorrow", true));
p.setTestWhileIdle(s.getBooleanProperty("testWhileIdle", false));
p.setTestOnReturn(s.getBooleanProperty("testOnReturn", false));
p.setTestOnConnect(s.getBooleanProperty("testOnConnect", false));
p.setRemoveAbandoned(s.getBooleanProperty("removeAbandoned", false));
p.setRemoveAbandonedTimeout(s.getIntProperty("removeAbandonedTimeout", 600));
p.setSuspectTimeout(s.getIntProperty("suspectTimeout", 600));
p.setLogAbandoned(s.getBooleanProperty("logAbandoned", false));
p.setLogValidationErrors(s.getBooleanProperty("logValidationErrors", false));
p.setJmxEnabled(false);
p.setIgnoreExceptionOnPreLoad(s.getBooleanProperty("ignoreExceptionOnPreLoad", false));
//p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", "ConnectionState;StatementFinalizer"));
p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", null));
p.setDefaultCatalog(s.getProperty("defaultCatalog", null));
return new DataSource(p);
}
示例4: initConnectionPool
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
private void initConnectionPool() {
poolConfig = new PoolProperties();
poolConfig.setName("kiwi-" + (++KIWI_ID));
poolConfig.setUrl(configuration.getJdbcUrl());
poolConfig.setDriverClassName(configuration.getDialect().getDriverClass());
poolConfig.setUsername(configuration.getDbUser());
poolConfig.setPassword(configuration.getDbPassword());
poolConfig.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
poolConfig.setCommitOnReturn(true);
poolConfig.setValidationQuery(configuration.getDialect().getValidationQuery());
poolConfig.setLogValidationErrors(true);
poolConfig.setTestWhileIdle(true);
poolConfig.setTimeBetweenEvictionRunsMillis(5000);
/*
poolConfig.setLogAbandoned(true);
poolConfig.setRemoveAbandoned(true);
*/
// interceptors
if(configuration.isQueryLoggingEnabled()) {
poolConfig.setJdbcInterceptors(
"org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;" +
"org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport"
);
} else {
poolConfig.setJdbcInterceptors(
"org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
);
}
if(log.isDebugEnabled()) {
poolConfig.setSuspectTimeout(30);
poolConfig.setLogAbandoned(true);
}
connectionPool = new DataSource(poolConfig);
}