• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PooledConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: disconnected

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing)
{
    for (ConnPair cp : conns.get(parent))
    {
        if (cp.conn.equals(con))
        {
            conns.get(parent).remove(cp);
        }
    }
    super.disconnected(parent, con, finalizing);
}
 
开发者ID:enioka,项目名称:jqm,代码行数:13,代码来源:PayloadInterceptor.java


示例17: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void reset(ConnectionPool parent, PooledConnection con)
{
    if (con == null)
    {
        return;
    }

    if (con.getConnection().getClass().toString().contains("racle"))
    {
        try
        {
            String[] names = Thread.currentThread().getName().split(";");

            String module = "'" + names[0] + "'";
            String action = names.length > 1 ? "'" + names[1] + "'" : "NULL";
            String clientInfo = names.length > 2 ? "'" + names[2] + "'" : "NULL";

            Statement s = con.getConnection().createStatement();
            s.execute("CALL DBMS_APPLICATION_INFO.SET_MODULE(" + module + ", " + action + ")");
            s.execute("CALL DBMS_APPLICATION_INFO.SET_CLIENT_INFO(" + clientInfo + ")");
            s.close();
        }
        catch (SQLException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}
 
开发者ID:enioka,项目名称:jqm,代码行数:32,代码来源:Interceptor.java


示例18: disconnected

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
    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:WhiteBearSolutions,项目名称:WBSAirback,代码行数:15,代码来源:StatementCache.java


示例19: reset

import org.apache.tomcat.jdbc.pool.PooledConnection; //导入依赖的package包/类
/**
 * no-op for this interceptor. no state is stored.
 */
@Override
public void reset(ConnectionPool parent, PooledConnection con) {
    // NOOP
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:8,代码来源:AbstractCreateStatementInterceptor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CorefMention类代码示例发布时间:2022-05-21
下一篇:
Java EntryTransformer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap