Search in sources :

Example 21 with Sequence

use of org.h2.schema.Sequence in project h2database by h2database.

the class JdbcDatabaseMetaData method getCrossReference.

/**
 * Gets the list of foreign key columns that references a table, as well as
 * the list of primary key columns that are references by a table. The
 * result set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME,
 * FK_NAME, KEY_SEQ.
 *
 * <ol>
 * <li>PKTABLE_CAT (String) primary catalog</li>
 * <li>PKTABLE_SCHEM (String) primary schema</li>
 * <li>PKTABLE_NAME (String) primary table</li>
 * <li>PKCOLUMN_NAME (String) primary column</li>
 * <li>FKTABLE_CAT (String) foreign catalog</li>
 * <li>FKTABLE_SCHEM (String) foreign schema</li>
 * <li>FKTABLE_NAME (String) foreign table</li>
 * <li>FKCOLUMN_NAME (String) foreign column</li>
 * <li>KEY_SEQ (short) sequence number (1,2,...)</li>
 * <li>UPDATE_RULE (short) action on update (see
 * DatabaseMetaData.importedKey...)</li>
 * <li>DELETE_RULE (short) action on delete (see
 * DatabaseMetaData.importedKey...)</li>
 * <li>FK_NAME (String) foreign key name</li>
 * <li>PK_NAME (String) primary key name</li>
 * <li>DEFERRABILITY (short) deferrable or not (always
 * importedKeyNotDeferrable)</li>
 * </ol>
 *
 * @param primaryCatalogPattern null or the catalog name
 * @param primarySchemaPattern the schema name of the primary table
 *          (optional)
 * @param primaryTable the name of the primary table (must be specified)
 * @param foreignCatalogPattern null or the catalog name
 * @param foreignSchemaPattern the schema name of the foreign table
 *          (optional)
 * @param foreignTable the name of the foreign table (must be specified)
 * @return the result set
 * @throws SQLException if the connection is closed
 */
