Package org.adbcj

Examples of org.adbcj.Connection.beginTransaction()


      }

      connection.beginTransaction();
      connection.rollback().get();

      connection.beginTransaction();
      connection.commit().get();

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


      connection.rollback().get();

      connection.beginTransaction();
      connection.commit().get();

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

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

      }
    }).get();
    logger.debug("Obtained lock on locks table");
   
    // Try to get lock with second connection
    conn2.beginTransaction();
    DbFuture<ResultSet> future = TestUtils.selectForUpdate(conn2, new DbListener<ResultSet>() {
      public void onCompletion(DbFuture<ResultSet> future) throws Exception {
        logger.debug("In second callback");
        invoked[1] = true;
        if (!locked.get()) {
View Full Code Here

      lockingConnection.beginTransaction();
      TestUtils.selectForUpdate(lockingConnection).get();

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

      connection.beginTransaction();

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

      // Get lock with select for update
      lockConnection.beginTransaction();
      TestUtils.selectForUpdate(lockConnection).get();

      // Do select for update on second connection so we can finalizeClose it and then cancel the finalizeClose
      connectionToClose.beginTransaction();
      DbFuture<ResultSet> future = TestUtils.selectForUpdate(connectionToClose);

      DbSessionFuture<Void> closeFuture = connectionToClose.close(false).addListener(new DbListener<Void>() {
        public void onCompletion(DbFuture<Void> future) throws Exception {
          logger.debug("testCancelClose: In finalizeClose callback for connectionManager {}", connectionManager);
View Full Code Here

  public void testBeginTransaction() throws Exception {
    Connection connection = connectionManager.connect().get();
    try {
      Assert.assertTrue(!connection.isInTransaction(), "Connections should not start with transaction started");
      connection.beginTransaction();
      Assert.assertTrue(connection.isInTransaction(), "Connection should be in transaction");
      try {
        connection.beginTransaction();
        Assert.fail("Should have thrown exception because connection is already in transaction");
      } catch (DbException e) {
View Full Code Here

    try {
      Assert.assertTrue(!connection.isInTransaction(), "Connections should not start with transaction started");
      connection.beginTransaction();
      Assert.assertTrue(connection.isInTransaction(), "Connection should be in transaction");
      try {
        connection.beginTransaction();
        Assert.fail("Should have thrown exception because connection is already in transaction");
      } catch (DbException e) {
        // Pass
      }
    } finally {
View Full Code Here

        Assert.fail("Not in transaction, rollback should have failed");
      } catch (DbException e) {
        // Pass
      }

      connection.beginTransaction();
      connection.rollback().get();

      connection.beginTransaction();
      connection.commit().get();
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.