提交 dbb83a90 authored 作者: Thomas Mueller's avatar Thomas Mueller

Close all connections.

上级 97a79050
...@@ -325,7 +325,7 @@ public class TestLob extends TestBase { ...@@ -325,7 +325,7 @@ public class TestLob extends TestBase {
trace("shutdown immediately"); trace("shutdown immediately");
conn.createStatement().execute("SHUTDOWN IMMEDIATELY"); conn.createStatement().execute("SHUTDOWN IMMEDIATELY");
trace("shutdown done"); trace("shutdown done");
conn = reconnect(null); conn = reconnect(conn);
conn.setAutoCommit(false); conn.setAutoCommit(false);
sp = null; sp = null;
} }
...@@ -355,7 +355,7 @@ public class TestLob extends TestBase { ...@@ -355,7 +355,7 @@ public class TestLob extends TestBase {
conn.createStatement().execute("DELETE FROM TEST"); conn.createStatement().execute("DELETE FROM TEST");
conn.createStatement().execute("CHECKPOINT"); conn.createStatement().execute("CHECKPOINT");
conn.createStatement().execute("SHUTDOWN IMMEDIATELY"); conn.createStatement().execute("SHUTDOWN IMMEDIATELY");
conn = reconnect(null); conn = reconnect(conn);
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST"); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
assertTrue(rs.next()); assertTrue(rs.next());
rs.getInt(1); rs.getInt(1);
...@@ -403,8 +403,7 @@ public class TestLob extends TestBase { ...@@ -403,8 +403,7 @@ public class TestLob extends TestBase {
Statement stat0 = conn0.createStatement(); Statement stat0 = conn0.createStatement();
stat0.executeUpdate("drop table CLOB_ENTITY if exists"); stat0.executeUpdate("drop table CLOB_ENTITY if exists");
stat0.getWarnings(); stat0.getWarnings();
stat0 stat0.executeUpdate("create table CLOB_ENTITY (ID bigint not null, DATA clob, CLOB_DATA clob, primary key (ID))");
.executeUpdate("create table CLOB_ENTITY (ID bigint not null, DATA clob, CLOB_DATA clob, primary key (ID))");
stat0.getWarnings(); stat0.getWarnings();
stat0.close(); stat0.close();
conn0.getWarnings(); conn0.getWarnings();
...@@ -651,7 +650,11 @@ public class TestLob extends TestBase { ...@@ -651,7 +650,11 @@ public class TestLob extends TestBase {
private Connection reconnect(Connection conn) throws SQLException { private Connection reconnect(Connection conn) throws SQLException {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (conn != null) { if (conn != null) {
conn.close(); try {
conn.close();
} catch (SQLException e) {
// ignore
}
} }
conn = getConnection("lob"); conn = getConnection("lob");
trace("re-connect=" + (System.currentTimeMillis() - time)); trace("re-connect=" + (System.currentTimeMillis() - time));
......
...@@ -51,8 +51,17 @@ public class TestOutOfMemory extends TestBase { ...@@ -51,8 +51,17 @@ public class TestOutOfMemory extends TestBase {
fail(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertEquals(ErrorCode.OUT_OF_MEMORY, e.getErrorCode()); assertEquals(ErrorCode.OUT_OF_MEMORY, e.getErrorCode());
try {
conn.close();
fail();
} catch (SQLException e2) {
assertEquals(ErrorCode.DATABASE_IS_CLOSED, e2.getErrorCode());
}
} }
freeMemory(); freeMemory();
conn = null;
conn = getConnection("outOfMemory");
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select count(*) from stuff"); ResultSet rs = stat.executeQuery("select count(*) from stuff");
rs.next(); rs.next();
assertEquals(3000, rs.getInt(1)); assertEquals(3000, rs.getInt(1));
......
...@@ -189,6 +189,11 @@ public class TestPowerOff extends TestBase { ...@@ -189,6 +189,11 @@ public class TestPowerOff extends TestBase {
} }
assertTrue(deleted); assertTrue(deleted);
} }
try {
conn.close();
} catch (SQLException e) {
// ignore
}
conn = getConnection(url); conn = getConnection(url);
conn.close(); conn.close();
} }
...@@ -215,6 +220,11 @@ public class TestPowerOff extends TestBase { ...@@ -215,6 +220,11 @@ public class TestPowerOff extends TestBase {
} }
((JdbcConnection) conn).setPowerOffCount(0); ((JdbcConnection) conn).setPowerOffCount(0);
try {
conn.close();
} catch (SQLException e) {
// ignore
}
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT COUNT(*) FROM TEST"); ResultSet rs = stat.executeQuery("SELECT COUNT(*) FROM TEST");
...@@ -290,7 +300,7 @@ public class TestPowerOff extends TestBase { ...@@ -290,7 +300,7 @@ public class TestPowerOff extends TestBase {
} }
conn.close(); conn.close();
} catch (SQLException e) { } catch (SQLException e) {
if (e.getSQLState().equals("" + ErrorCode.SIMULATED_POWER_OFF)) { if (e.getSQLState().equals("" + ErrorCode.DATABASE_IS_CLOSED)) {
// this is ok // this is ok
} else { } else {
throw e; throw e;
......
...@@ -40,6 +40,8 @@ public class AliasMapTest extends TestBase { ...@@ -40,6 +40,8 @@ public class AliasMapTest extends TestBase {
.orderBy(p.productId).select(); .orderBy(p.productId).select();
assertEquals("[]", products.toString()); assertEquals("[]", products.toString());
db.close();
} }
} }
...@@ -50,6 +50,7 @@ public class TestConnectionPool extends TestBase { ...@@ -50,6 +50,7 @@ public class TestConnectionPool extends TestBase {
Connection conn2 = man.getConnection(); Connection conn2 = man.getConnection();
assertTrue(conn2.getAutoCommit()); assertTrue(conn2.getAutoCommit());
conn2.close();
man.dispose(); man.dispose();
} }
......
...@@ -76,6 +76,7 @@ public class TestXA extends TestBase { ...@@ -76,6 +76,7 @@ public class TestXA extends TestBase {
Connection c = xa.getConnection(); Connection c = xa.getConnection();
assertTrue(!c.getAutoCommit()); assertTrue(!c.getAutoCommit());
c.close(); c.close();
xa.close();
} }
private void testXA(boolean useOneDatabase) { private void testXA(boolean useOneDatabase) {
......
...@@ -213,6 +213,12 @@ public class TestFileLockSerialized extends TestBase { ...@@ -213,6 +213,12 @@ public class TestFileLockSerialized extends TestBase {
printResult(stat2, "select * from test"); printResult(stat2, "select * from test");
conn2.close(); conn2.close();
try {
conn.close();
} catch (SQLException e) {
// ignore
}
} }
private void testConcurrentReadWrite() throws Exception { private void testConcurrentReadWrite() throws Exception {
......
...@@ -518,6 +518,11 @@ public class TestTools extends TestBase { ...@@ -518,6 +518,11 @@ public class TestTools extends TestBase {
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try {
conn.close();
} catch (SQLException e) {
// ignore
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论