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

Unclear what is the initial cursor position once @Select had queried one or more rows.

XMLWordPrintable

    • b63
    • generic
    • generic
    • Verified

      It is unclear of what should the inital cursor position once @Select statement is invoked. Currently looks like the cursor is pointing the first row; however, from doc stated it is similar to ResultSet, so I think it should position before the first row.


      From the Doc:
      Select: The returned DataSet is treated similar to a ResultSet object.

      ResultSet: A ResultSet object maintains a cursor pointing to its current row of data.
      Initially the cursor is positioned before the first row.


      JDK : 1.6.0 PIT
        Java(TM) 2 Runtime Environment, Standard Edition (build
        1.6.0-internal-sk149173_19_Oct_2005_00_43-b00)
        Java HotSpot(TM) Client VM (build 1.6.0-ea-b56, mixed mode)
      DB : ORCL
      VM : client
      switch/Mode : default
      Platform[s] : Sol 10 sparc and Linux RHAS4

      Test owner :
      Failing Test :

          java_sql_eod/dataset/DataSet001_010 compile_and_execute

      TestBase Location:
      ==================

          /net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child

      Test source location:
      =====================
          /net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child/jdbc/src/java_sql_eod/dataset/DataSet001_010/*.java

      Share source location:
      ======================
         /net/cady/export/sqa/tcheung/jdbc/SQE/6.0_child/jdbc/share
         /net/cady/export/sqa/tcheung/jdbc/SQE/6.0_child/share

      tlog file location:
      ==================
      /net/cady.sfbay/export/sqa/tcheung/jdbc/BUGS/[bug id]

      How to reproduce:
      ====================

         1. cd /net/cady.sfbay/export/sqa/tcheung/jdbc/BUGS/[bug id]
         2. DataSet001_010.tlog (your JDK)
          or

         1) Copy the setup and Run_Standalone.ksh from $TestBase/jdbc to your local dir.
             cp /net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child/jdbc/Run_Standalone.ksh .

         2) Craete a your testlist.
              echo "java_sql_eod/dataset/DataSet001_010 compile_and_execute" > mytestlist

         3) Overwrite the default environment variables.
             export PIT_HOME=/net/cady.sfbay/export/sqa/tcheung/jdbc/SQE/6.0_child
             export TESTLIST = `pwd`/mytestlist
             export JDK_PATH="your jdk"
           if needed.
             export VM_OPTS=""
             export DB_NAME=""
             export DB_DRIVER_NAME=""
             export DB_CONNECTION_NAME=""
             export DB_CONNECTION_STRING=""
             export DB_LOGIN_NAME=""
             export DB_LOGIN_PASSWORD=""

         4) Run_Standalone.ksh.

          Read $TestBase/jdbc/docs/Run_Standalone.README for more detail.

      --------Sample Test/Script START---------------------
      ******* Sample test will not run as standalone java program ******
      interface I_Query006 extends BaseQuery {
          @Select(sql="SELECT firstName, lastName, id, age from dataset001 order by id asc ")
          DataSet<PersonInfo> getPersons() throws SQLRuntimeException;
      }
      try {
                  System.out.println(this.getClass().getName()+".doTest() : getting QueryObject handle(JDBC 3.0)....");
                  //this invocation is for JDBC 3.0 compliant drivers
                  query = QueryObjectFactory.createQueryObject(I_Query006.class, con);
                  System.out.println(this.getClass().getName()+".doTest() : got QueryObject handle(JDBC 3.0) ");
              } catch (SQLException sqlEx) {
                  System.err.println(this.getClass().getName()+": SQLException caught "+sqlEx.getMessage());
                  //free the resources
                  utils.closeConnection(con);
                  throw new TestFailureException
                          ("Exception when QueryObjectFactory.createQueryObject. [Message="+sqlEx.getMessage()+"]", sqlEx);
              }
              
              //get the DataSet object
              System.out.println(this.getClass().getName()+".doTest() : Executing @Query....");
              
              try {
                  rows = query.getPersons();
              }catch (SQLRuntimeException ex) {
                  System.err.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught when executing @Query : "+ex.getMessage());
                  throw new TestFailureException
                          ("Un-Expected Exception when getting DataSet by executing @Query. [Message="+ex.getMessage()+"]", ex);
              }

              if (null == rows || rows.size() != 5) {
                  System.out.println(this.getClass().getName()+".doTest() : DataSet returned by @Query is not of expected size. TEST FAILED");
                  throw new TestFailureException("DataSet returned by @Query is not of expected size. TEST FAILED");
              }

              System.out.println(this.getClass().getName()+".doTest() : Got Dataset. Executing DataSet.getRow() & ensuring that Data has been filled as expected. ....");
              //ensure that all the data is returned as expected.
              
              //without positioning on any row, call DS.getRow()
              
              PersonInfo person = null;
              try {
                  person = rows.getRow();
              }catch (SQLRuntimeException ex){
                  System.err.println(this.getClass().getName()+".doTest() : SQLRuntimeException caught when executing DataSet.getRow(). Expected behaviour. : "+ex.getMessage());
                  ex.printStackTrace();
                  System.out.println(this.getClass().getName()+".doTest() : TEST PASSED");
                  return;
              }


      ===========================
      public class PersonInfo {
          
          private long id ;
          private String firstName ;
          private String lastName ;
          private int age ;

          public long getId() {
              return id;
          }

          public void setId(long id) {
              this.id = id;
          }

          public String getFirstName() {
              return firstName;
          }

          public void setFirstName(String firstName) {
              this.firstName = firstName;
          }

          public String getLastName() {
              return lastName;
          }

          public void setLastName(String lastName) {
              this.lastName = lastName;
          }

          public int getAge() {
              return age;
          }

          public void setAge(int age) {
              this.age = age;
          }
      }

      --------Sample Test/Script END----------------------

      Test output:
      =============

      DataSet001_010.doTest() : getting Connection object....
      DataSet001_010.doTest() : getting QueryObject handle(JDBC 3.0)....
      DataSet001_010.doTest() : got QueryObject handle(JDBC 3.0)
      DataSet001_010.doTest() : Executing @Query....
      DataSet001_010.doTest() : Got Dataset. Executing DataSet.getRow() & ensuring that Data has been filled as expected. ....
      The current row is :player4_fName
      DataSet001_010.doTest() : TEST FAILED
      TEST FAILED : DataSet001_010.doTest() :No SQLException thrown when calling DataSet.getRow() w/o positioning at any row in the DataSet
      com.sun.j2se_sqe.jdbc.utils.TestFailureException: No SQLException thrown when calling DataSet.getRow() w/o positioning at any row in the DataSet
              at DataSet001_010.doTest(DataSet001_010.java:101)
              at DataSet001_010.main(DataSet001_010.java:159)

      Specific Machine Info:
      =====================
      For Solaris[sparc/x86] ->
      orthello>uname -a
      SunOS orthello 5.10 Generic sun4u sparc SUNW,Ultra-60

      For Linux ->
      [dtftest@inclusion Update001_SQL_003]$ uname -a
      Linux inclusion 2.6.9-16.EL #1 Mon Aug 15 19:58:49 EDT 2005 i686 i686 i386 GNU/Linux

            skaushiksunw Shreyas Kaushik (Inactive)
            tacheung Tak Wing Cheung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: