Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-5090

Retrieving BLOB fields sometimes fails

    Details

    • Urgency:
      Low
    • Issue & fix info:
      Newcomer, Release Note Needed, Repro attached, Workaround attached
    • Bug behavior facts:
      Embedded/Client difference

      Description

      This is my first issue report, so please be understanding if I'm posting the wrong thing, in the wrong place or in the wrong way. I just want to help.

      While iterating through a ResultSet, when accessing a BLOB field to read its contents via an InputStream, I noticed that:

      • if the current ResultSet's has been "warmed up" by retrieving another column first, everything it's fine;
      • if, on the other hand, you first-thing access the BLOB (and read other columns later), then upon reading the first byte out the InputStream bound to the BLOB field (ResultSet.getBinaryStream("col_name")) an IOException is thrown (and IOException's getMessage() method returns null).

      Following is an example, taken from a real application. The two code segments only differ in the fact that a SMALLINT & VARCHAR read is done before/after the BLOB read.

      -Working snippet-
      [...]
      icRelPath[i] = "imm" + File.separator + "ic" + "" + rs.getShort("setIcone") + "" + i + "." + rs.getString("estensione");
      AutoCloseInputStream acis = new AutoCloseInputStream(rs.getBinaryStream("ic" + i));
      if (rs.wasNull())
      icRelPath[i] = null;
      else
      {
      //icRelPath[i] = "imm" + File.separator + "ic" + "" + rs.getShort("setIcone") + "" + i + "." + rs.getString("estensione");
      BufferedInputStream bis = new BufferedInputStream(acis);
      int b = bis.read();//READS FINE
      [...]

      -Broken snippet-
      [...]
      //icRelPath[i] = "imm" + File.separator + "ic" + "" + rs.getShort("setIcone") + "" + i + "." + rs.getString("estensione");
      AutoCloseInputStream acis = new AutoCloseInputStream(rs.getBinaryStream("ic" + i));
      if (rs.wasNull())
      icRelPath[i] = null;
      else
      {
      icRelPath[i] = "imm" + File.separator + "ic" + "" + rs.getShort("setIcone") + "" + i + "." + rs.getString("estensione");
      BufferedInputStream bis = new BufferedInputStream(acis);
      int b = bis.read();//THROWS IOException WITH A null ERROR MESSAGE STRING
      [...]

        Attachments

        1. releaseNote.html
          3 kB
          Kristian Waagan
        2. derby-5090-3a-change_messages.diff
          29 kB
          Kristian Waagan
        3. derby-5090-1b-fix.diff
          19 kB
          Kristian Waagan
        4. derby-5090-2a-test.stat
          0.2 kB
          Kristian Waagan
        5. derby-5090-2a-test.diff
          29 kB
          Kristian Waagan
        6. derby-5090-1a-fix.stat
          0.4 kB
          Kristian Waagan
        7. derby-5090-1a-fix.diff
          19 kB
          Kristian Waagan
        8. Derby5090_3.java
          1 kB
          Unai Vivi
        9. Derby5090_2.java
          1.0 kB
          Knut Anders Hatlen
        10. Derby5090.java
          0.8 kB
          Knut Anders Hatlen

          Issue Links

            Activity

              People

              • Assignee:
                kristwaa Kristian Waagan
                Reporter:
                unai Unai Vivi
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: