Package java.sql

Examples of java.sql.ResultSet


        // child of v2
        stat.execute("create view v3 as select * from v2");
    }

    private void checkViewRemainsValid() throws SQLException {
        ResultSet rs = stat.executeQuery("select b from v1");
        assertTrue(rs.next());
        assertEquals(1, rs.getInt(1));
        assertFalse(rs.next());

        rs = stat.executeQuery("select b from v2");
        assertTrue(rs.next());
        assertEquals(1, rs.getInt(1));
        assertFalse(rs.next());

        rs = stat.executeQuery("select b from test");
        assertTrue(rs.next());
        assertEquals(2, rs.getInt(1));
        assertFalse(rs.next());

        stat.execute("drop table test cascade");

        ResultSet d = conn.getMetaData().getTables(null, null, null, null);
        while (d.next()) {
            // should have no tables left in the database
            assertEquals(d.getString(2) + "." + d.getString(3),
                    "INFORMATION_SCHEMA", d.getString(2));
        }
    }
View Full Code Here


      connection.close();
    }

    @Test public void testViewMetadataRepositoryMerge() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("select * from vw");
      rs.next();
      assertEquals(2011, rs.getInt(1));
    }
View Full Code Here

      s.execute("delete from vw");
    }
   
    @Test public void testProcMetadataRepositoryMerge() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("call proc(1)");
      rs.next();
      assertEquals(2011, rs.getInt(1));
    }
View Full Code Here

      CallableStatement s = connection.prepareCall("{? = call sysadmin.setProperty((select uid from tables where name='vw'), 'foo', 'bar')}");
      assertFalse(s.execute());
      assertNull(s.getClob(1));
     
      Statement stmt = connection.createStatement();
      ResultSet rs = stmt.executeQuery("select name, \"value\" from properties where uid = (select uid from tables where name='vw')");
      rs.next();
      assertEquals("foo", rs.getString(1));
      assertEquals("bar", rs.getString(2));
    }
View Full Code Here

      s.execute();
    }
   
    @Test public void testAlterView() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("select * from vw");
      rs.next();
      assertEquals(2011, rs.getInt(1));
     
      assertFalse(s.execute("alter view vw as select '2012'"));
     
      rs = s.executeQuery("select * from vw");
      rs.next();
      assertEquals(2012, rs.getInt(1));
    }
View Full Code Here

      assertEquals(2012, rs.getInt(1));
    }
   
    @Test public void testAlterProcedure() throws Exception {
      Statement s = connection.createStatement();
      ResultSet rs = s.executeQuery("call proc(1)");
      rs.next();
      assertEquals(2011, rs.getInt(1));
     
      assertFalse(s.execute("alter procedure proc as begin select '2012'; end"));
     
      //the sleep is needed to ensure that the plan is invalidated
      Thread.sleep(100);
     
      rs = s.executeQuery("call proc(1)");
      rs.next();
      assertEquals(2012, rs.getInt(1));
    }
View Full Code Here

                }
                TimeZone.setDefault(target);
                DateTimeUtils.resetCalendar();
                conn = getConnection(db);
                stat = conn.createStatement();
                ResultSet rs = stat.executeQuery("select * from date_list order by t");
                while (rs.next()) {
                    String source = rs.getString(1);
                    String a = rs.getString(2);
                    String b = rs.getString(3);
                    b = b.substring(0, a.length());
                    if (!a.equals(b)) {
                        assertEquals(source + ">" + target, a, b);
                    }
                }
View Full Code Here

        if (!date.toString().equals(s)) {
            println(TimeZone.getDefault().getID() + " " + s + " <> " + date.toString());
            return;
        }
        prep.setString(1, s);
        ResultSet rs = prep.executeQuery();
        rs.next();
        String t = rs.getString(1);
        if (!s.equals(t)) {
            assertEquals(TimeZone.getDefault().getID(), s, t);
        }
    }
View Full Code Here

                prep.setInt(2, random.nextInt(10));
                prep.execute();
            } else {
                PreparedStatement prep = conn.prepareStatement("select * from news where id = ?");
                prep.setInt(1, random.nextInt(getNewsCount()));
                ResultSet rs = prep.executeQuery();
                if (!rs.next()) {
                    System.out.println("No row found");
                    // throw new AssertionError("No row found");
                }
                if (rs.next()) {
                    System.out.println("Multiple rows found");
                    // throw new AssertionError("Multiple rows found");
                }
            }
        }
View Full Code Here

        PreparedStatement prep = conn.prepareStatement("insert into orders(customer_id , total) values(?, ?)");
        prep.setInt(1, random.nextInt(getCustomerCount()));
        BigDecimal total = new BigDecimal("0");
        prep.setBigDecimal(2, total);
        prep.executeUpdate();
        ResultSet rs = prep.getGeneratedKeys();
        rs.next();
        int orderId = rs.getInt(1);
        int lines = random.nextInt(20);
        for (int i = 0; i < lines; i++) {
            insertLine.setInt(1, orderId);
            insertLine.setInt(2, i);
            insertLine.setString(3, ITEMS[random.nextInt(ITEMS.length)]);
View Full Code Here

TOP

Related Classes of java.sql.ResultSet

Copyright © 2018 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.