DdlUtils
  1. DdlUtils
  2. DDLUTILS-29

"Stream is already closed" with Oracle

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0 RC1
    • Component/s: Core - Oracle
    • Labels:
      None
    • Environment:
      Using oracle10g jdbc client driver with oracle 8i server

      Description

      I get a SQLException stating that the "stream is already closed".
      It occurs in at org.apache.ddlutils.io.JdbcModelReader.getValueAsString
      for the "COLUMN_DEF" column.

      Here is the stack trace - as you can see, I am using the ant task, with the sample xml provided on DdlUtils' site.

      java.sql.SQLException: Le flux de données est déjà fermé
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
      at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:166)
      at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:207)
      at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:390)
      at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:355)
      at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1559)
      at org.apache.ddlutils.io.JdbcModelReader.getValueAsString(JdbcModelReader.java:494)
      at org.apache.ddlutils.io.JdbcModelReader.getColumnsForTable(JdbcModelReader.java:277)
      at org.apache.ddlutils.io.JdbcModelReader.getTables(JdbcModelReader.java:205)
      at org.apache.ddlutils.io.JdbcModelReader.getDatabase(JdbcModelReader.java:140)
      at org.apache.ddlutils.task.DatabaseToDdlTask.readSchema(DatabaseToDdlTask.java:194)
      at org.apache.ddlutils.task.DatabaseToDdlTask.execute(DatabaseToDdlTask.java:214)

      I have tested it with 8i, 9i and 10g versions of the client oracle driver - same result.

      It highly looks like this is a bug in oracle's drivers management of Long fields.

      My tests proved that resultset.getString("COLUMN_DEF") :
      +can't be called twice (if .next() is not called obviously)
      +always fails for primary fields with 9i- drivers
      +fails if called after e.g. .getString("IS_NULLABLE") with 10g drivers
      +works OK if called first with 10g drivers

      So what I did is modify
      JdbcModelReader.getColumnsForTable(DatabaseMetaData, String)
      and move the call of
      getValueAsString(..., "COLUMN_DEF", ...)
      to be the first one called. This works perfectly on my platform now.

      I'll attach the corresponding patch

        Activity

        Alexandre Borgoltz created issue -
        Alexandre Borgoltz made changes -
        Field Original Value New Value
        Attachment oracle_COLUMN_DEF_bug.patch [ 12314841 ]
        Thomas Dudziak made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Thomas Dudziak made changes -
        Component/s Core - Oracle [ 12311217 ]
        Thomas Dudziak made changes -
        Fix Version/s 1.0 RC1 [ 12312482 ]

          People

          • Assignee:
            Thomas Dudziak
            Reporter:
            Alexandre Borgoltz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development