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