Package java.sql

Examples of java.sql.ResultSet


      connection.close();
    }

    @Test public void testSetTableStats() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("select cardinality from tables where name = 'PARTSSUPPLIER.PARTS'");
      rs.next();
      assertEquals(16, rs.getInt(1));
      s.execute("call setTableStats(tableName=>'partssupplier.partssupplier.parts', cardinality=>32)");
      rs = s.executeQuery("select cardinality from tables where name = 'PARTSSUPPLIER.PARTS'");
      rs.next();
      assertEquals(32, rs.getInt(1));
    }
View Full Code Here


      assertEquals(32, rs.getInt(1));
    }
   
    @Test public void testSetColumnStats() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("select MinRange, MaxRange, DistinctCount, NullCount from columns where name = 'PART_ID'");
      rs.next();
      assertEquals(null, rs.getString(1));
      assertEquals(null, rs.getString(2));
      assertEquals(-1, rs.getInt(3));
      assertEquals(-1, rs.getInt(4));
      s.execute("call setColumnStats(tableName=>'partssupplier.partssupplier.parts', columnName=>'PART_ID', max=>32, nullcount=>0)");
      rs = s.executeQuery("select MinRange, MaxRange, DistinctCount, NullCount from columns where name = 'PART_ID'");
      rs.next();
      assertEquals(null, rs.getString(1));
      assertEquals("32", rs.getString(2));
      assertEquals(-1, rs.getInt(3));
      assertEquals(0, rs.getInt(4));
    }
View Full Code Here

  }
 
  @Test public void testBlob() throws Exception {
    Statement s = conn.createStatement();
    assertTrue(s.execute("select to_bytes('abc', 'UTF-16')"));
    ResultSet rs = s.getResultSet();
    assertTrue(rs.next());
    byte[] bytes = rs.getBytes(1);
    assertEquals("abc", new String(bytes, Charset.forName("UTF-16")));
  }
View Full Code Here

  }
 
  @Test public void testClob() throws Exception {
    Statement s = conn.createStatement();
    assertTrue(s.execute("select cast('abc' as clob)"));
    ResultSet rs = s.getResultSet();
    assertTrue(rs.next());
    //getting as a clob is unsupported, since it uses the lo logic
    String clob = rs.getString(1);
    assertEquals("abc", clob);
  }
View Full Code Here

    conn.setAutoCommit(true);
  }
 
  @Test public void testPk() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select ta.attname, ia.attnum, ic.relname, n.nspname, tc.relname " +//$NON-NLS-1$
      "from pg_catalog.pg_attribute ta, pg_catalog.pg_attribute ia, pg_catalog.pg_class tc, pg_catalog.pg_index i, " +//$NON-NLS-1$
      "pg_catalog.pg_namespace n, pg_catalog.pg_class ic where tc.relname = E'pg_attribute' AND n.nspname = E'pg_catalog'");
    TestMMDatabaseMetaData.compareResultSet(rs);
  }
View Full Code Here

 
  @Test public void testPkPrepared() throws Exception {
    PreparedStatement stmt = conn.prepareStatement("select ta.attname, ia.attnum, ic.relname, n.nspname, tc.relname " +//$NON-NLS-1$
        "from pg_catalog.pg_attribute ta, pg_catalog.pg_attribute ia, pg_catalog.pg_class tc, pg_catalog.pg_index i, " +//$NON-NLS-1$
        "pg_catalog.pg_namespace n, pg_catalog.pg_class ic where tc.relname = E'pg_attribute' AND n.nspname = E'pg_catalog'");
    ResultSet rs = stmt.executeQuery();
    TestMMDatabaseMetaData.compareResultSet(rs);
 
View Full Code Here

    }
  }
 
  @Test public void testEscapedLiteral() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select E'\\n\\thello pg'");
    assertTrue(rs.next());
    assertEquals("\n\thello pg", rs.getString(1));
  }
View Full Code Here

    assertEquals("\n\thello pg", rs.getString(1));
  }
 
  @Test public void testPgProc() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from pg_proc");
    rs.next();
    assertEquals("oid", rs.getArray("proargtypes").getBaseTypeName());
  }
View Full Code Here

    assertEquals("oid", rs.getArray("proargtypes").getBaseTypeName());
  }
 
  @Test public void testPgProcedure() throws Exception {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select has_function_privilege(100, 'foo')");
    rs.next();
  }
View Full Code Here

        stat.execute("drop table test_view, test cascade");
    }

    private void testDropViewDefaultBehaviour() throws SQLException {
        createTestData();
        ResultSet rs = stat.executeQuery("select value from information_schema.settings where name = 'DROP_RESTRICT'");
        rs.next();
        boolean dropRestrict = rs.getBoolean(1);
        if (dropRestrict) {
            // should fail because have dependencies
            assertThrows(ErrorCode.CANNOT_DROP_2, stat).
                execute("drop view v1");
        } else {
View Full Code Here

TOP

Related Classes of java.sql.ResultSet

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.