Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-4842

PutDatabaseRecord throws "stream has all ready been closed" with oracle default values

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.5.0
    • Fix Version/s: None
    • Component/s: Extensions
    • Environment:
      Oracle
    • Flags:
      Patch

      Description

      When inserting into an oracle database (using ojdbc7 as the driver),  

      to a table with one of its fields has a default value, the putdatabaserecord processor throws "stream has already been closed" exception.

      i explored the problem for quite, even going as far as taking the code and debugging it on my pc

      after a little bit of time i figured out what the problem was. 

      The problem occurs while getting the TableSchema from the database (line 1018)

      the DataBaseMetaData .getColumns method returns a result set of the descriptions of all the columns of the table, including the defaultvalue, which comes as a LONG typed variable

      when trying to create a ColumnDescription object from the result set it gets values such as the name of the column, datatype and default value

      But duo to a low level oracle protocol flaw you cannot fetch  LONG typed columns from the database unless it comes before any of the other cloumns.

      https://blog.jooq.org/2015/12/30/oracle-long-and-long-raw-causing-stream-has-already-been-closed-exception/

       

      to fix this i just moved line number 1088 

      final String defaultValue = resultSet.getString("COLUMN_DEF");

      to one line before line 1082

      final String columnName = resultSet.getString("COLUMN_NAME");

       

      i know it's a weird problem, and even a weirder solution. 

      I would appreciate it greatly if you could make this upgrade to the PutDatabaseRecord processor

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Max Kelada Nimrod Avni
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: