OpenJPA
  1. OpenJPA
  2. OPENJPA-699

SQLWarnings not handled properly with WarningAction set to "handle"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 2.0.0-M1
    • Component/s: diagnostics
    • Labels:
      None
    • Environment:
      Kodo 4.1.4
      OpenJPA 1.0.0
      MS SQL 2005
      MS JDBC DRIVER VERSION 1.1
      JDK 1.5

      Description

      If set "kodo.ConnectionFactoryProperties" "warningAction" to "throw" or "handle", when an INSERT statement fails due
      to an attempt to insert null into a non-null column, log output is "The statement has been
      terminated".
      If didn't set "warningAction", the default value is "ignore". It logs correct SQLException which is as follows:

      Cannot
      insert the value NULL into column 'TestTimeNotNullNoDefaultUtc', table
      'STADatabase.dbo.DefaultValuesJ'; column does not allow nulls. INSERT fails.
      {prepstmnt 112461492
      ... ...

      In org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.LoggingPreparedStatement.executeUpdate(), the
      code is
      public int executeUpdate(String sql) throws SQLException {
      _sql = sql;
      logSQL(this);
      long start = System.currentTimeMillis();
      try

      { return super.executeUpdate(sql); }

      catch (SQLException se)

      { throw wrap(se, LoggingStatement.this); }

      finally

      { logTime(start); handleSQLWarning(LoggingStatement.this); }

      }
      In this test case, it got a SQLWarning with msg 'The statement has been
      terminated' and a SQLException which tells Column null is not allowed.
      When WarningAction is set to 'throw' or 'handle' and if handle doesn't
      consume the warning but throw it, the SQLWarning is thrown from finally
      block.
      The SQLWarning which it is a subclass of SQLException will be processed by
      DBdictionary.newStoreException() so we see the incorrect message.

      1. openJPA-699.patch
        9 kB
        Xiaoqin Feng
      2. openJPA-699-v2.patch
        31 kB
        Xiaoqin Feng

        Activity

        Xiaoqin Feng created issue -
        Xiaoqin Feng made changes -
        Field Original Value New Value
        Attachment openJPA-699.patch [ 12388776 ]
        Xiaoqin Feng made changes -
        Attachment openJPA-699-v2.patch [ 12388928 ]
        Abe White made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Donald Woods made changes -
        Fix Version/s 2.0.0-M1 [ 12313624 ]
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Xiaoqin Feng
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development