本文整理汇总了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();
}
示例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();
}