Uploaded image for project: 'IronJacamar'
  1. IronJacamar
  2. JBJCA-1392

Need to add checkTransaction handling for unwrap connection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • JDBC

      connection.setAutoCommit cannot affect unwrap native connection. The following mc.getAutoCommit result is true.

      c = dataSource.getConnection();
      c.setAutoCommit(false);
      if (c.isWrapperFor(oracle.jdbc.OracleConnection.class)) {
        mc = c.unwrap(oracle.jdbc.OracleConnection.class);
      }
      System.out.println("[JDBC 4 Wrapper] autoCommit : " + mc.getAutoCommit());
      

      However, the following getUnderlyingConnection native connection result is false.

      c = dataSource.getConnection();
      c.setAutoCommit(false);
      WrappedConnection wc = (WrappedConnection)c;
      oracle.jdbc.OracleConnection mc = (oracle.jdbc.OracleConnection)wc.getUnderlyingConnection();
      System.out.println("[org.jboss.ironjacamar.jdbcadapters WrappedConnection] autoCommit : " + mc.getAutoCommit());
      

      The getUnderlyingConnection method call BaseWrapperManagedConnection.checkTransaction process, but there is no similar process in unwrap method.

      org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java
         void checkTransaction() throws SQLException
         {
            synchronized (stateLock)
            {
               if (inManagedTransaction)
                  return;
      
               // Check autocommit
               if (jdbcAutoCommit != underlyingAutoCommit)
               {
                  con.setAutoCommit(jdbcAutoCommit);
                  underlyingAutoCommit = jdbcAutoCommit;
               }
            }
      

            istudens@redhat.com Ivo Studensky
            istudens@redhat.com Ivo Studensky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: