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.PreparedStatement;
10: import java.sql.Statement;
11:
12: import org.h2.test.TestBase;
13:
14: /**
15: * Tests the compatibility with other databases.
16: */
17: public class TestCompatibility extends TestBase {
18:
19: private Connection conn;
20:
21: public void test() throws Exception {
22: deleteDb("compatibility");
23: conn = getConnection("compatibility");
24:
25: testHsqlDb();
26: testMySQL();
27:
28: conn.close();
29:
30: }
31:
32: private void testHsqlDb() throws Exception {
33: Statement stat = conn.createStatement();
34: stat
35: .execute("DROP TABLE TEST IF EXISTS; CREATE TABLE TEST(ID INT PRIMARY KEY); ");
36: stat.execute("CALL CURRENT_TIME");
37: stat.execute("CALL CURRENT_TIMESTAMP");
38: stat.execute("CALL CURRENT_DATE");
39: stat.execute("CALL SYSDATE");
40: stat.execute("CALL TODAY");
41:
42: stat.execute("DROP TABLE TEST IF EXISTS");
43: stat.execute("CREATE TABLE TEST(ID INT)");
44: stat.execute("INSERT INTO TEST VALUES(1)");
45: PreparedStatement prep = conn
46: .prepareStatement("SELECT LIMIT ? 1 ID FROM TEST");
47: prep.setInt(1, 2);
48: prep.executeQuery();
49: stat.execute("DROP TABLE TEST IF EXISTS");
50:
51: }
52:
53: private void testMySQL() throws Exception {
54: Statement stat = conn.createStatement();
55: stat.execute("SELECT 1");
56: stat.execute("DROP TABLE IF EXISTS TEST");
57: stat.execute("CREATE TABLE TEST(ID INT, NAME VARCHAR)");
58: stat
59: .execute("INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World')");
60: }
61:
62: }
|