01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (license2)
04: * Initial Developer: H2 Group
05: */
06: package org.h2.test.db;
07:
08: import java.sql.Connection;
09: import java.sql.Statement;
10:
11: import org.h2.test.TestBase;
12:
13: /**
14: * Tests the CHECKPOINT SQL statement.
15: */
16: public class TestCheckpoint extends TestBase {
17:
18: public void test() throws Exception {
19: // TODO test checkpoint with rollback, not only just run the command
20: deleteDb("checkpoint");
21: Connection c0 = getConnection("checkpoint");
22: Statement s0 = c0.createStatement();
23: Connection c1 = getConnection("checkpoint");
24: Statement s1 = c1.createStatement();
25: s1
26: .execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
27: s1.execute("INSERT INTO TEST VALUES(1, 'Hello')");
28: s0.execute("CHECKPOINT");
29:
30: s1.execute("INSERT INTO TEST VALUES(2, 'World')");
31: c1.setAutoCommit(false);
32: s1.execute("INSERT INTO TEST VALUES(3, 'Maybe')");
33: s0.execute("CHECKPOINT");
34:
35: s1.execute("INSERT INTO TEST VALUES(4, 'Or not')");
36: s0.execute("CHECKPOINT");
37:
38: s1.execute("INSERT INTO TEST VALUES(5, 'ok yes')");
39: s1.execute("COMMIT");
40: s0.execute("CHECKPOINT");
41:
42: c0.close();
43: c1.close();
44: }
45:
46: }
|