1 Reply Latest reply on Dec 20, 2002 3:43 AM by rmahal

    Oracle transaction isolation

    imdkidd

      How do I set the transaction isolation level for my entity bean, i am using an oracle datasource?

      I need to set it on a bean by bean basis.

        • 1. Re: Oracle transaction isolation
          rmahal

          My understanding is that transaction isolation is not a deployment attribute for ORACLE. In the past I've needed a snapshot read when extracting data. To achieve this I've had to issue "SET TRANSACTION READONLY" manually once I've connected to the database. I hope this helps.

          Some code ....

          public static void setTransactionIsolationRepeatableRead(DataSource dataSource)
          throws GeneralPersistenceException {

          // Getting connection
          Connection connection = null;
          PreparedStatement preparedStatement = null;
          try {
          connection = dataSource.getConnection();

          // Oracle/jdbc doesn't support this!!!!
          // connection.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
          // Therefore doing it manually
          preparedStatement = connection.prepareStatement("set transaction read only");
          preparedStatement.executeUpdate();
          cat.debug("Set transaction read only as TRANSACTION_REPEATABLE_READ is not supported!");
          }
          catch(SQLException sqle) {
          cat.fatal("Unable to get database connection/set isolation level: " + dataSource + " " + sqle.getMessage());
          throw new GeneralPersistenceException("Unable to get database connection/set isolation level: " + dataSource, sqle);
          }

          closeDatabaseResource(preparedStatement,connection);
          }