Package org.adbcj

Examples of org.adbcj.ResultSet


      // Clear out updates table
      Result result = connection.executeUpdate("DELETE FROM updates").get();
      assertNotNull(result);

      // Make sure updates is empty
      ResultSet rs = connection.executeQuery("SELECT id FROM updates").get();
      assertNotNull(rs);
      assertEquals(rs.size(), 0);

      connection.beginTransaction();

      // Insert a row
      result = connection.executeUpdate("INSERT INTO updates (id) VALUES (1)").get();
      assertNotNull(result);
      assertEquals(result.getAffectedRows(), Long.valueOf(1));

      // Make sure we can select the row
      rs = connection.executeQuery("SELECT id FROM updates").get();
      assertNotNull(rs);
      assertEquals(rs.size(), 1);
      Value value = rs.get(0).get(0);
      assertEquals(value.getInt(), 1);

      // Rollback transaction
      connection.rollback().get();

      // select query should now be empty
      rs = connection.executeQuery("SELECT id FROM updates").get();
      assertNotNull(rs);
      assertEquals(rs.size(), 0);

    } finally {
      connection.close(true);
    }
  }
View Full Code Here


      result = connection.executeUpdate("INSERT INTO updates (id) VALUES (1)").get();
      assertNotNull(result);
      assertEquals(result.getAffectedRows(), Long.valueOf(1));

      // Make sure second connection can't see data
      ResultSet rs = connection2.executeQuery("SELECT id FROM updates").get();
      assertNotNull(rs);
      assertEquals(rs.size(), 0);

      connection.commit().get();

      // Make sure both connections can see data
      rs = connection.executeQuery("SELECT id FROM updates").get();
      assertNotNull(rs);
      assertEquals(rs.size(), 1);
      assertEquals(rs.get(0).get(0).getInt(), 1);

      rs = connection2.executeQuery("SELECT id FROM updates").get();
      assertNotNull(rs);
      assertEquals(rs.size(), 1);
      assertEquals(rs.get(0).get(0).getInt(), 1);

    } finally {
      connection.close(true);
      connection2.close(true);
    }
View Full Code Here

    final boolean[] callbacks = {false};
    final CountDownLatch latch = new CountDownLatch(callbacks.length);
   
    Connection connection = connectionManager.connect().get();
    try {
      ResultSet resultSet = connection.executeQuery("SELECT int_val, str_val FROM simple_values ORDER BY int_val").addListener(new DbListener<ResultSet>() {
        public void onCompletion(DbFuture<ResultSet> future) throws Exception {
          System.out.println("In callback");
          future.get().size();
          callbacks[0] = true;
          latch.countDown();
          System.out.println("Finished callback");
        }
      }).get();
     
      Assert.assertEquals(6, resultSet.size());
     
      Iterator<Row> i = resultSet.iterator();
     
      Row nullRow = null;
      Row row = i.next();
      if (row.get(0).isNull()) {
        nullRow = row;
View Full Code Here

    result = connection.executeUpdate("INSERT INTO updates (id) VALUES (1)").get();
    assertNotNull(result);
    assertEquals(result.getAffectedRows(), Long.valueOf(1));

    // Select the row
    ResultSet rs = connection.executeQuery("SELECT id FROM updates").get();
    assertNotNull(rs);
    assertEquals(rs.size(), 1);
    Value value = rs.get(0).get(0);
    assertEquals(value.getInt(), 1);
    assertEquals(value.getField().getColumnLabel(), "id");

    // Update nothing
    result = connection.executeUpdate("UPDATE updates SET id=1 WHERE id=2").get();
View Full Code Here

    ConnectionManager cm = ConnectionManagerProvider.createConnectionManager("adbcj:postgresql-netty://localhost/adbcjtck", "adbcjtck", "adbcjtck");
    Connection connection = cm.connect().get();

    final DbFuture<ResultSet> future = connection.executeQuery("SELECT * FROM simple_values");
    final DbFuture<ResultSet> future2 = connection.executeQuery("SELECT * FROM large");
    ResultSet rs = future.get();
    ResultSet rs2 = future2.get();
    for (Row row : rs) {
      System.out.println(row.get(0) + " " + row.get(1));
    }
    for (Row row : rs2) {
      System.out.println(row.get(0) + " " + row.get(1));
View Full Code Here

   */
  public static void main(String[] args) throws DbException, InterruptedException {
    ConnectionManager cm = ConnectionManagerProvider.createConnectionManager("adbcj:postgresql-mina://localhost/adbcjtck", "adbcjtck", "adbcjtck");
    Connection connection = cm.connect().get();
 
    final ResultSet rs = connection.executeQuery("SELECT * FROM large").get();
    for (Row row : rs) {
      System.out.println(row.get(0) + " " + row.get(1));
    }
    cm.close(true).get();
  }
View Full Code Here

TOP

Related Classes of org.adbcj.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.