@Override
public ResultSet getCrossReference(String primaryCatalogPattern, String primarySchemaPattern, String primaryTable, String foreignCatalogPattern, String foreignSchemaPattern, String foreignTable) throws SQLException {
    try {
        if (isDebugEnabled()) {
            debugCode("getCrossReference(" + quote(primaryCatalogPattern) + ", " + quote(primarySchemaPattern) + ", " + quote(primaryTable) + ", " + quote(foreignCatalogPattern) + ", " + quote(foreignSchemaPattern) + ", " + quote(foreignTable) + ");");
        }
        checkClosed();
        PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "PKTABLE_CATALOG PKTABLE_CAT, " + "PKTABLE_SCHEMA PKTABLE_SCHEM, " + "PKTABLE_NAME PKTABLE_NAME, " + "PKCOLUMN_NAME, " + "FKTABLE_CATALOG FKTABLE_CAT, " + "FKTABLE_SCHEMA FKTABLE_SCHEM, " + "FKTABLE_NAME, " + "FKCOLUMN_NAME, " + "ORDINAL_POSITION KEY_SEQ, " + "UPDATE_RULE, " + "DELETE_RULE, " + "FK_NAME, " + "PK_NAME, " + "DEFERRABILITY " + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " + "WHERE PKTABLE_CATALOG LIKE ? ESCAPE ? " + "AND PKTABLE_SCHEMA LIKE ? ESCAPE ? " + "AND PKTABLE_NAME = ? " + "AND FKTABLE_CATALOG LIKE ? ESCAPE ? " + "AND FKTABLE_SCHEMA LIKE ? ESCAPE ? " + "AND FKTABLE_NAME = ? " + "ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ");
        prep.setString(1, getCatalogPattern(primaryCatalogPattern));
        prep.setString(2, "\\");
        prep.setString(3, getSchemaPattern(primarySchemaPattern));
        prep.setString(4, "\\");
        prep.setString(5, primaryTable);
        prep.setString(6, getCatalogPattern(foreignCatalogPattern));
        prep.setString(7, "\\");
        prep.setString(8, getSchemaPattern(foreignSchemaPattern));
        prep.setString(9, "\\");
        prep.setString(10, foreignTable);
        return prep.executeQuery();
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : PreparedStatement(java.sql.PreparedStatement) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 22 with Sequence

use of org.h2.schema.Sequence in project h2database by h2database.

the class JdbcDatabaseMetaData method getImportedKeys.

/**
 * Gets the list of primary key columns that are referenced by a table. The
 * result set is sorted by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME,
 * FK_NAME, KEY_SEQ.
 *
 * <ol>
 * <li>PKTABLE_CAT (String) primary catalog</li>
 * <li>PKTABLE_SCHEM (String) primary schema</li>
 * <li>PKTABLE_NAME (String) primary table</li>
 * <li>PKCOLUMN_NAME (String) primary column</li>
 * <li>FKTABLE_CAT (String) foreign catalog</li>
 * <li>FKTABLE_SCHEM (String) foreign schema</li>
 * <li>FKTABLE_NAME (String) foreign table</li>
 * <li>FKCOLUMN_NAME (String) foreign column</li>
 * <li>KEY_SEQ (short) sequence number (1, 2, ...)</li>
 * <li>UPDATE_RULE (short) action on update (see
 * DatabaseMetaData.importedKey...)</li>
 * <li>DELETE_RULE (short) action on delete (see
 * DatabaseMetaData.importedKey...)</li>
 * <li>FK_NAME (String) foreign key name</li>
 * <li>PK_NAME (String) primary key name</li>
 * <li>DEFERRABILITY (short) deferrable or not (always
 * importedKeyNotDeferrable)</li>
 * </ol>
 *
 * @param catalogPattern null (to get all objects) or the catalog name
 * @param schemaPattern the schema name of the foreign table
 * @param tableName the name of the foreign table
 * @return the result set
 * @throws SQLException if the connection is closed
 */
@Override
public ResultSet getImportedKeys(String catalogPattern, String schemaPattern, String tableName) throws SQLException {
    try {
        if (isDebugEnabled()) {
            debugCode("getImportedKeys(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(tableName) + ");");
        }
        checkClosed();
        PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "PKTABLE_CATALOG PKTABLE_CAT, " + "PKTABLE_SCHEMA PKTABLE_SCHEM, " + "PKTABLE_NAME PKTABLE_NAME, " + "PKCOLUMN_NAME, " + "FKTABLE_CATALOG FKTABLE_CAT, " + "FKTABLE_SCHEMA FKTABLE_SCHEM, " + "FKTABLE_NAME, " + "FKCOLUMN_NAME, " + "ORDINAL_POSITION KEY_SEQ, " + "UPDATE_RULE, " + "DELETE_RULE, " + "FK_NAME, " + "PK_NAME, " + "DEFERRABILITY " + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " + "WHERE FKTABLE_CATALOG LIKE ? ESCAPE ? " + "AND FKTABLE_SCHEMA LIKE ? ESCAPE ? " + "AND FKTABLE_NAME = ? " + "ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, FK_NAME, KEY_SEQ");
        prep.setString(1, getCatalogPattern(catalogPattern));
        prep.setString(2, "\\");
        prep.setString(3, getSchemaPattern(schemaPattern));
        prep.setString(4, "\\");
        prep.setString(5, tableName);
        return prep.executeQuery();
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : PreparedStatement(java.sql.PreparedStatement) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 23 with Sequence

use of org.h2.schema.Sequence in project h2database by h2database.

the class TestStatement method testIdentity.

private void testIdentity() throws SQLException {
    Statement stat = conn.createStatement();
    stat.execute("CREATE SEQUENCE SEQ");
    stat.execute("CREATE TABLE TEST(ID INT)");
    stat.execute("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", Statement.RETURN_GENERATED_KEYS);
    ResultSet rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(1, rs.getInt(1));
    assertFalse(rs.next());
    stat.execute("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", Statement.RETURN_GENERATED_KEYS);
    rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(2, rs.getInt(1));
    assertFalse(rs.next());
    stat.execute("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", new int[] { 1 });
    rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(3, rs.getInt(1));
    assertFalse(rs.next());
    stat.execute("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", new String[] { "ID" });
    rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(4, rs.getInt(1));
    assertFalse(rs.next());
    stat.executeUpdate("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", Statement.RETURN_GENERATED_KEYS);
    rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(5, rs.getInt(1));
    assertFalse(rs.next());
    stat.executeUpdate("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", new int[] { 1 });
    rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(6, rs.getInt(1));
    assertFalse(rs.next());
    stat.executeUpdate("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", new String[] { "ID" });
    rs = stat.getGeneratedKeys();
    rs.next();
    assertEquals(7, rs.getInt(1));
    assertFalse(rs.next());
    stat.execute("CREATE TABLE TEST2(ID identity primary key)");
    stat.execute("INSERT INTO TEST2 VALUES()");
    stat.execute("SET @X = IDENTITY()");
    rs = stat.executeQuery("SELECT @X");
    rs.next();
    assertEquals(1, rs.getInt(1));
    stat.execute("DROP TABLE TEST");
    stat.execute("DROP TABLE TEST2");
}
Also used : PreparedStatement(java.sql.PreparedStatement) JdbcStatement(org.h2.jdbc.JdbcStatement) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet)

Example 24 with Sequence

use of org.h2.schema.Sequence in project h2database by h2database.

the class TestGetGeneratedKeys method testCalledSequences.

/**
 * Test for keys generated by sequences.
 *
 * @param conn
 *            connection
 * @throws Exception
 *             on exception
 */
private void testCalledSequences(Connection conn) throws Exception {
    Statement stat = conn.createStatement();
    stat.execute("CREATE SEQUENCE SEQ");
    stat.execute("CREATE TABLE TEST(ID INT)");
    PreparedStatement prep;
    prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", Statement.RETURN_GENERATED_KEYS);
    prep.execute();
    ResultSet rs = prep.getGeneratedKeys();
    rs.next();
    assertEquals(1, rs.getInt(1));
    assertFalse(rs.next());
    prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", Statement.RETURN_GENERATED_KEYS);
    prep.execute();
    rs = prep.getGeneratedKeys();
    rs.next();
    assertEquals(2, rs.getInt(1));
    assertFalse(rs.next());
    prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", new int[] { 1 });
    prep.execute();
    rs = prep.getGeneratedKeys();
    rs.next();
    assertEquals(3, rs.getInt(1));
    assertFalse(rs.next());
    prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", new String[] { "ID" });
    prep.execute();
    rs = prep.getGeneratedKeys();
    rs.next();
    assertEquals(4, rs.getInt(1));
    assertFalse(rs.next());
    prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
    prep.execute();
    rs = prep.getGeneratedKeys();
    rs.next();
    assertFalse(rs.next());
    stat.execute("DROP TABLE TEST");
    stat.execute("DROP SEQUENCE SEQ");
    stat.execute("CREATE TABLE TEST(ID BIGINT)");
    stat.execute("CREATE SEQUENCE SEQ");
    prep = conn.prepareStatement("INSERT INTO TEST VALUES (30), (NEXT VALUE FOR SEQ)," + " (NEXT VALUE FOR SEQ), (NEXT VALUE FOR SEQ), (20)", Statement.RETURN_GENERATED_KEYS);
    prep.executeUpdate();
    rs = prep.getGeneratedKeys();
    rs.next();
    assertEquals(1L, rs.getLong(1));
    rs.next();
    assertEquals(2L, rs.getLong(1));
    rs.next();
    assertEquals(3L, rs.getLong(1));
    assertFalse(rs.next());
    stat.execute("DROP TABLE TEST");
    stat.execute("DROP SEQUENCE SEQ");
}
Also used : JdbcStatement(org.h2.jdbc.JdbcStatement) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) JdbcPreparedStatement(org.h2.jdbc.JdbcPreparedStatement) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) JdbcPreparedStatement(org.h2.jdbc.JdbcPreparedStatement)

Example 25 with Sequence

use of org.h2.schema.Sequence in project h2database by h2database.

the class TestWeb method testWebApp.

private void testWebApp() throws Exception {
    Server server = new Server();
    server.setOut(new PrintStream(new ByteArrayOutputStream()));
    server.runTool("-web", "-webPort", "8182", "-properties", "null", "-tcp", "-tcpPort", "9101");
    try {
        String url = "http://localhost:8182";
        WebClient client;
        String result;
        client = new WebClient();
        result = client.get(url);
        client.readSessionId(result);
        client.get(url, "login.jsp");
        client.get(url, "adminSave.do");
        result = client.get(url, "index.do?language=de");
        result = client.get(url, "login.jsp");
        assertContains(result, "Einstellung");
        result = client.get(url, "index.do?language=en");
        result = client.get(url, "login.jsp");
        assertTrue(result.indexOf("Einstellung") < 0);
        result = client.get(url, "test.do?driver=abc" + "&url=jdbc:abc:mem: " + getTestName() + "&user=sa&password=sa&name=_test_");
        assertContains(result, "Exception");
        result = client.get(url, "test.do?driver=org.h2.Driver" + "&url=jdbc:h2:mem:" + getTestName() + "&user=sa&password=sa&name=_test_");
        assertTrue(result.indexOf("Exception") < 0);
        result = client.get(url, "login.do?driver=org.h2.Driver" + "&url=jdbc:h2:mem:" + getTestName() + "&user=sa&password=sa&name=_test_");
        result = client.get(url, "header.jsp");
        result = client.get(url, "query.do?sql=" + "create table test(id int primary key, name varchar);" + "insert into test values(1, 'Hello')");
        result = client.get(url, "query.do?sql=create sequence test_sequence");
        result = client.get(url, "query.do?sql=create schema test_schema");
        result = client.get(url, "query.do?sql=" + "create view test_view as select * from test");
        result = client.get(url, "tables.do");
        result = client.get(url, "query.jsp");
        result = client.get(url, "query.do?sql=select * from test");
        assertContains(result, "Hello");
        result = client.get(url, "query.do?sql=select * from test");
        result = client.get(url, "query.do?sql=@META select * from test");
        assertContains(result, "typeName");
        result = client.get(url, "query.do?sql=delete from test");
        result = client.get(url, "query.do?sql=@LOOP 1000 " + "insert into test values(?, 'Hello ' || ?/*RND*/)");
        assertContains(result, "1000 * (Prepared)");
        result = client.get(url, "query.do?sql=select * from test");
        result = client.get(url, "query.do?sql=@list select * from test");
        assertContains(result, "Row #");
        result = client.get(url, "query.do?sql=@parameter_meta " + "select * from test where id = ?");
        assertContains(result, "INTEGER");
        result = client.get(url, "query.do?sql=@edit select * from test");
        assertContains(result, "editResult.do");
        result = client.get(url, "query.do?sql=" + StringUtils.urlEncode("select space(100001) a, 1 b"));
        assertContains(result, "...");
        result = client.get(url, "query.do?sql=" + StringUtils.urlEncode("call '<&>'"));
        assertContains(result, "&lt;&amp;&gt;");
        result = client.get(url, "query.do?sql=@HISTORY");
        result = client.get(url, "getHistory.do?id=4");
        assertContains(result, "select * from test");
        result = client.get(url, "query.do?sql=delete from test");
        // op 1 (row -1: insert, otherwise update): ok,
        // 2: delete  3: cancel,
        result = client.get(url, "editResult.do?sql=@edit " + "select * from test&op=1&row=-1&r-1c1=1&r-1c2=Hello");
        assertContains(result, "1");
        assertContains(result, "Hello");
        result = client.get(url, "editResult.do?sql=@edit " + "select * from test&op=1&row=1&r1c1=1&r1c2=Hallo");
        assertContains(result, "1");
        assertContains(result, "Hallo");
        result = client.get(url, "query.do?sql=select * from test");
        assertContains(result, "1");
        assertContains(result, "Hallo");
        result = client.get(url, "editResult.do?sql=@edit " + "select * from test&op=2&row=1");
        result = client.get(url, "query.do?sql=select * from test");
        assertContains(result, "no rows");
        // autoComplete
        result = client.get(url, "autoCompleteList.do?query=select 'abc");
        assertContains(StringUtils.urlDecode(result), "'");
        result = client.get(url, "autoCompleteList.do?query=select 'abc''");
        assertContains(StringUtils.urlDecode(result), "'");
        result = client.get(url, "autoCompleteList.do?query=select 'abc' ");
        assertContains(StringUtils.urlDecode(result), "||");
        result = client.get(url, "autoCompleteList.do?query=select 'abc' |");
        assertContains(StringUtils.urlDecode(result), "|");
        result = client.get(url, "autoCompleteList.do?query=select 'abc' || ");
        assertContains(StringUtils.urlDecode(result), "'");
        result = client.get(url, "autoCompleteList.do?query=call timestamp '2");
        assertContains(result, "20");
        result = client.get(url, "autoCompleteList.do?query=call time '1");
        assertContains(StringUtils.urlDecode(result), "12:00:00");
        result = client.get(url, "autoCompleteList.do?query=" + "call timestamp '2001-01-01 12:00:00.");
        assertContains(result, "nanoseconds");
        result = client.get(url, "autoCompleteList.do?query=" + "call timestamp '2001-01-01 12:00:00.00");
        assertContains(result, "nanoseconds");
        result = client.get(url, "autoCompleteList.do?query=" + "call $$ hello world");
        assertContains(StringUtils.urlDecode(result), "$$");
        result = client.get(url, "autoCompleteList.do?query=alter index ");
        assertContains(StringUtils.urlDecode(result), "character");
        result = client.get(url, "autoCompleteList.do?query=alter index idx");
        assertContains(StringUtils.urlDecode(result), "character");
        result = client.get(url, "autoCompleteList.do?query=alter index \"IDX_");
        assertContains(StringUtils.urlDecode(result), "\"");
        result = client.get(url, "autoCompleteList.do?query=alter index \"IDX_\"\"");
        assertContains(StringUtils.urlDecode(result), "\"");
        result = client.get(url, "autoCompleteList.do?query=help ");
        assertContains(result, "anything");
        result = client.get(url, "autoCompleteList.do?query=help select");
        assertContains(result, "anything");
        result = client.get(url, "autoCompleteList.do?query=call ");
        assertContains(result, "0x");
        result = client.get(url, "autoCompleteList.do?query=call 0");
        assertContains(result, ".");
        result = client.get(url, "autoCompleteList.do?query=se");
        assertContains(result, "select");
        assertContains(result, "set");
        result = client.get(url, "tables.do");
        assertContains(result, "TEST");
        result = client.get(url, "autoCompleteList.do?query=" + "select * from ");
        assertContains(result, "test");
        result = client.get(url, "autoCompleteList.do?query=" + "select * from test t where t.");
        assertContains(result, "id");
        result = client.get(url, "autoCompleteList.do?query=" + "select id x from test te where t");
        assertContains(result, "te");
        result = client.get(url, "autoCompleteList.do?query=" + "select * from test where name = '");
        assertContains(StringUtils.urlDecode(result), "'");
        result = client.get(url, "autoCompleteList.do?query=" + "select * from information_schema.columns where columns.");
        assertContains(result, "column_name");
        result = client.get(url, "query.do?sql=delete from test");
        // special commands
        result = client.get(url, "query.do?sql=@autocommit_true");
        assertContains(result, "Auto commit is now ON");
        result = client.get(url, "query.do?sql=@autocommit_false");
        assertContains(result, "Auto commit is now OFF");
        result = client.get(url, "query.do?sql=@cancel");
        assertContains(result, "There is currently no running statement");
        result = client.get(url, "query.do?sql=@generated insert into test(id) values(test_sequence.nextval)");
        assertContains(result, "<tr><th>ID</th></tr><tr><td>1</td></tr>");
        result = client.get(url, "query.do?sql=@maxrows 2000");
        assertContains(result, "Max rowcount is set");
        result = client.get(url, "query.do?sql=@password_hash user password");
        assertContains(result, "501cf5c163c184c26e62e76d25d441979f8f25dfd7a683484995b4a43a112fdf");
        result = client.get(url, "query.do?sql=@sleep 1");
        assertContains(result, "Ok");
        result = client.get(url, "query.do?sql=@catalogs");
        assertContains(result, "PUBLIC");
        result = client.get(url, "query.do?sql=@column_privileges null null null TEST null");
        assertContains(result, "PRIVILEGE");
        result = client.get(url, "query.do?sql=@cross_references null null null TEST");
        assertContains(result, "PKTABLE_NAME");
        result = client.get(url, "query.do?sql=@exported_keys null null null TEST");
        assertContains(result, "PKTABLE_NAME");
        result = client.get(url, "query.do?sql=@imported_keys null null null TEST");
        assertContains(result, "PKTABLE_NAME");
        result = client.get(url, "query.do?sql=@primary_keys null null null TEST");
        assertContains(result, "PK_NAME");
        result = client.get(url, "query.do?sql=@procedures null null null");
        assertContains(result, "PROCEDURE_NAME");
        result = client.get(url, "query.do?sql=@procedure_columns");
        assertContains(result, "PROCEDURE_NAME");
        result = client.get(url, "query.do?sql=@schemas");
        assertContains(result, "PUBLIC");
        result = client.get(url, "query.do?sql=@table_privileges");
        assertContains(result, "PRIVILEGE");
        result = client.get(url, "query.do?sql=@table_types");
        assertContains(result, "SYSTEM TABLE");
        result = client.get(url, "query.do?sql=@type_info");
        assertContains(result, "CLOB");
        result = client.get(url, "query.do?sql=@version_columns");
        assertContains(result, "PSEUDO_COLUMN");
        result = client.get(url, "query.do?sql=@attributes");
        assertContains(result, "Feature not supported: &quot;attributes&quot;");
        result = client.get(url, "query.do?sql=@super_tables");
        assertContains(result, "SUPERTABLE_NAME");
        result = client.get(url, "query.do?sql=@super_types");
        assertContains(result, "Feature not supported: &quot;superTypes&quot;");
        result = client.get(url, "query.do?sql=@prof_start");
        assertContains(result, "Ok");
        result = client.get(url, "query.do?sql=@prof_stop");
        assertContains(result, "Top Stack Trace(s)");
        result = client.get(url, "query.do?sql=@best_row_identifier null null TEST");
        assertContains(result, "SCOPE");
        assertContains(result, "COLUMN_NAME");
        assertContains(result, "ID");
        result = client.get(url, "query.do?sql=@udts");
        assertContains(result, "CLASS_NAME");
        result = client.get(url, "query.do?sql=@udts null null null 1,2,3");
        assertContains(result, "CLASS_NAME");
        result = client.get(url, "query.do?sql=@LOOP 10 " + "@STATEMENT insert into test values(?, 'Hello')");
        result = client.get(url, "query.do?sql=select * from test");
        assertContains(result, "8");
        result = client.get(url, "query.do?sql=@EDIT select * from test");
        assertContains(result, "editRow");
        result = client.get(url, "query.do?sql=@AUTOCOMMIT TRUE");
        result = client.get(url, "query.do?sql=@AUTOCOMMIT FALSE");
        result = client.get(url, "query.do?sql=@TRANSACTION_ISOLATION");
        result = client.get(url, "query.do?sql=@SET MAXROWS 1");
        result = client.get(url, "query.do?sql=select * from test order by id");
        result = client.get(url, "query.do?sql=@SET MAXROWS 1000");
        result = client.get(url, "query.do?sql=@TABLES");
        assertContains(result, "TEST");
        result = client.get(url, "query.do?sql=@COLUMNS null null TEST");
        assertContains(result, "ID");
        result = client.get(url, "query.do?sql=@INDEX_INFO null null TEST");
        assertContains(result, "PRIMARY");
        result = client.get(url, "query.do?sql=@CATALOG");
        assertContains(result, "PUBLIC");
        result = client.get(url, "query.do?sql=@MEMORY");
        assertContains(result, "Used");
        result = client.get(url, "query.do?sql=@INFO");
        assertContains(result, "getCatalog");
        result = client.get(url, "logout.do");
        result = client.get(url, "login.do?driver=org.h2.Driver&" + "url=jdbc:h2:mem:" + getTestName() + "&user=sa&password=sa&name=_test_");
        result = client.get(url, "logout.do");
        result = client.get(url, "settingRemove.do?name=_test_");
        client.get(url, "admin.do");
    } finally {
        server.shutdown();
    }
}
Also used : PrintStream(java.io.PrintStream) Server(org.h2.tools.Server) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

Sequence (org.h2.schema.Sequence)19 ValueString (org.h2.value.ValueString)14 PreparedStatement (java.sql.PreparedStatement)10 Column (org.h2.table.Column)10 Database (org.h2.engine.Database)9 Expression (org.h2.expression.Expression)8 DbException (org.h2.message.DbException)8 Table (org.h2.table.Table)8 ResultSet (java.sql.ResultSet)7 Statement (java.sql.Statement)7 Constraint (org.h2.constraint.Constraint)7 Index (org.h2.index.Index)7 Connection (java.sql.Connection)6 SQLException (java.sql.SQLException)6 SchemaObject (org.h2.schema.SchemaObject)6 ArrayList (java.util.ArrayList)5 DropSequence (org.h2.command.ddl.DropSequence)5 DbObject (org.h2.engine.DbObject)5 Schema (org.h2.schema.Schema)5 TriggerObject (org.h2.schema.TriggerObject)5