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


Java PooledConnection类代码示例

本文整理汇总了Java中org.apache.tomcat.jdbc.pool.PooledConnection的典型用法代码示例。如果您正苦于以下问题:Java PooledConnection类的具体用法?Java PooledConnection怎么用?Java PooledConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: disconnected

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
    @SuppressWarnings("unchecked")
    ConcurrentHashMap<CacheKey,CachedStatement> statements =
        (ConcurrentHashMap<CacheKey,CachedStatement>)con.getAttributes().get(STATEMENT_CACHE_ATTR);

    if (statements!=null) {
        for (Map.Entry<CacheKey, CachedStatement> p : statements.entrySet()) {
            closeStatement(p.getValue());
        }
        statements.clear();
    }

    super.disconnected(parent, con, finalizing);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:StatementCache.java

示例2: resetTimer

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:ResetAbandonedTimer.java

示例3: testSuspect

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Test
public void testSuspect() throws Exception {
    this.datasource.setMaxActive(100);
    this.datasource.setMaxIdle(100);
    this.datasource.setInitialSize(0);
    this.datasource.getPoolProperties().setAbandonWhenPercentageFull(0);
    this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(100);
    this.datasource.getPoolProperties().setRemoveAbandoned(true);
    this.datasource.getPoolProperties().setRemoveAbandonedTimeout(100);
    this.datasource.getPoolProperties().setSuspectTimeout(1);
    this.datasource.getPoolProperties().setLogAbandoned(true);
    Connection con = datasource.getConnection();
    Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
    Thread.sleep(3000);
    PooledConnection pcon = con.unwrap(PooledConnection.class);
    Assert.assertTrue("Connection should be marked suspect",pcon.isSuspect());
    con.close();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestSuspectTimeout.java

示例4: testCleanupCloseConnectionNegative

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Test
public void testCleanupCloseConnectionNegative() {
	try {
		TestConnectionAction test = new TestConnectionAction();
		DalConnection connHolder = getDalConnection();
		test.connHolder = connHolder;
		test.statement = test.connHolder.getConn().createStatement();
		test.rs = test.statement.executeQuery("select * from " + SqlServerTestInitializer.TABLE_NAME);
		test.rs.next();
		PooledConnection c = (PooledConnection)connHolder.getConn().unwrap(PooledConnection.class);
		connHolder.error(new NullPointerException("0800"));

		test.cleanup();
		assertTrue(!c.isDiscarded());
		assertTrue(!c.isReleased());
		assertNotNull(test);
		assertTrue(test.conn == null);
		assertTrue(test.statement == null);
		assertTrue(test.rs == null);
		assertTrue(test.connHolder == null);
	} catch (Exception ex) {
		ex.printStackTrace();
		fail("There should be no exception here");
	}
}
 
开发者ID:ctripcorp,项目名称:dal,代码行数:26,代码来源:ConnectionActionTest.java

示例5: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:enioka,项目名称:jqm,代码行数:19,代码来源:PayloadInterceptor.java

示例6: testSuspect

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
public void testSuspect() throws Exception {
    this.init();
    this.datasource.setMaxActive(100);
    this.datasource.setMaxIdle(100);
    this.datasource.setInitialSize(0);
    this.datasource.getPoolProperties().setAbandonWhenPercentageFull(0);
    this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(100);
    this.datasource.getPoolProperties().setRemoveAbandoned(true);
    this.datasource.getPoolProperties().setRemoveAbandonedTimeout(100);
    this.datasource.getPoolProperties().setSuspectTimeout(1);
    this.datasource.getPoolProperties().setLogAbandoned(true);
    Connection con = datasource.getConnection();
    assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
    Thread.sleep(3000);
    PooledConnection pcon = con.unwrap(PooledConnection.class);
    assertTrue("Connection should be marked suspect",pcon.isSuspect());
    con.close();
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:19,代码来源:TestSuspectTimeout.java

示例7: create

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
protected PooledConnection create(final boolean incrementCounter) {
    final PooledConnection con = super.create(incrementCounter);
    if (getPoolProperties().getDataSource() == null) { // using driver
        // init driver with TCCL
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if (cl == null) {
            cl = TomEEConnectionPool.class.getClassLoader();
        }
        try {
            Reflections.set(con, "driver", Class.forName(getPoolProperties().getDriverClassName(), true, cl).newInstance());
        } catch (final ClassNotFoundException cnfe) {
            try { // custom resource classloader
                Reflections.set(con, "driver", Class.forName(getPoolProperties().getDriverClassName(), true, creationLoader).newInstance());
            } catch (final Exception e) {
                // will fail later, no worry
            }
        } catch (final Exception cn) {
            // will fail later, no worry
        }
    }
    return con;
}
 
开发者ID:apache,项目名称:tomee,代码行数:24,代码来源:TomEEDataSourceCreator.java

示例8: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent!=null) {
        poolName = parent.getName();
        pool = parent;
        registerJmx();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:SlowQueryReportJmx.java

示例9: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@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<CacheKey,CachedStatement> cache = new ConcurrentHashMap<CacheKey, CachedStatement>();
            pcon.getAttributes().put(STATEMENT_CACHE_ATTR,cache);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:StatementCache.java

示例10: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    super.reset(parent, con);
    if (parent!=null)
        queries = SlowQueryReport.perPoolStats.get(parent.getName());
    else
        queries = null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:SlowQueryReport.java

示例11: disconnected

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@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);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:ConnectionState.java

示例12: create

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:adangel,项目名称:liquibase-percona,代码行数:21,代码来源:MockedTomcatJdbcConnection.java

示例13: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    // TODO Auto-generated method stub
    super.reset(parent, con);
    if (parent!=null) {
        poolName = parent.getName();
        pool = parent;
        registerJmx();
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:SlowQueryReportJmx.java

示例14: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:StatementCache.java

示例15: disconnected

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
    @SuppressWarnings("unchecked")
    ConcurrentHashMap<String,CachedStatement> statements =
        (ConcurrentHashMap<String,CachedStatement>)con.getAttributes().get(STATEMENT_CACHE_ATTR);

    if (statements!=null) {
        for (Map.Entry<String, CachedStatement> p : statements.entrySet()) {
            closeStatement(p.getValue());
        }
        statements.clear();
    }

    super.disconnected(parent, con, finalizing);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:StatementCache.java


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