當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。