Package org.adbcj

Examples of org.adbcj.Connection.executeQuery()


      // 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();
View Full Code Here


      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);
View Full Code Here

      // 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();
View Full Code Here

      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 {
View Full Code Here

      connection.beginTransaction();

      TestUtils.selectForUpdate(connection);
      for (int i = 0; i < 5; i++) {
        futures.add(connection.executeQuery(String.format("SELECT *, %d FROM simple_values", i)));
      }

      logger.debug("Closing connection");
      connection.close(true).get();
      logger.debug("Closed");
View Full Code Here

    Connection connection = connectionManager.connect().get();

    List<DbSessionFuture<ResultSet>> futures = new ArrayList<DbSessionFuture<ResultSet>>();

    for (int i = 0; i < 5; i++) {
      futures.add(connection.executeQuery(String.format("SELECT *, %d FROM simple_values", i)));
    }
    try {
      connection.close(false).get(10, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
      for (DbSessionFuture<ResultSet> future : futures) {
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();
View Full Code Here

    Connection connection = connectionManager.connect().get();
   
    List<DbFuture<ResultSet>> futures = new LinkedList<DbFuture<ResultSet>>();
    for (int i = 0; i < 1000; i++) {
      futures.add(
          connection.executeQuery(String.format("SELECT *, %d FROM simple_values", i))
          );
    }
   
    for (DbFuture<ResultSet> future : futures) {
      try {
View Full Code Here

  }
 
  public void testBrokenSelect() throws Exception {
    Connection connection = connectionManager.connect().get();
   
    DbSessionFuture<ResultSet> future = connection.executeQuery("SELECT broken_query");
    try {
      future.get(5, TimeUnit.SECONDS);
      throw new AssertionError("Issues a bad query, future should have failed");
    } catch (DbException e) {
      // Pass
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.