Examples of PoolProperties


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

//            log.fatal("CONNECTION CREATION EXCEPTION: " + ex);
//            throw(ex);
//        }
        log.debug("building datasource pool from properties: [" + jdbcDriver + "]: " + jdbcUrl + " @ " + jdbcUserName + " / " + jdbcPassword);
        // attempt to set up the datasource for the first time and return a connection
        PoolProperties p = new PoolProperties();
        p.setUrl(jdbcUrl);
        p.setDriverClassName(jdbcDriver);
        p.setUsername(jdbcUserName);
        p.setPassword(jdbcPassword);
        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(2);
        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 = new DataSource();
        dataSource.setPoolProperties(p);
        log.debug("set properties...");
View Full Code Here

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

         
          if (log.isInfoEnabled()) {
            log.info("Initializing data source for JDBC URL: " + dbUrl);
          }

          PoolProperties p = new PoolProperties();
          p.setUrl(dbUrl);
          p.setDriverClassName(driver);
          p.setUsername(username);
          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.setLogAbandoned(true);
          p.setRemoveAbandoned(true);
          p.setDefaultAutoCommit(false);
          p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
              + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
          DataSource tomcatDatasource = new DataSource();
          tomcatDatasource.setPoolProperties(p);

          dataSource = tomcatDatasource;
View Full Code Here

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

    }

    @Test
    public void testPool() throws SQLException, InterruptedException {
        DriverManager.setLoginTimeout(1);
        PoolProperties poolProperties = new DefaultProperties();
        int threadsCount = 3;
        poolProperties.setMaxActive(threadsCount);
        poolProperties.setMaxIdle(threadsCount);
        poolProperties.setMinIdle(0);
        poolProperties.setMaxWait(5000);
        poolProperties.setInitialSize(0);
        poolProperties.setRemoveAbandoned(true);
        poolProperties.setRemoveAbandonedTimeout(300);
        poolProperties.setRollbackOnReturn(true);
        poolProperties.setFairQueue(fairQueue);
        final DataSource ds = new DataSource(poolProperties);

        final CountDownLatch openedLatch = new CountDownLatch(threadsCount);
        final CountDownLatch closedLatch = new CountDownLatch(threadsCount);
        final CountDownLatch toCloseLatch = new CountDownLatch(1);
View Full Code Here

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

public class TestJdbcInterceptorConfigParsing {

    @Test
    public void testBasic() throws Exception {
        String interceptorConfig = "FirstInterceptor;SecondInterceptor(parm1=value1,parm2=value2)";
        PoolProperties props = new PoolProperties();
        props.setJdbcInterceptors(interceptorConfig);
        InterceptorDefinition[] interceptorDefs = props.getJdbcInterceptorsAsArray();
        assertNotNull(interceptorDefs);

        // 3 items because parser automatically inserts TrapException interceptor to front of list
        assertEquals(interceptorDefs.length, 3);
        assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());
View Full Code Here

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

    public void testWhitespace() throws Exception {
        String interceptorConfig = "FirstInterceptor ; \n" +
            "SecondInterceptor (parm1  = value1 , parm2= value2 ) ; \n\n" +
            "\t org.cyb.ThirdInterceptor(parm1=value1);  \n" +
            "EmptyParmValInterceptor(parm1=  )";
        PoolProperties props = new PoolProperties();
        props.setJdbcInterceptors(interceptorConfig);
        InterceptorDefinition[] interceptorDefs = props.getJdbcInterceptorsAsArray();
        assertNotNull(interceptorDefs);

        // 5 items because parser automatically inserts TrapException interceptor to front of list
        assertEquals(interceptorDefs.length, 5);
        assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());
View Full Code Here

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

     *
     * @throws Exception
     */
    @Test
    public void testExceptionOrNot() throws Exception {
        PoolProperties props = null;

        String[] exceptionInducingConfigs = {
            "EmptyParmsInterceptor()",
            "WhitespaceParmsInterceptor(   )"
        };
        for (String badConfig : exceptionInducingConfigs) {
            props = new PoolProperties();
            props.setJdbcInterceptors(badConfig);
            try {
                props.getJdbcInterceptorsAsArray();
                fail("Expected exception.");
            } catch (Exception e) {
                // Expected
            }
        }

        String[] noExceptionButInvalidConfigs = {
            "MalformedParmsInterceptor(=   )",
            "MalformedParmsInterceptor(  =)",
            "MalformedParmsInterceptor(",
            "MalformedParmsInterceptor( ",
            "MalformedParmsInterceptor)",
            "MalformedParmsInterceptor) ",
            "MalformedParmsInterceptor )"
        };
        for (String badConfig : noExceptionButInvalidConfigs) {
            props = new PoolProperties();
            props.setJdbcInterceptors(badConfig);
            try {
                props.getJdbcInterceptorsAsArray();
            } catch (Exception e) {
                fail("Unexpected exception.");
            }
        }
    }
View Full Code Here

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

    @Test
    public void textExtraSemicolonBehavior() {

        // This one DOES get an extra/empty definition
        PoolProperties props = new PoolProperties();
        props.setJdbcInterceptors(";EmptyLeadingSemiInterceptor");
        InterceptorDefinition[] jiDefs = props.getJdbcInterceptorsAsArray();
        assertNotNull(jiDefs);
        assertEquals(jiDefs.length, 3);

        // This one does NOT get an extra/empty definition (no trailing whitespace)
        props = new PoolProperties();
        props.setJdbcInterceptors("EmptyTrailingSemiInterceptor;");
        jiDefs = props.getJdbcInterceptorsAsArray();
        assertNotNull(jiDefs);
        assertEquals(jiDefs.length, 2);

        // This one DOES get an extra/empty definition (with trailing whitespace)
        props = new PoolProperties();
        props.setJdbcInterceptors("EmptyTrailingSemiInterceptor; ");
        jiDefs = props.getJdbcInterceptorsAsArray();
        assertNotNull(jiDefs);
        assertEquals(jiDefs.length, 3);
    }
View Full Code Here

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

    public Bug54227() {
    }

    @Test
    public void testPool() throws SQLException, InterruptedException {
        PoolProperties poolProperties = new DefaultProperties();
        poolProperties.setMinIdle(0);
        poolProperties.setInitialSize(0);
        poolProperties.setMaxActive(1);
        poolProperties.setMaxWait(5000);
        poolProperties.setMaxAge(100);
        poolProperties.setRemoveAbandoned(false);

        final DataSource ds = new DataSource(poolProperties);
        Connection con;
        Connection actual1;
        Connection actual2;
View Full Code Here

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

        });
    }

    @Test
    public void testPool() throws SQLException {
        PoolProperties poolProperties = new DefaultProperties();
        poolProperties.setMinIdle(0);
        poolProperties.setInitialSize(0);
        poolProperties.setMaxWait(5000);
        poolProperties.setRemoveAbandoned(true);
        poolProperties.setRemoveAbandonedTimeout(300);
        poolProperties.setRollbackOnReturn(true);
        poolProperties.setInitSQL(initSQL);
        final DataSource ds = new DataSource(poolProperties);
        ds.getConnection().close();
        assertNull(poolProperties.getInitSQL());
    }
View Full Code Here

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

public class Bug54978 {

    @Test
    public void testIllegalValidationQuery() {
        PoolProperties poolProperties = new DefaultProperties();
        poolProperties.setMinIdle(0);
        poolProperties.setInitialSize(1);
        poolProperties.setMaxActive(1);
        poolProperties.setMaxWait(5000);
        poolProperties.setMaxAge(100);
        poolProperties.setRemoveAbandoned(false);
        poolProperties.setTestOnBorrow(true);
        poolProperties.setTestOnConnect(false);
        poolProperties.setValidationQuery("sdadsada");
        final DataSource ds = new DataSource(poolProperties);
        try {
            ds.getConnection().close();
            fail("Validation should have failed.");
        }catch (SQLException x) {
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.