Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4916451

javax.sql.rowset.serial.SQLOutput.writeXXX write Serial wrap

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: sdR10048 Date: 09/03/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b16"
      JCK : 1.5
      Platform[s] : Solaris
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] :api/javax_sql/rowset/serial/SQLOutput/index.html#Write[SQLOutputImpl0001]
      api/javax_sql/rowset/serial/SQLOutput/index.html#Write[SQLOutputImpl0005]
      api/javax_sql/rowset/serial/SQLOutput/index.html#Write[SQLOutputImpl0008]
      api/javax_sql/rowset/serial/SQLOutput/index.html#Write[SQLOutputImpl0013]

      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
          /**
           * Writes an <code>Array</code> object in the Java
           * programming language to this <code>SQLOutputImpl</code>
           * object. The driver converts this value to an SQL <code>ARRAY<code>
           * value before returning it to the database.
           *
           * @param x an object representing an SQL <code>ARRAY</code> value
           * @throws SQLException if the write position is located at an invalid
           * position
           */
          public void writeArray(Array x) throws SQLException {

      ...
      ---------- end-of-excerpt ---------------

      Problem description
      ===================
      Methods:
        writeArray
        writeBlob
        writeClob
        writeRef

      write to the specified vector not the input parameter but the corresponding
      SerialXXX shell. That behaviour is unspecified. See demo.

          
      Minimized test:
      ===============
      ------- T.java -------
      import javax.sql.rowset.*;
      import javax.sql.rowset.serial.*;
      import java.util.*;
      import java.sql.*;
      import java.io.*;

      public class T {

          public static void main(String[] args) {
              try {
                  Vector vector = new Vector();
                  SQLOutputImpl out = new SQLOutputImpl(vector, null);
                  MyBlob blob = new MyBlob();
                  out.writeBlob(blob);
                  System.out.println(" size "+vector.size());
                  System.out.println(" [0] "+vector.get(0));
                  System.out.println("expected "+blob);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

      class MyBlob implements Blob {

          private byte array0[] = {};

          public long length() throws SQLException {
              return 0;
          }
          public byte[] getBytes(long pos, int length)
              throws SQLException {
              return array0;
          }
          public InputStream getBinaryStream()
              throws SQLException {
              return new ByteArrayInputStream(array0);
          }
          public long position(byte[] pattern, long start)
              throws SQLException {
              return 0;
          }
          public long position(Blob pattern, long start)
              throws SQLException {
              return 0;
          }
          public int setBytes(long pos, byte[] bytes)
              throws SQLException {
              return 0;
          }
          public int setBytes(long pos, byte[] bytes, int offset, int len)
              throws SQLException {
              return 0;
          }
          public OutputStream setBinaryStream(long pos)
              throws SQLException {
              return null;
          }
          public void truncate(long len)
              throws SQLException {
          }
      }

      ------- end-of-T.java -------

      Minimized test output:
      ======================
          size 1
           [0] javax.sql.rowset.serial.SerialBlob@93dee9
      expected MyBlob@fabe9

      ======================================================================

            jbrucesunw Jonathan Bruce (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: