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


Java JdbcConnectionPool.setLogWriter方法代码示例

本文整理汇总了Java中org.h2.jdbcx.JdbcConnectionPool.setLogWriter方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcConnectionPool.setLogWriter方法的具体用法?Java JdbcConnectionPool.setLogWriter怎么用?Java JdbcConnectionPool.setLogWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.jdbcx.JdbcConnectionPool的用法示例。


在下文中一共展示了JdbcConnectionPool.setLogWriter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testShutdown

import org.h2.jdbcx.JdbcConnectionPool; //导入方法依赖的package包/类
private void testShutdown() throws SQLException {
    String url = getURL("connectionPool2", true), user = getUser();
    String password = getPassword();
    JdbcConnectionPool cp = JdbcConnectionPool.create(url, user, password);
    StringWriter w = new StringWriter();
    cp.setLogWriter(new PrintWriter(w));
    Connection conn1 = cp.getConnection();
    Connection conn2 = cp.getConnection();
    conn1.close();
    conn2.createStatement().execute("shutdown immediately");
    cp.dispose();
    assertTrue(w.toString().length() > 0);
    cp.dispose();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:TestConnectionPool.java

示例2: testUncommittedTransaction

import org.h2.jdbcx.JdbcConnectionPool; //导入方法依赖的package包/类
private void testUncommittedTransaction() throws SQLException {
    String url = getURL("connectionPool", true), user = getUser();
    String password = getPassword();
    JdbcConnectionPool man = JdbcConnectionPool.create(url, user, password);

    assertEquals(30, man.getLoginTimeout());
    man.setLoginTimeout(1);
    assertEquals(1, man.getLoginTimeout());
    man.setLoginTimeout(0);
    assertEquals(30, man.getLoginTimeout());
    assertEquals(10, man.getMaxConnections());

    PrintWriter old = man.getLogWriter();
    PrintWriter pw = new PrintWriter(new StringWriter());
    man.setLogWriter(pw);
    assertTrue(pw == man.getLogWriter());
    man.setLogWriter(old);

    Connection conn1 = man.getConnection();
    assertTrue(conn1.getAutoCommit());
    conn1.setAutoCommit(false);
    conn1.close();
    assertTrue(conn1.isClosed());

    Connection conn2 = man.getConnection();
    assertTrue(conn2.getAutoCommit());
    conn2.close();

    man.dispose();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:TestConnectionPool.java


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