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

SyncResolver.getConflictValue(int) throws SQLException: Invalid cursor position

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • 6
    • core-libs
    • None
    • b95
    • generic
    • generic
    • Verified

      JDK : Java HotSpot(TM) Client VM (build 1.6.0-beta2-b81, mixed mode)
      DB : Oracle 9i, DB2 8.1, SQL Server 2000
      Driver : Oracle/I-Net Oranxo.jar, DB2/DataDirect 3.4, SQL Server/I-Net Merlia.jar
      Platform[s] : Any


      Test source location:
      =====================
      /net/cady/export/dtf/unified/knight-ws/suites/jdbc/jdbc/src/javax_sql_rowset/syncresolver/SyncResolver1_003/SyncResolver1_003.java


      Testcase Description (SyncResolver1_003):
      =========================================
      Check the default constructor for CachedRowSet instance without arguments. An implementation of CachedRowSet should be able to get a CahedRowSet handle.


      How to reproduce:
      =================
      1) cd /net/cady/export/sqa/js159705/jdbc/bugs/[bug id]
      2) ksh Run_Standalone.ksh
      3) Results will be in workDir/$username.$os.$arch/$testcase/ directory.

      Other options:
      To change other options (such as changing the JDK, database, connection string), you can edit setup file in that directory before running the Run_Standalone.ksh.

      Tonga Log output:
      =================
      [2006-04-24T21:23:07.10] SQL Exception encountered Invalid cursor position
      [2006-04-24T21:23:13.64] Error: SyncResolver1_003 : CachedRowSet Test Failed
      [2006-04-24T21:23:13.64] com.sun.j2se_sqe.jdbc.utils.TestFailureException: CachedRowSet Test Failed
      [2006-04-24T21:23:13.64] at SyncResolver1_003.doTest(SyncResolver1_003.java:195)
      [2006-04-24T21:23:13.64] at SyncResolver1_003.main(SyncResolver1_003.java:240)
      [2006-04-24T21:23:13.64] Caused by: java.sql.SQLException: Invalid cursor position
      [2006-04-24T21:23:13.64] at com.sun.rowset.internal.SyncResolverImpl.getConflictValue(SyncResolverImpl.java:136)
      [2006-04-24T21:23:13.64] at SyncResolver1_003.doTest(SyncResolver1_003.java:179)
      [2006-04-24T21:23:13.64] ... 1 more
      [2006-04-24T21:23:13.64] PropertyReader: SQL_DIR_PATH=/home/js159705/test/workDir
      [2006-04-24T21:23:13.64] PropertyReader: SQL_FILE_NAME=initdb.conf
      [2006-04-24T21:23:13.64] PropertyReader: SQL_ABS_PATH=/home/js159705/test/workDir/initdb.conf
      [2006-04-24T21:23:13.64] Got two connection handles
      [2006-04-24T21:23:13.64] Setting table name as:tmp_rowset3
      [2006-04-24T21:23:13.64] Setting key columns for CachedRowSet
      [2006-04-24T21:23:13.64] Populated a RowSet.
      [2006-04-24T21:23:13.64] Size of rowset is :5
      [2006-04-24T21:23:13.64] Inserted a row in the cachedrowset
      [2006-04-24T21:23:13.64] Creating a new Statement object
      [2006-04-24T21:23:13.64] Got a new ResultSet object
      [2006-04-24T21:23:13.64] Inserted a row in the database
      [2006-04-24T21:23:13.64] SPE thrown. Getting the sync resolver object
      [2006-04-24T21:23:13.64] Got the sync resolver object :com.sun.rowset.internal.SyncResolverImpl@765a16
      [2006-04-24T21:23:13.64] In SyncResolver.INSERT_ROW_CONFLICT


      Test case code:
      ===============
          /**
           * @testName: SyncResolver1_003 (same as SyncResolver1/testSyncResolverInsert)
           *
           * @assertion:
           *
           * @test_Strategy: Check the default constructor for CachedRowSet
           * instance without arguments.
           * An implementation of CachedRowSet should be able
           * to get a CahedRowSet handle.
           */
          public void doTest() throws TestFailureException {
              try {
                  int keyCols[] = {3};
                  int row,colConflict;
                  boolean bool = false;

                  Statement stmt1, stmt2;
                  ResultSet rs1,rs2;
                  Connection con1, con2;

                  CachedRowSet crs;

                  con1 = DriverManager.getConnection(strUrl, strUserId, strPassword);
                  con2 = DriverManager.getConnection(strUrl, strUserId, strPassword);
                  logMsg("Got two connection handles");

                  stmt1 = con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
                  rs1 = stmt1.executeQuery(strQuery3);

                  crs = new CachedRowSetImpl();

                  crs.setTableName("tmp_rowset3");
                  logMsg("Setting table name as:"+crs.getTableName());

                  crs.setKeyColumns(keyCols);
                  logMsg("Setting key columns for CachedRowSet ");

                  crs.setCommand(strQuery3);

                  crs.populate(rs1);
                  logMsg("Populated a RowSet. ");
                  logMsg("Size of rowset is :"+crs.size());


                  crs.moveToInsertRow();
                  crs.updateInt(1,6);
                  crs.updateString(2,"six");
                  crs.updateInt(3,60);
                  crs.insertRow();
                  crs.moveToCurrentRow();
                  logMsg("Inserted a row in the cachedrowset");

                  stmt2 = con2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
                  logMsg("Creating a new Statement object");

                  rs2 = stmt2.executeQuery(strQuery3);
                  logMsg("Got a new ResultSet object");
                  rs2.beforeFirst();

                  row = 0;
                  rs2.moveToInsertRow();
                  rs2.updateInt(1,6);
                  rs2.updateString(2,"sixsix");
                  rs2.updateDouble(3,600);
                  rs2.insertRow();

                  rs2.moveToCurrentRow();
                  logMsg("Inserted a row in the database");

                  try {

                      crs.acceptChanges(con1);

                  } catch(SyncProviderException spe){

                      logMsg("SPE thrown. Getting the sync resolver object");

                      SyncResolver syncRes = spe.getSyncResolver();
                      logMsg("Got the sync resolver object :"+syncRes);

                      row = 1;

                      while(syncRes.nextConflict()) {

                          Object obj1 = "cachedrowset";
                          Integer obj2 = new Integer(2);

                          if(syncRes.getStatus() == SyncResolver.INSERT_ROW_CONFLICT ) {
                              logMsg("In SyncResolver.INSERT_ROW_CONFLICT");
                              for(int j=1;j<= crs.getMetaData().getColumnCount();j++) {
                                  logMsg("Conflicted value is :"+ syncRes.getConflictValue(j));
                              } //end for
                              bool = true;
                          }

                      } //end while

                      if(!bool) {
                          throw new TestFailureException("RowSet test failed.");
                      }
                  }

                  crs.commit();

              } catch (SQLException sqle) {
                  logErr("SQL Exception encountered " + sqle.getMessage());
                  throw new TestFailureException("CachedRowSet Test Failed", sqle);
              } catch (Exception e) {
                  logErr("Unexpected Exception " + e.getMessage());
                  throw new TestFailureException("CachedRowSet Test Failed", e);
              }
          }

            ssharmasunw Sushmita Sharma (Inactive)
            jsuensunw Jesse Suen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: