Examples of PoolProperties


Examples of org.apache.tomcat.jdbc.pool.PoolProperties

import org.apache.tomcat.jdbc.pool.PoolProperties;

public class SimplePOJOExample {

    public static void main(String[] args) throws Exception {
        PoolConfiguration p = new PoolProperties();
        p.setUrl("jdbc:mysql://localhost:3306/mysql?autoReconnect=true");
        p.setDriverClassName("com.mysql.jdbc.Driver");
        p.setUsername("root");
        p.setPassword("password");
        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.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
        p.setLogAbandoned(true);
        p.setRemoveAbandoned(true);
        DataSource datasource = new DataSource();
        datasource.setPoolProperties(p);

        Connection con = null;
        try {
View Full Code Here

Examples of org.apache.tomcat.jdbc.pool.PoolProperties

  // see also org.mifosplatform.DataSourceProperties.setMifosDefaults()

        final String jdbcUrl = tenant.databaseURL();

        final PoolConfiguration poolConfiguration = new PoolProperties();
        poolConfiguration.setDriverClassName("com.mysql.jdbc.Driver");
        poolConfiguration.setName(tenant.getSchemaName() + "_pool");
        poolConfiguration.setUrl(jdbcUrl);
        poolConfiguration.setUsername(tenant.getSchemaUsername());
        poolConfiguration.setPassword(tenant.getSchemaPassword());

        poolConfiguration.setInitialSize(tenant.getInitialSize());

        poolConfiguration.setTestOnBorrow(tenant.isTestOnBorrow());
        poolConfiguration.setValidationQuery("SELECT 1");
        poolConfiguration.setValidationInterval(tenant.getValidationInterval());

        poolConfiguration.setRemoveAbandoned(tenant.isRemoveAbandoned());
        poolConfiguration.setRemoveAbandonedTimeout(tenant.getRemoveAbandonedTimeout());
        poolConfiguration.setLogAbandoned(tenant.isLogAbandoned());
        poolConfiguration.setAbandonWhenPercentageFull(tenant.getAbandonWhenPercentageFull());

        /**
         * Vishwas- Do we need to enable the below properties and add
         * ResetAbandonedTimer for long running batch Jobs?
         **/
        // poolConfiguration.setMaxActive(tenant.getMaxActive());
        // poolConfiguration.setMinIdle(tenant.getMinIdle());
        // poolConfiguration.setMaxIdle(tenant.getMaxIdle());

        // poolConfiguration.setSuspectTimeout(tenant.getSuspectTimeout());
        // poolConfiguration.setTimeBetweenEvictionRunsMillis(tenant.getTimeBetweenEvictionRunsMillis());
        // poolConfiguration.setMinEvictableIdleTimeMillis(tenant.getMinEvictableIdleTimeMillis());

        poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
                + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport");

        return new org.apache.tomcat.jdbc.pool.DataSource(poolConfiguration);
    }
View Full Code Here

Examples of org.apache.tomcat.jdbc.pool.PoolProperties

    public DefaultTestCase(String name) {
        super(name);
    }

    protected void init() throws Exception {
        PoolProperties p = new DefaultProperties();
        p.setJmxEnabled(false);
        p.setTestWhileIdle(false);
        p.setTestOnBorrow(false);
        p.setTestOnReturn(false);
        p.setValidationInterval(30000);
        p.setTimeBetweenEvictionRunsMillis(30000);
        p.setMaxActive(threadcount);
        p.setInitialSize(threadcount);
        p.setMaxWait(10000);
        p.setRemoveAbandonedTimeout(10000);
        p.setMinEvictableIdleTimeMillis(10000);
        p.setMinIdle(threadcount);
        p.setLogAbandoned(false);
        p.setRemoveAbandoned(false);
        datasource = new org.apache.tomcat.jdbc.pool.DataSourceProxy();
        datasource.setPoolProperties(p);
    }
View Full Code Here

Examples of org.apache.tomcat.jdbc.pool.PoolProperties

   * @throws PropertyVetoException
   * @throws InterruptedException
   * @throws SQLException
   */
  private DataSource multiThreadedTomcatJDBC(boolean doPreparedStatement) throws PropertyVetoException, InterruptedException, SQLException {
    PoolProperties config = new PoolProperties();
    config.setUrl(url);
      config.setDriverClassName("com.jolbox.bonecp.MockJDBCDriver");
    config.setUsername(username);
    config.setPassword(password);
    config.setMaxIdle(pool_size);
    config.setMaxAge(0);
    config.setInitialSize(pool_size);
    config.setMaxActive(pool_size);
    org.apache.tomcat.jdbc.pool.DataSource dsb = new org.apache.tomcat.jdbc.pool.DataSource();
          dsb.setPoolProperties(config);
          if (doPreparedStatement){
            // not yet implemented in this version
          }
View Full Code Here

Examples of org.apache.tomcat.jdbc.pool.PoolProperties

   * @return time taken
   * @throws SQLException
   */
  private long singleTomcatJDBC() throws SQLException{
    // Start tomcat JDBC
    PoolProperties config = new PoolProperties();
    config.setUrl(url);
      config.setDriverClassName("com.jolbox.bonecp.MockJDBCDriver");
    config.setUsername(username);
    config.setPassword(password);
    config.setMaxIdle(pool_size);
    config.setMaxAge(0);
    config.setInitialSize(pool_size);
    config.setMaxActive(pool_size);
    org.apache.tomcat.jdbc.pool.DataSource dsb = new org.apache.tomcat.jdbc.pool.DataSource();
          dsb.setPoolProperties(config);

    long start = System.currentTimeMillis();
    for (int i=0; i < MAX_CONNECTIONS; i++){
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.