0 Replies Latest reply on Jan 19, 2009 6:31 AM by Marcos Antonio

    Will the container restore the transaction isolation level?

    Marcos Antonio Novice

      Hello, everybody!

      Look at the following code:

      public void foo()
      {
       Connection connection = null;
       PreparedStatement command = null;
       ResultSet data = null;
       try
       {
       InitialContext context = new InitialContext();
       DataSource dataSource =
       (DataSource) context.lookup("java:/BibliotecaDS");
       connection = dataSource.getConnection();
       connection.setTransactionIsolation(
       Connection.TRANSACTION_REPEATABLE_READ);
      
       // Execute some selects and updates...
       }
       catch (NamingException ex)
       {
       // Handle exception...
       }
       catch (SQLException ex)
       {
       // Handle exception...
       }
       finally
       {
       // Close resources...
       }
      }
      

      As you can see I'm getting a managed connection from the connection pool and changing its transation isolation level before using the connection to create statements and result sets. My doubt is: after the method completes and JBoss commit or rollback the updates, will the container revert the connection's transaction isolation level to the initial value, before the execution of the method? If so, that's what I expect and what
      I want. If not, I won't be able to change the isolation level because suddenly I'll have a connection pool full of connections with a more restrictive isolation level, making my application run slow.

      Thank you.

      Marcos