org.apache.tomcat.jdbc.pool.ConnectionPool Java Examples

The following examples show how to use org.apache.tomcat.jdbc.pool.ConnectionPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResetAbandonedTimer.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (con == null) {
        this.pcon = null;
        if (oname != null) {
            JmxUtil.unregisterJmx(oname);
            oname = null;
        }
    } else {
        this.pcon = con;
        if (oname == null) {
            String keyprop = ",JdbcInterceptor=" + getClass().getSimpleName();
            oname = JmxUtil.registerJmx(pcon.getObjectName(), keyprop, this);
        }
    }
}
 
Example #2
Source File: JmxPasswordTest.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.datasource.setDriverClassName(Driver.class.getName());
    this.datasource.setUrl("jdbc:tomcat:test");
    this.datasource.setPassword(password);
    this.datasource.setUsername(username);
    this.datasource.getConnection().close();
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    String domain = "tomcat.jdbc";
    Hashtable<String,String> properties = new Hashtable<>();
    properties.put("type", "ConnectionPool");
    properties.put("class", this.getClass().getName());
    oname = new ObjectName(domain,properties);
    ConnectionPool pool = datasource.createPool();
    org.apache.tomcat.jdbc.pool.jmx.ConnectionPool jmxPool = new org.apache.tomcat.jdbc.pool.jmx.ConnectionPool(pool);
    mbs.registerMBean(jmxPool, oname);

}
 
Example #3
Source File: DefaultConnectionState.java    From dal with Apache License 2.0 6 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    if (parent == null || con == null)
        return;

    try {
        boolean firstTime = isFirstTime.get();
        if (!firstTime)
            return;

        isFirstTime.set(false);
        String connectionName = con.toString();
        String url = con.getPoolProperties().getUrl();
        String poolName = parent.getName();
        String info = String.format("%s of url %s has been created for the first time,connection pool name:%s.",
                connectionName, url, poolName);
        logger.info(info);
    } catch (Throwable e) {
    }
}
 
Example #4
Source File: PayloadInterceptor.java    From jqm with Apache License 2.0 6 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con)
{
    trackedConnPool = parent;
    trackedPooledCon = con;

    if (parent != null && con != null)
    {
        ConnPair cp = new ConnPair();
        cp.conn = con;
        cp.thread = Thread.currentThread();
        Set<ConnPair> pairs = conns.get(parent);
        if (pairs != null)
        {
            conns.get(parent).add(cp);
        }
    }
}
 
Example #5
Source File: PoolCleanerTest.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testPoolCleaner() throws Exception {
    datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
    datasource.getPoolProperties().setTestWhileIdle(true);
    Assert.assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());

    datasource.getConnection().close();
    Assert.assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());

    datasource.close();
    Assert.assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());


}
 
Example #6
Source File: TestSlowQueryReport.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testFailedSql() throws Exception {
    int count = 3;
    Connection con = this.datasource.getConnection();
    for (int i=0; i<count; i++) {
        Statement st = con.createStatement();
        try {
            ResultSet rs = st.executeQuery(failedSql);
            rs.close();
        }catch (Exception x) {
            // NO-OP
        }
        st.close();
    }
    Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName());
    Assert.assertNotNull(map);
    Assert.assertEquals(1,map.size());
    ConnectionPool pool = datasource.getPool();
    String key = map.keySet().iterator().next();
    SlowQueryReport.QueryStats stats = map.get(key);
    System.out.println("Stats:"+stats);
    con.close();
    tearDown();
    Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName()));
}
 
Example #7
Source File: TestSlowQueryReport.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testFastSql() throws Exception {
    int count = 3;
    Connection con = this.datasource.getConnection();
    String fastSql = this.datasource.getValidationQuery();
    for (int i=0; i<count; i++) {
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery(fastSql);
        rs.close();
        st.close();
    }
    Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName());
    Assert.assertNotNull(map);
    Assert.assertEquals(1,map.size());
    ConnectionPool pool = datasource.getPool();
    con.close();
    tearDown();
    Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName()));
}
 
Example #8
Source File: PayloadInterceptor.java    From jqm with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the engine to trigger the cleanup at the end of a payload thread.
 */
