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

javax.sql.rowset.BaseRowSet:getParams after setBinStream


    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
    • CPU:
    • OS:


      Name: sdR10048 Date: 08/29/2003

      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b16"
      Tests fail:


      Specification excerpt:
      --------- J2SE API spec v.1.5 ---------
      public void setBinaryStream(int parameterIndex,
                                  java.io.InputStream x,
                                  int length)
                           throws java.sql.SQLException
      Sets the designated parameter to the given java.io.InputStream in the Java
      programming language, which will have the specified number of bytes.
      The contents of the stream will be read and sent to the database.

      When a very large binary value is input to a LONGVARBINARY parameter,
      it may be more practical to send it via a java.io.InputStream object.
      A JDBC technology-enabled driver will read the data from the stream as
      needed until it reaches end-of-file.

      Note: This stream object can either be a standard Java stream object or
      your own subclass that implements the standard interface.

      The parameter value set by this method is stored internally and will be
      supplied as the appropriate parameter in this JDBC RowSet's command
       when the method execute is called.

      Primitives and object instances values to be used as JDBC RowSet
      command parameters are stored internally as object instances in an
      internal Vector object instance. Subsequent calls to getParams ouput
      an object array of the current command parameters that is a direct
      representation of the current internal command parameters.

      parameterIndex - the ordinal number of the placeholder parameter in
      this RowSet object's command that is to be set. The first parameter
      is 1, the second is 2, and so on; must be 1 or greater
      x - the java input stream that contains the binary parameter value
      length - the number of bytes in the stream
      java.sql.SQLException - if an error occurs or the parameter index is out of bounds


      public java.lang.Object[] getParams()
                                   throws java.sql.SQLException
      Retrieves an array containing the parameter values that have been set for this RowSet object's command. Before the command is sent to the DBMS to be executed, these parameters will be substituted for placeholder parameters in the PreparedStatement object that is the command for this RowSet object.

      Each element in the array that is returned is an Object instance that contains the values of the parameters supplied to a setter method. The order of the elements is determined by the value supplied for parameterIndex. If the setter method takes only the parameter index and the value to be set, the array element will contain the value to be set (which must be expressed as an Object). If there are additional parameters, the array element will itself be an array containing the value to be set plus any additional parameter values supplied to the setter method. These additional parameters are for the use of the driver or the DBMS and may or may not be used.

      an array of Object instances that includes the parameter values that may be set in this RowSet object's command; an empty array if no parameters have been set
      java.sql.SQLException - if an error occurs
      ---------- end-of-excerpt ---------------

      Problem description
      Method getParams() return wrong array of parameters after setBinaryStream(,,)
      method call. The same with setUnicodeStream method. See demo:

      import javax.sql.rowset.*;
      import javax.sql.*;
      import java.sql.*;
      import java.io.*;

      public class T {

          public static void main(String[] args) {
              MyBaseRowSet rs = new MyBaseRowSet();
              byte bytes[] = {1,2,3,4,5};
              try {
                  rs.setCommand("select name from thetable");
                  rs.setBinaryStream(1, new ByteArrayInputStream(bytes),3);
                  Object[] output = rs.getParams();
                  System.out.println("len: "+output.length);
                  Object[] param1 = (Object[])output[0];
                  for (int i=0;i<param1.length;i++) {
                      System.out.println("param1["+i+"]: "+param1[i]);
              } catch (Exception e) {

      class MyBaseRowSet extends BaseRowSet {

          public MyBaseRowSet() {
          public void initParams() {

      Demo's output:
      len: 1
      param1[0]: java.io.ByteArrayInputStream@1a7bf11
      param1[1]: 3
      param1[2]: 1

      // the first parameter (param1) should have size of 2 as spec says.


      Name: sdR10048 Date: 02/04/2004

      This testcase:
      has the same problem. Third element should be expected in getParams().





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


              • Created: