private void createConnection() throws SQLException {
   connectionProvider = ConnectionProviderFactory.newConnectionProvider(properties);
   connection = connectionProvider.getConnection();
   if (!connection.getAutoCommit()) {
     connection.commit();
     connection.setAutoCommit(true);
   }
 }
Example #2
0
  /**
   * Try to update the row with the given error. Flag a failure if a timeout occurs when not
   * expected, and vice versa.
   *
   * @param id The id of the row to be updated
   * @param timeoutExpected true if it is expected that the update times out
   * @throws java.sql.SQLException
   */
  private void executeParallelUpdate(int id, boolean timeoutExpected) throws SQLException {
    Connection conn2 = openDefaultConnection();
    Statement stmt2 = conn2.createStatement();

    try {
      stmt2.executeUpdate(
          "update BLOBCLOB set BLOBDATA = " + "cast(X'FFFFFF' as blob) where ID=" + id);
      stmt2.close();
      conn2.commit();
      conn2.close();
      if (timeoutExpected) {
        fail("FAIL - should have gotten lock timeout");
      }
    } catch (SQLException se) {
      stmt2.close();
      conn2.rollback();
      conn2.close();
      if (timeoutExpected) {
        assertSQLState(LOCK_TIMEOUT, se);
      } else {
        throw se;
      }
    }
  }