public static int forceCleanup(Thread t)
{
    int i = 0;
    for (Map.Entry<ConnectionPool, Set<ConnPair>> e : conns.entrySet())
    {
        for (ConnPair c : e.getValue())
        {
            if (c.thread.equals(t))
            {
                try
                {
                    // This will in turn remove it from the static Map.
                    c.conn.getHandler().invoke(c.conn, Connection.class.getMethod("close"), null);
                }
                catch (Throwable e1)
                {
                    e1.printStackTrace();
                }
                i++;
            }
        }
    }
    return i;
}
 
Example #9
Source File: TomcatJdbcDataSourceFactoryTest.java    From spring-cloud-aws with Apache License 2.0 6 votes vote down vote up
@Test
void testCloseDataSource() throws Exception {
	TomcatJdbcDataSourceFactory tomcatJdbcDataSourceFactory = new TomcatJdbcDataSourceFactory();
	tomcatJdbcDataSourceFactory.setInitialSize(0);

	DataSourceInformation dataSourceInformation = new DataSourceInformation(
			DatabaseType.MYSQL, "localhost", 3306, "test", "user", "password");
	DataSource dataSource = tomcatJdbcDataSourceFactory
			.createDataSource(dataSourceInformation);
	assertThat(dataSource).isNotNull();

	ConnectionPool pool = dataSource.createPool();
	assertThat(pool.isClosed()).isFalse();
	tomcatJdbcDataSourceFactory.closeDataSource(dataSource);
	assertThat(pool.isClosed()).isTrue();
}
 
Example #10
Source File: JmxPasswordTest.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.datasource.setDriverClassName(Driver.class.getName());
    this.datasource.setUrl("jdbc:tomcat:test");
    this.datasource.setPassword(password);
    this.datasource.setUsername(username);
    this.datasource.getConnection().close();
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    String domain = "tomcat.jdbc";
    Hashtable<String,String> properties = new Hashtable<String,String>();
    properties.put("type", "ConnectionPool");
    properties.put("class", this.getClass().getName());
    oname = new ObjectName(domain,properties);
    ConnectionPool pool = datasource.createPool();
    org.apache.tomcat.jdbc.pool.jmx.ConnectionPool jmxPool = new org.apache.tomcat.jdbc.pool.jmx.ConnectionPool(pool);
    mbs.registerMBean(jmxPool, oname);

}
 
Example #11
Source File: PoolCleanerTest.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void test2PoolCleaners() throws Exception {
    datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
    datasource.getPoolProperties().setTestWhileIdle(true);

    DataSource ds2 = new DataSource(datasource.getPoolProperties());

    Assert.assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());

    datasource.getConnection().close();
    ds2.getConnection().close();
    Assert.assertEquals("Pool cleaner should have 2 cleaner.",2,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());

    datasource.close();
    Assert.assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());

    ds2.close();
    Assert.assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());
}
 
Example #12
Source File: TestSlowQueryReport.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testFastSql() throws Exception {
    int count = 3;
    this.init();
    this.datasource.setMaxActive(1);
    this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName());
    Connection con = this.datasource.getConnection();
    String fastSql = this.datasource.getValidationQuery();
    for (int i=0; i<count; i++) {
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery(fastSql);
        rs.close();
        st.close();
    }
    Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName());
    Assert.assertNotNull(map);
    Assert.assertEquals(0,map.size());
    ConnectionPool pool = datasource.getPool();
    con.close();
    tearDown();
    Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName()));
}
 
Example #13
Source File: PoolCleanerTest.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testPoolCleaner() throws Exception {
    datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
    datasource.getPoolProperties().setTestWhileIdle(true);
    Assert.assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());

    datasource.getConnection().close();
    Assert.assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());

    datasource.close();
    Assert.assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());


}
 
Example #14
Source File: SlowQueryReport.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void poolStarted(ConnectionPool pool) {
    super.poolStarted(pool);
    //see if we already created a map for this pool
    queries = SlowQueryReport.perPoolStats.get(pool.getName());
    if (queries==null) {
        //create the map to hold our stats
        //however TODO we need to improve the eviction
        //selection
        queries = new ConcurrentHashMap<>();
        if (perPoolStats.putIfAbsent(pool.getName(), queries)!=null) {
            //there already was one
            queries = SlowQueryReport.perPoolStats.get(pool.getName());
        }
    }
}
 
