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

Blob.setBytes differs between embedded and client driver when the specified length is invalid



    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • JDBC
    • Normal
    • Newcomer
    • Embedded/Client difference


      Blob.setBytes behaves differently with the embedded driver and the client driver.
      Assume a 1 byte array and a specified length of 2: Blob.setBytes(1, new byte[]


      , 0, 2)
      Embedded: IndexOutOfBoundsException (from java.io.RandomAccessFile.writeBytes or System.arraycopy)
      Client: succeeds, returns insertion count 1

      The behavior should be made consistent, but what is the correct behavior?

      From the Blob.setBytes JavaDoc:
      "Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written. Writing starts at position pos in the BLOB value; len bytes from the given byte array are written. The array of bytes will overwrite the existing bytes in the Blob object starting at the position pos. If the end of the Blob value is reached while writing the array of bytes, then the length of the Blob value will be increased to accomodate the extra bytes."


        1. Derby3898.java
          1 kB
          Katherine Marsden
        2. derby-3898-1.patch
          13 kB
          Yun Lee
        3. derby-3898-1.stat
          0.4 kB
          Yun Lee
        4. derby-3898-testcase.patch
          3 kB
          Yun Lee
        5. derby-3898-testcase.stat
          0.1 kB
          Yun Lee
        6. enable-javame.diff
          0.9 kB
          Knut Anders Hatlen
        7. overflow.diff
          2 kB
          Knut Anders Hatlen

        Issue Links



              yunlee Yun Lee
              kristwaa Kristian Waagan
              0 Vote for this issue
              0 Start watching this issue