当前位置: 首页>>代码示例>>Java>>正文


Java PoolProperties.setJdbcInterceptors方法代码示例

本文整理汇总了Java中org.apache.tomcat.jdbc.pool.PoolProperties.setJdbcInterceptors方法的典型用法代码示例。如果您正苦于以下问题:Java PoolProperties.setJdbcInterceptors方法的具体用法?Java PoolProperties.setJdbcInterceptors怎么用?Java PoolProperties.setJdbcInterceptors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tomcat.jdbc.pool.PoolProperties的用法示例。


在下文中一共展示了PoolProperties.setJdbcInterceptors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPoolProperties

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public PoolProperties getPoolProperties() {
    PoolProperties poolProperties = new PoolProperties();
    poolProperties.setUrl("jdbc:postgresql://localhost:5432/chronica");
    poolProperties.setDriverClassName("org.postgresql.Driver");
    poolProperties.setUsername("chronica");
    poolProperties.setPassword("chronica");
    poolProperties.setJmxEnabled(true);
    poolProperties.setTestWhileIdle(false);
    poolProperties.setTestOnBorrow(true);
    poolProperties.setValidationQuery("SELECT 1");
    poolProperties.setTestOnReturn(false);
    poolProperties.setValidationInterval(30000);
    poolProperties.setTimeBetweenEvictionRunsMillis(30000);
    poolProperties.setMaxActive(100);
    poolProperties.setInitialSize(10);
    poolProperties.setMaxWait(10000);
    poolProperties.setRemoveAbandonedTimeout(60);
    poolProperties.setMinEvictableIdleTimeMillis(30000);
    poolProperties.setMinIdle(10);
    poolProperties.setLogAbandoned(true);
    poolProperties.setRemoveAbandoned(true);
    poolProperties.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
            + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
    return poolProperties;
}
 
开发者ID:evanx,项目名称:chronic,代码行数:26,代码来源:ChronicProperties.java

示例2: createPool

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public static void createPool() throws Exception {
// Modify this code in order to extract a Connection from your
// connection pooling system:

// Driver parameters to use:
String driverClassName = "org.postgresql.Driver";
String url = "jdbc:postgresql://localhost:5432/kawansoft_example";
String username = "user1";
String password = "password1";

// Creating the DataSource bean and populating the values:
// Mandatory values to set
PoolProperties p = new PoolProperties();
p.setDriverClassName(driverClassName);
p.setUrl(url);
p.setUsername(username);
p.setPassword(password);

// Other possible values to set
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(2);
p.setInitialSize(2);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(2);
p.setMaxIdle(2);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setJdbcInterceptors("ConnectionState;StatementFinalizer");

dataSource = new DataSource();
dataSource.setPoolProperties(p);

   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:40,代码来源:TestTomcatJdbcPoolBehavior.java

示例3: 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);
}
 
开发者ID:ctripcorp,项目名称:dal,代码行数:38,代码来源:DatabasePoolConfigParser.java

示例4: createDataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
private static DataSource createDataSource(String url, String userName, String password, String driverClass)
        throws Exception {
    PoolProperties p = new PoolProperties();

    p.setUrl(url);
    p.setUsername(userName);
    p.setPassword(password);
    p.setDriverClassName(driverClass);
    p.setJmxEnabled(false);
    p.setTestWhileIdle(false);
    p.setTestOnBorrow(true);
    p.setTestOnReturn(false);
    p.setValidationQuery("SELECT 1");
    p.setValidationQueryTimeout(5);
    p.setValidationInterval(30000L);
    p.setTimeBetweenEvictionRunsMillis(5000);
    p.setMaxActive(100);
    p.setMinIdle(0);
    p.setMaxWait(10000);
    p.setMaxAge(0L);
    p.setInitialSize(1);
    p.setRemoveAbandonedTimeout(60);
    p.setRemoveAbandoned(true);
    p.setLogAbandoned(true);
    p.setMinEvictableIdleTimeMillis(30000);
    p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
            + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");

    org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(p);
    ds.createPool();
    return ds;
}
 
开发者ID:ctripcorp,项目名称:dal,代码行数:33,代码来源:DataSourceUtil.java

示例5: setUp

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Before
public void setUp() {
    PoolProperties p = new PoolProperties();
    p.setUrl("jdbc:mysql://localhost:3306/mysql");
    p.setDriverClassName("com.mysql.jdbc.Driver");
    p.setUsername("root");
    p.setPassword("");
    p.setJmxEnabled(true);
    p.setTestWhileIdle(false);
    p.setTestOnBorrow(true);
    p.setValidationQuery("SELECT 1");
    p.setTestOnReturn(false);
    p.setValidationInterval(30000);
    p.setTimeBetweenEvictionRunsMillis(30000);
    p.setMaxActive(100);
    p.setInitialSize(10);
    p.setMaxWait(10000);
    p.setRemoveAbandonedTimeout(60);
    p.setMinEvictableIdleTimeMillis(30000);
    p.setMinIdle(10);
    p.setLogAbandoned(true);
    p.setRemoveAbandoned(true);
    p.setFairQueue(true);
    p.setJdbcInterceptors(
            "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
                    "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
    dataSource = new DataSource();
    dataSource.setPoolProperties(p);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:30,代码来源:DataSourceTest.java

示例6: setUp

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Before
public void setUp() {
    PoolProperties p = new PoolProperties();
    p.setUrl("jdbc:mysql://localhost:3306/admin");
    p.setDriverClassName("com.mysql.jdbc.Driver");
    p.setUsername("root");
    p.setPassword("");
    p.setJmxEnabled(true);
    p.setTestWhileIdle(false);
    p.setTestOnBorrow(true);
    p.setValidationQuery("SELECT 1");
    p.setTestOnReturn(false);
    p.setValidationInterval(30000);
    p.setTimeBetweenEvictionRunsMillis(30000);
    p.setMaxActive(100);
    p.setInitialSize(10);
    p.setMaxWait(10000);
    p.setRemoveAbandonedTimeout(60);
    p.setMinEvictableIdleTimeMillis(30000);
    p.setMinIdle(10);
    p.setLogAbandoned(true);
    p.setRemoveAbandoned(true);
    p.setFairQueue(true);
    p.setJdbcInterceptors(
            "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
                    "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
    dataSource = new DataSource();
    dataSource.setPoolProperties(p);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:30,代码来源:DbUtilsTest.java

示例7: setUp

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Before
public void setUp() {
    PoolProperties p = new PoolProperties();
    p.setUrl("jdbc:mysql://127.0.0.1:3308/admin");
    p.setDriverClassName("com.mysql.jdbc.Driver");
    p.setUsername("root");
    p.setPassword("");
    p.setJmxEnabled(true);
    p.setTestWhileIdle(false);
    p.setTestOnBorrow(true);
    p.setValidationQuery("SELECT 1");
    p.setTestOnReturn(false);
    p.setValidationInterval(30000);
    p.setTimeBetweenEvictionRunsMillis(30000);
    p.setMaxActive(100);
    p.setInitialSize(10);
    p.setMaxWait(10000);
    p.setRemoveAbandonedTimeout(60);
    p.setMinEvictableIdleTimeMillis(30000);
    p.setMinIdle(10);
    p.setLogAbandoned(true);
    p.setRemoveAbandoned(true);
    p.setFairQueue(true);
    p.setJdbcInterceptors(
            "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
                    "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
    dataSource = new DataSource();
    dataSource.setPoolProperties(p);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:30,代码来源:Sql2oTest.java

示例8: DBConnection

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public DBConnection(JdbcConfiguration configuration) {
	PoolProperties p = new PoolProperties();
	p.setDriverClassName(configuration.getDriverClass());
	p.setUrl(configuration.getUrl());
	p.setUsername(configuration.getUsername());
	p.setPassword(configuration.getPassword());
	p.setJmxEnabled(true);
	p.setTestWhileIdle(false);
	p.setTestOnBorrow(true);
	p.setValidationQuery("SELECT 1");
	p.setTestOnReturn(false);
	p.setValidationInterval(30000);
	p.setTimeBetweenEvictionRunsMillis(30000);
	p.setMaxActive(100);
	p.setInitialSize(10);
	p.setMaxWait(10000);
	p.setRemoveAbandonedTimeout(60);
	p.setMinEvictableIdleTimeMillis(30000);
	p.setMinIdle(10);
	p.setLogAbandoned(true);
	p.setRemoveAbandoned(true);
	p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
							+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
	
	this.dataSource = new DataSource();
	this.dataSource.setPoolProperties(p);
	
}
 
开发者ID:fengsage,项目名称:jfinal-admin-gen,代码行数:29,代码来源:DBConnection.java

示例9: initial

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Test
public void initial() throws Exception {
    PoolProperties p = new PoolProperties();
    p.setUrl("jdbc:h2:mem");
    p.setDriverClassName("org.h2.Driver");
    p.setUsername("sa");
    p.setPassword("sa");
    p.setJmxEnabled(true);
    p.setTestWhileIdle(false);
    p.setTestOnBorrow(true);
    p.setValidationQuery("SELECT 1");
    p.setTestOnReturn(false);
    p.setValidationInterval(30000);
    p.setTimeBetweenEvictionRunsMillis(30000);
    p.setMaxActive(100);
    p.setInitialSize(10);
    p.setMaxWait(10000);
    p.setRemoveAbandonedTimeout(60);
    p.setMinEvictableIdleTimeMillis(30000);
    p.setMinIdle(10);
    p.setLogAbandoned(true);
    p.setRemoveAbandoned(true);
    p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
            + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
    DataSource dataSource = new DataSource();
    dataSource.setPoolProperties(p);
    try (Connection connection = dataSource.getConnection(); 
            Statement statement = connection.createStatement(); 
            ResultSet resultSet = statement.executeQuery("select 1")) {
        while (resultSet.next()) {
            logger.info("{}", resultSet.getObject(1));
        }
    }          
}
 
开发者ID:evanx,项目名称:chronic,代码行数:35,代码来源:TestTomcatPool.java

示例10: addDataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public static void addDataSource(String key, Properties props) throws SQLException{
    String cs = props.getProperty("jdbcconnectstring");
    Matcher o = oraclePattern.matcher(cs);
    Matcher m = mysqlPattern.matcher(cs);
    int currType;
    
    PoolProperties p = new PoolProperties();
    p.setUrl(props.getProperty("jdbcconnectstring"));
    if (o.matches()) {
    	p.setDriverClassName("oracle.jdbc.OracleDriver");
    	currType=ORACLE;
    } else if (m.matches()) {
    	p.setDriverClassName("com.mysql.jdbc.Driver");
    	currType=MYSQL;
    } else {
        throw new SQLException("Unknown database type in " + cs);
    }
    p.setUsername(props.getProperty("user"));
    p.setPassword(props.getProperty("passwd"));
    //p.setJmxEnabled(true);
    p.setTestWhileIdle(false);
    p.setTestOnBorrow(true);
    p.setValidationQuery("SELECT 1");
    p.setValidationInterval(30000);
    p.setTestOnReturn(false);
    p.setTimeBetweenEvictionRunsMillis(30000);
    p.setMaxActive(100);
    p.setInitialSize(5);
    p.setMaxWait(1000);
    p.setRemoveAbandonedTimeout(30000);
    p.setMinEvictableIdleTimeMillis(30000);
    p.setMinIdle(5);
    p.setLogAbandoned(true);
    p.setRemoveAbandoned(true);
    p.setJdbcInterceptors(
      "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+
      "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
    DataSource datasource = new DataSource();
    datasource.setPoolProperties(p);
    sourceType.put(datasource, currType);
    sources.put(key, datasource);
}
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:43,代码来源:DatabaseConnectionManager.java

示例11: newDataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
DataSource newDataSource(HashMapKey hashMapKey, String json) {
    TomcatPoolProperties tomcatPoolProperties = new Gson().fromJson(json, TomcatPoolProperties.class);
    PoolProperties poolProperties = new PoolProperties();

    String username = tomcatPoolProperties.getUsername();
    String password = tomcatPoolProperties.getPassword();
    String url = tomcatPoolProperties.getUrl();

    if (url == null || password == null || username == null) {
        throw new MalformedJsonException("The url or username or password is null. Provide " + "proper details.");
    }

    poolProperties.setUsername(username);
    poolProperties.setPassword(password);

    poolProperties.setUrl(tomcatPoolProperties.getUrl());
    poolProperties.setTestWhileIdle(tomcatPoolProperties.isTestWhileIdle());
    poolProperties.setTestOnBorrow(tomcatPoolProperties.isTestOnBorrow());
    poolProperties.setTestOnReturn(tomcatPoolProperties.isTestOnReturn());
    poolProperties.setValidationQuery(tomcatPoolProperties.getValidationQuery());
    poolProperties.setValidationInterval(tomcatPoolProperties.getValidationInterval());
    poolProperties.setTimeBetweenEvictionRunsMillis(tomcatPoolProperties.getTimeBetweenEvictionRunsMillis());
    poolProperties.setMaxActive(tomcatPoolProperties.getMaxActive());
    poolProperties.setMinIdle(tomcatPoolProperties.getMinIdle());
    poolProperties.setMaxWait(tomcatPoolProperties.getMaxWait());
    poolProperties.setInitialSize(tomcatPoolProperties.getInitialSize());
    poolProperties.setRemoveAbandonedTimeout(tomcatPoolProperties.getRemoveAbandonedTimeout());
    poolProperties.setRemoveAbandoned(tomcatPoolProperties.isRemoveAbandoned());
    poolProperties.setLogAbandoned(tomcatPoolProperties.isLogAbandoned());
    poolProperties.setMinEvictableIdleTimeMillis(tomcatPoolProperties.getMinEvictableIdleTimeMillis());
    poolProperties.setJmxEnabled(tomcatPoolProperties.isJmxEnabled());
    poolProperties.setJdbcInterceptors(tomcatPoolProperties.getJdbcInterceptors());

    poolProperties.setDriverClassName(tomcatPoolProperties.getDriverClassName());

    boolean forceAlternateUsername = tomcatPoolProperties.isForceAlternateUsername();
    if (forceAlternateUsername) {
        if (logger.isDebugEnabled()) {
            logger.debug("The property forceAlternateUsername is true. Setting it to false(default) improves the " +
                    "" + "performance while retrieving connections from the pool.");
        }
    }

    javax.sql.DataSource dataSource = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties);
    if (logger.isInfoEnabled()) {
        logger.info("Successfully prepared the Data Source " + dataSource.getClass() + ". " +
                "Registering key for the DataSource provider " + hashMapKey.getDataSourceProvider());
    }

    ((org.apache.tomcat.jdbc.pool.DataSource) dataSource).setAlternateUsernameAllowed(forceAlternateUsername);

    if (logger.isInfoEnabled()) {
        logger.info("Registering DataSource pool of type TomcatJdbc");
    }

    this.dataSourcePool.register(hashMapKey, dataSource, json);
    return dataSource;
}
 
开发者ID:helicalinsight,项目名称:helicalinsight,代码行数:59,代码来源:TomcatConfigurer.java

示例12: 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;
}
 
开发者ID:ctripcorp,项目名称:dal,代码行数:55,代码来源:PoolPropertiesHelper.java

示例13: start

import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的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);
	}
}
 
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:46,代码来源:TomcatJdbcPool.java

示例14: 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);
	}
}
 
开发者ID:Bonsanto,项目名称:db-component,代码行数:73,代码来源:DBConnection.java

示例15: 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);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:54,代码来源:ArtifactoryTomcatDataSource.java


注:本文中的org.apache.tomcat.jdbc.pool.PoolProperties.setJdbcInterceptors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。