Example #15
Source File: TestSlowQueryReport.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testFastSql() throws Exception {
    int count = 3;
    this.init();
    this.datasource.setMaxActive(1);
    this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName());
    Connection con = this.datasource.getConnection();
    String fastSql = this.datasource.getValidationQuery();
    for (int i=0; i<count; i++) {
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery(fastSql);
        rs.close();
        st.close();
    }
    Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName());
    Assert.assertNotNull(map);
    Assert.assertEquals(0,map.size());
    ConnectionPool pool = datasource.getPool();
    con.close();
    tearDown();
    Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName()));
}
 
Example #16
Source File: StatementCache.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent==null) {
        cacheSize = null;
        this.pcon = null;
        if (oname != null) {
            JmxUtil.unregisterJmx(oname);
            oname = null;
        }
    } else {
        cacheSize = cacheSizeMap.get(parent);
        this.pcon = con;
        if (!pcon.getAttributes().containsKey(STATEMENT_CACHE_ATTR)) {
            ConcurrentHashMap<CacheKey,CachedStatement> cache =
                    new ConcurrentHashMap<>();
            pcon.getAttributes().put(STATEMENT_CACHE_ATTR,cache);
        }
        if (oname == null) {
            String keyprop = ",JdbcInterceptor=" + getClass().getSimpleName();
            oname = JmxUtil.registerJmx(pcon.getObjectName(), keyprop, this);
        }
    }
}
 
Example #17
Source File: JmxPasswordTest.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.datasource.setDriverClassName(Driver.class.getName());
    this.datasource.setUrl("jdbc:tomcat:test");
    this.datasource.setPassword(password);
    this.datasource.setUsername(username);
    this.datasource.getConnection().close();
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    String domain = "tomcat.jdbc";
    Hashtable<String,String> properties = new Hashtable<String,String>();
    properties.put("type", "ConnectionPool");
    properties.put("class", this.getClass().getName());
    oname = new ObjectName(domain,properties);
    ConnectionPool pool = datasource.createPool();
    org.apache.tomcat.jdbc.pool.jmx.ConnectionPool jmxPool = new org.apache.tomcat.jdbc.pool.jmx.ConnectionPool(pool);
    mbs.registerMBean(jmxPool, oname);

}
 
Example #18
Source File: SlowQueryReport.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void poolStarted(ConnectionPool pool) {
    super.poolStarted(pool);
    //see if we already created a map for this pool
    queries = SlowQueryReport.perPoolStats.get(pool.getName());
    if (queries==null) {
        //create the map to hold our stats
        //however TODO we need to improve the eviction
        //selection
        queries = new ConcurrentHashMap<String,QueryStats>();
        if (perPoolStats.putIfAbsent(pool.getName(), queries)!=null) {
            //there already was one
            queries = SlowQueryReport.perPoolStats.get(pool.getName());
        }
    }
}
 
Example #19
Source File: PoolCleanerTest.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void test2PoolCleaners() throws Exception {
    datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
    datasource.getPoolProperties().setTestWhileIdle(true);

    DataSource ds2 = new DataSource(datasource.getPoolProperties());

    Assert.assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());

    datasource.getConnection().close();
    ds2.getConnection().close();
    Assert.assertEquals("Pool cleaner should have 2 cleaner.",2,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());

    datasource.close();
    Assert.assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());

    ds2.close();
    Assert.assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
    Assert.assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
    Assert.assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());
}
 
Example #20
Source File: DalTomcatDataSource.java    From dal with Apache License 2.0 5 votes vote down vote up
private synchronized ConnectionPool pCreatePool() throws SQLException {
    if (pool != null) {
        return pool;
    } else {
        pool = new DalConnectionPool(poolProperties);
        return pool;
    }
}
 
Example #21
Source File: TestSlowQueryReport.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailedSql() throws Exception {
    int count = 3;
    this.init();
    this.datasource.setMaxActive(1);
    this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName());
    Connection con = this.datasource.getConnection();
    String slowSql = "select 1 from non_existent";
    for (int i=0; i<count; i++) {
        Statement st = con.createStatement();
        try {
            ResultSet rs = st.executeQuery(slowSql);
            rs.close();
        }catch (Exception x) {
            // NO-OP
        }
        st.close();

    }
    Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName());
    Assert.assertNotNull(map);
    Assert.assertEquals(1,map.size());
    ConnectionPool pool = datasource.getPool();
    String key = map.keySet().iterator().next();
    SlowQueryReport.QueryStats stats = map.get(key);
    System.out.println("Stats:"+stats);
    con.close();
    tearDown();
    Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName()));
}
 
