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

The following examples show how to use org.apache.tomcat.jdbc.pool.ProxyConnection. 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 Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public boolean resetTimer() {
    boolean result = false;
    JdbcInterceptor interceptor = this.getNext();
    while (interceptor!=null && result==false) {
        if (interceptor instanceof ProxyConnection) {
            PooledConnection con = ((ProxyConnection)interceptor).getConnection();
            if (con!=null) {
                con.setTimestamp(System.currentTimeMillis());
                result = true;
            } else {
                break;
            }
        }
        interceptor = interceptor.getNext();
    }
    return result;
}
 
Example #2
Source File: ResetAbandonedTimer.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
public boolean resetTimer() {
    boolean result = false;
    JdbcInterceptor interceptor = this.getNext();
    while (interceptor!=null && result==false) {
        if (interceptor instanceof ProxyConnection) {
            PooledConnection con = ((ProxyConnection)interceptor).getConnection();
            if (con!=null) {
                con.setTimestamp(System.currentTimeMillis());
                result = true;
            } else {
                break;
            }
        }
        interceptor = interceptor.getNext();
    }
    return result;
}
 
Example #3
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;
}