Example #22
Source File: TestSlowQueryReport.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailedSql() throws Exception {
    int count = 3;
    this.init();
    this.datasource.setMaxActive(1);
    this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName());
    Connection con = this.datasource.getConnection();
    String slowSql = "select 1 from non_existent";
    for (int i=0; i<count; i++) {
        Statement st = con.createStatement();
        try {
            ResultSet rs = st.executeQuery(slowSql);
            rs.close();
        }catch (Exception x) {
            // NO-OP
        }
        st.close();

    }
    Map<String,SlowQueryReport.QueryStats> map = SlowQueryReport.getPoolStats(datasource.getPool().getName());
    Assert.assertNotNull(map);
    Assert.assertEquals(1,map.size());
    ConnectionPool pool = datasource.getPool();
    String key = map.keySet().iterator().next();
    SlowQueryReport.QueryStats stats = map.get(key);
    System.out.println("Stats:"+stats);
    con.close();
    tearDown();
    Assert.assertNull(SlowQueryReport.getPoolStats(pool.getName()));
}
 
Example #23
Source File: TomEEDataSourceCreator.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionPool createPool() throws SQLException {
    if (pool != null) {
        return pool;
    } else {
        pool = new TomEEConnectionPool(poolProperties, Thread.currentThread().getContextClassLoader()); // to force to init the driver with TCCL
        return pool;
    }
}
 
Example #24
Source File: SlowQueryReportJmx.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent!=null) {
        poolName = parent.getName();
        pool = parent;
        registerJmx();
    }
}
 
Example #25
Source File: MockedTomcatJdbcConnection.java    From liquibase-percona with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a mocked SQL connection, that looks like a tomcat-jdbc pooled connection.
 * @param username the username to use
 * @param password the password to use
 * @return the connection
 * @throws SQLException
 */
public static Connection create(String username, String password) throws SQLException {
    PoolProperties poolProps = new PoolProperties();
    poolProps.setUsername(username);
    poolProps.setPassword(password);
    poolProps.setDataSource(new MockDataSource());
    ConnectionPool pool = new ConnectionPool(poolProps);
    PooledConnection pooledConnection = new PooledConnection(poolProps, pool);
    pooledConnection.connect();
    ProxyConnection proxyConnection = new ProxyConnection(null, pooledConnection, true) {};
    DisposableConnectionFacade invocationHandler = new DisposableConnectionFacade(proxyConnection) {};
    Connection connection = (Connection) Proxy.newProxyInstance(DisposableConnectionFacade.class.getClassLoader(), new Class[] {Connection.class}, invocationHandler);
    return connection;
}
 
Example #26
Source File: SlowQueryReportJmx.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent!=null) {
        poolName = parent.getName();
        pool = parent;
        registerJmx();
    }
}
 
Example #27
Source File: StatementCache.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent==null) {
        cacheSize = null;
        this.pcon = null;
    } else {
        cacheSize = cacheSizeMap.get(parent);
        this.pcon = con;
        if (!pcon.getAttributes().containsKey(STATEMENT_CACHE_ATTR)) {
            ConcurrentHashMap<String,CachedStatement> cache = new ConcurrentHashMap<String, CachedStatement>();
            pcon.getAttributes().put(STATEMENT_CACHE_ATTR,cache);
        }
    }
}
 
Example #28
Source File: DefaultConnectionState.java    From dal with Apache License 2.0 5 votes vote down vote up
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
    if (parent == null || con == null)
        return;

    try {
        String connectionName = con.toString();
        String url = con.getPoolProperties().getUrl();
        String poolName = parent.getName();
        String info = String.format("%s of url %s has been destroyed,connection pool name:%s.", connectionName, url,
                poolName);
        logger.info(info);
    } catch (Throwable e) {
    }
}
 
Example #29
Source File: SlowQueryReportJmx.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent!=null) {
        poolName = parent.getName();
        pool = parent;
        registerJmx();
    }
}
 
Example #30
Source File: ConnectionState.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
    //we are resetting, reset our defaults
    autoCommit = null;
    transactionIsolation = null;
    readOnly = null;
    catalog = null;
    super.disconnected(parent, con, finalizing);
}