Examples of SQLInteger


Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Create a row.
    T_AccessRow r1 = new T_AccessRow(1);
    r1.setCol(0, new SQLInteger(value1));

    // Get a location template
    RowLocation rowloc = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc);

    // Update it to the second value
        DataValueDescriptor[] update_row  = new DataValueDescriptor[1];
        update_row[0] = new SQLInteger(value2);

        FormatableBitSet update_desc = new FormatableBitSet(1);
        update_desc.set(0);

    cc.replace(rowloc, update_row, update_desc);

    // Create a new row (of the same type, since the interface expects
    // the callers to be keeping the row types straight.
    T_AccessRow r2 = new T_AccessRow(1);
    SQLInteger c2 = new SQLInteger(0);
    r2.setCol(0, c2);

    // Fetch the stored value.
    if (!cc.fetch(rowloc, r2.getRowArray(), (FormatableBitSet) null))
        {
      throw T_Fail.testFailMsg("(insertAndUpdate) Fetch val not there.");
        }

    // Close the conglomerate.
    cc.close();

    // Make sure we read back the value we wrote.
    if (c2.getInt() != value2)
      throw T_Fail.testFailMsg("(insertAndUpdate) Fetch value != updated value.");
    else
      return true;
  }
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

    // Insert some values.
    int values[] = { 11, 22, 33, 44, 55, 66 };
    T_AccessRow row = new T_AccessRow(1);
    for (int i = 0; i < values.length; i++)
    {
      row.setCol(0, new SQLInteger(values[i]));
      if (cc.insert(row.getRowArray()) != 0)
        throw T_Fail.testFailMsg("(scanExample after insert) insert failed ");
    }

        // For test coverage call the debugging output routine - can't diff it.
        REPORT("(scanExample) debug output testing: " + tc.debugOpened());

    // Close the conglomerate.
    cc.close();

        if ((tc.countOpens(TransactionController.OPEN_TOTAL) > 0)        ||
            (tc.countOpens(TransactionController.OPEN_CONGLOMERATE) > 0) ||
            (tc.countOpens(TransactionController.OPEN_SCAN) > 0)         ||
            (tc.countOpens(TransactionController.OPEN_CREATED_SORTS) > 0)    ||
            (tc.countOpens(TransactionController.OPEN_SORT) > 0))
        {
            System.out.println("OPENED 1:\n" + tc.debugOpened());
            return(FAIL("unexpected open count."));
        }

    REPORT("(scanExample) rows inserted");

    // Correlates our position in the upcoming scan to the values array.
    int scanindex = 0;

    // Put a specific column in the row so we can look at it.
    SQLInteger col = new SQLInteger(0);
    row.setCol(0, col);

        flush_cache();

        StaticCompiledOpenConglomInfo static_info =
            tc.getStaticCompiledConglomInfo(conglomid);

    // Open a scan on the conglomerate.
    ScanController scan1 = tc.openCompiledScan(
      false, // don't hold
      0,     // not for update
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_SERIALIZABLE,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0,    // unused if stop position is null.
            static_info,
            tc.getDynamicCompiledConglomInfo(conglomid));

        // check out the RowCountable interface's.
       
        if (scan1.getEstimatedRowCount() != 6)
        {
            throw T_Fail.testFailMsg(
                "(scanExample) estimated row count not 6:" +
                scan1.getEstimatedRowCount());
        }

        // Test 2 - ASSERT(should be able to set arbitrary row count)

        scan1.setEstimatedRowCount(5);

        if (scan1.getEstimatedRowCount() != 5)
        {
            throw T_Fail.testFailMsg("(scanExample) estimated row count not 5");
        }


    // Iterate through and check that the rows are still there.
    while (scan1.next())
    {
      scan1.fetch(row.getRowArray());

      // Check we got the value we put in.
      if (col.getInt() != values[scanindex])
        throw T_Fail.testFailMsg("(scanExample after insert) Row "
          + scanindex
          + " should have been "
          + values[scanindex]
          + ", was "
          + col.getInt());

      scanindex++;
    }

        // make sure another next() call continues to return false.
        if (scan1.next())
            throw T_Fail.testFailMsg("(scanExample after insert) should continue to return false after reaching end of scan");

        // see if reopen scan interfaces work
    scan1.reopenScan(
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

        scan1.next();
        scan1.next();
        scan1.next();
        RowLocation third_row_rowloc = scan1.newRowLocationTemplate();
        scan1.fetchLocation(third_row_rowloc);

        // see if reopen scan interfaces work
    scan1.reopenScanByRowLocation(
            third_row_rowloc,
      null);

        scanindex = 2;
    while (scan1.next())
    {
      scan1.fetch(row.getRowArray());

      // Check we got the value we put in.
      if (col.getInt() != values[scanindex])
        throw T_Fail.testFailMsg("(scanExample after insert) Row "
          + scanindex
          + " should have been "
          + values[scanindex]
          + ", was "
          + col.getInt());

      scanindex++;
    }

    scan1.close();

    // Check we saw the right number of rows.
    if (scanindex != values.length)
      throw T_Fail.testFailMsg("(scanExample after insert) Expected "
        + values.length
        + "rows, got "
        + scanindex);

    REPORT("(scanExample) rows present and accounted for");

    // Open another scan on the conglomerate.
    ScanController scan2 = tc.openScan(
      conglomid,
      false, // don't hold
      TransactionController.OPENMODE_FORUPDATE, // for update
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_SERIALIZABLE,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

    // Iterate with the second scan and fiddle with the values so they
    // look like the new value array.
    int newvalues[] = { 22, 33, 444, 55, 6666 };
     while (scan2.next())
    {
      scan2.fetch(row.getRowArray());

      switch(((SQLInteger) row.getCol(0)).getInt())
      {
      case 11:
        if (!scan2.delete())
          throw T_Fail.testFailMsg("(scanExample) delete failed.");
        break;
      case 22:
      case 33:
      case 55:
        // leave these alone
        break;
      case 44:
                DataValueDescriptor[] update_row  = new DataValueDescriptor[1];
                update_row[0] = new SQLInteger(444);

                FormatableBitSet update_desc = new FormatableBitSet(1);
                update_desc.set(0);

        if (!scan2.replace(update_row, update_desc))
                {
          throw T_Fail.testFailMsg(
                        "(scanExample) partial column row replace failed.");
                }
        break;
      case 66:
        row.setCol(0, new SQLInteger(6666));
        if (!scan2.replace(row.getRowArray(), (FormatableBitSet) null))
          throw T_Fail.testFailMsg("(scanExample) replace failed.");
        break;
      default:
        throw T_Fail.testFailMsg("(scanExample) Read unexpected value.");
      }
    }
    scan2.close();

    REPORT("(scanExample) rows fiddled with");

    // Open a third scan on the conglomerate.
    ScanController scan3 = tc.openScan(
      conglomid,
      false, // don't hold
      0, // not for update
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_SERIALIZABLE,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

    // Iterate through and inspect the changes.
    scanindex = 0;
    row.setCol(0, col);
    while (scan3.next())
    {
      scan3.fetch(row.getRowArray());

      REPORT("(scanExample) scan3 fetched " + col.getInt());

      // Check we got the value we put in.
      if (col.getInt() != newvalues[scanindex])
        throw T_Fail.testFailMsg("(scanExample after changes) Row "
          + scanindex
          + " should have been "
          + newvalues[scanindex]
          + ", was "
          + col.getInt());

      scanindex++;
    }
    scan3.close();

    // Open a third scan on the conglomerate.
    scan3 = tc.openScan(
      conglomid,
      false, // don't hold
      0, // not for update
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_READ_UNCOMMITTED,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

    // Iterate through and inspect the changes.
    scanindex = 0;
    row.setCol(0, col);
    while (scan3.next())
    {
      scan3.fetch(row.getRowArray());

      REPORT("(scanExample) scan3 fetched " + col.getInt());

      // Check we got the value we put in.
      if (col.getInt() != newvalues[scanindex])
        throw T_Fail.testFailMsg("(scanExample after changes) Row "
          + scanindex
          + " should have been "
          + newvalues[scanindex]
          + ", was "
          + col.getInt());

      scanindex++;
    }
    scan3.close();
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Create a 1 column row. int column = 1.
    T_AccessRow r1 = new T_AccessRow(1);
    SQLInteger c1 = new SQLInteger(1);
    r1.setCol(0, c1);

    // Get a location template
    RowLocation rowloc1 = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc1);

        // create another 1 column row. int column = 2.
    // Get a location template
        r1.setCol(0, new SQLInteger(2));
    RowLocation rowloc2 = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc2);

        // At this point the table looks like:
        // col1
        // ----
        // 1
        // 2

        // RESOLVE - currently the store can't catch the following error:
        /*
        // Test that we can't alter while it is open.
        try
        {
            tc.addColumnToConglomerate(conglomid, 1, c1);
      throw T_Fail.testFailMsg(
                "(alterTable) Allowed alter table while table was open.");
        }
        catch (StandardException t)
        {
            // expected error continue the test.
        }
        */

        // Test that we can't add data to columns that don't exist

        // Currently we only error check in debug code. 
        // RESOLVE - should this be a runtime error?
        if (SanityManager.DEBUG)
        {
            try
            {
                T_AccessRow two_column_row = new T_AccessRow(2);
                SQLInteger col1        = new SQLInteger(3);
                SQLInteger col2        = new SQLInteger(3);
                cc.insert(two_column_row.getRowArray());
                throw T_Fail.testFailMsg(
                    "(alterTable) Allowed insert of bad row.");
            }
            catch (StandardException t)
            {
                // expected error continue the test.
            }
        }

        // Test that we can't fetch data columns that don't exist

        // Currently we only error check for this in sanity code.
        // RESOLVE - (mikem) should we check for this in released runtime?
        if (SanityManager.DEBUG)
        {
            try
            {
                T_AccessRow two_column_row = new T_AccessRow(2);
                if (!cc.fetch(
                        rowloc1, two_column_row.getRowArray(), (FormatableBitSet) null))
                {
                    throw T_Fail.testFailMsg(
                        "(alterTable) Allowed fetch of bad row, bad ret val.");
                }

                throw T_Fail.testFailMsg(
                    "(alterTable) Allowed fetch of bad row.");
            }
            catch (StandardException t)
            {
                // expected error continue the test.
            }
        }

        // Test that we can't fetch data columns that don't exist
        // Currently we only error check for this in sanity code.
        // RESOLVE - (mikem) should we check for this in released runtime?
        if (SanityManager.DEBUG)
        {
            try
            {
                DataValueDescriptor[] third_column_row =
                    new DataValueDescriptor[3];

                third_column_row[2]         = new SQLInteger(3);

                FormatableBitSet   fetch_desc        = new FormatableBitSet(3);
                fetch_desc.set(2);

                if (!cc.fetch(
                        rowloc1, third_column_row, fetch_desc))
                {
                    throw T_Fail.testFailMsg(
                        "(alterTable) Allowed fetch of bad row, bad ret val.");
                }

                throw T_Fail.testFailMsg(
                    "(alterTable) Allowed fetch of bad row.");
            }
            catch (StandardException t)
            {
                // expected error continue the test.
            }
        }

        // Test that we can't replace data columns that don't exist

        // Currently we only error check for this in sanity code.
        // RESOLVE - (mikem) should we check for this in released runtime?
        if (SanityManager.DEBUG)
        {
            try
            {
                T_AccessRow two_column_row = new T_AccessRow(2);
                SQLInteger col1        = new SQLInteger(3);
                SQLInteger col2        = new SQLInteger(3);
                cc.replace(rowloc1, two_column_row.getRowArray(), null);
                throw T_Fail.testFailMsg(
                    "(alterTable) Allowed replace of bad row.");
            }
            catch (StandardException t)
            {
                // expected error continue the test.
            }
        }

        // Test that we can't replace data columns that don't exist
        if (SanityManager.DEBUG)
        {
            try
            {
                DataValueDescriptor[] second_column_row  =
                    new DataValueDescriptor[2];
                second_column_row[1]        = new SQLInteger(3);

                FormatableBitSet   update_desc        = new FormatableBitSet(2);
                update_desc.set(1);

                cc.replace(rowloc1, second_column_row, update_desc);
                throw T_Fail.testFailMsg(
                    "(alterTable) Allowed partial row update of bad column.");
            }
            catch (StandardException t)
            {
                // expected error continue the test.
            }
        }

    // Make sure commitNoSync gets executed sometimes.
        tc.commitNoSync(TransactionController.RELEASE_LOCKS);


        // now alter the conglomerate, add another int column
        tc.addColumnToConglomerate(conglomid, 1, c1);

        // Open the table after the close done by commit.
    cc = tc.openConglomerate(
                conglomid,
                false,
                TransactionController.OPENMODE_FORUPDATE,
                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

        T_AccessRow two_column_row = new T_AccessRow(2);
        SQLInteger col1        = new SQLInteger(3);
        SQLInteger col2        = new SQLInteger(3);

        // fetch the rows and make sure you get null's in new fields.
        if (!cc.fetch(
                rowloc1, two_column_row.getRowArray(), (FormatableBitSet) null))
        {
      throw T_Fail.testFailMsg(
                "(alterTable) Row not there.");
        }

        if ((((SQLInteger)two_column_row.getCol(0)).getInt() != 1) ||
            (!two_column_row.getCol(1).isNull()))
        {
      throw T_Fail.testFailMsg(
                "(alterTable) Bad column value after alter.");
        }
        if (!cc.fetch(
                rowloc2, two_column_row.getRowArray(), (FormatableBitSet) null))
        {
      throw T_Fail.testFailMsg(
                "(alterTable) Row not there.");
        }

        if ((((SQLInteger)two_column_row.getCol(0)).getInt() != 2) ||
            (!two_column_row.getCol(1).isNull()))
        {
      throw T_Fail.testFailMsg(
                "(alterTable) Bad column value after alter.");
        }

        // make sure insert of 2 column row works.
        two_column_row = new T_AccessRow(2);
        two_column_row.setCol(0, new SQLInteger(3));
        two_column_row.setCol(1, new SQLInteger(300));
        cc.insert(two_column_row.getRowArray());


        // At this point the table looks like:
        // col1 col2
        // ---- ----
        // 1    NA
        // 2    NA
        // 3    300

       
    ScanController scan = tc.openScan(
      conglomid,
      false,  // don't hold
      TransactionController.OPENMODE_FORUPDATE, // for update
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_SERIALIZABLE,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

        while (scan.next())
        {
            scan.fetch(two_column_row.getRowArray());

            key_value = ((SQLInteger)two_column_row.getCol(0)).getInt();

            switch(key_value)
            {
                case 1:
                {
                    // Set non-existent column value to 100
                    if (!two_column_row.getCol(1).isNull())
                    {
                        throw T_Fail.testFailMsg(
                            "(alterTable) Bad column value after alter.");
                    }

                    // test that replace field works on alter added column
                    // make result row be: (1, 100)

                    two_column_row.setCol(1, new SQLInteger(100));

                    scan.replace(two_column_row.getRowArray(), (FormatableBitSet) null);
                    break;
                }
                case 2:
                {
                    if (!two_column_row.getCol(1).isNull())
                    {
                        throw T_Fail.testFailMsg(
                            "(alterTable) Bad column value after alter.");
                    }

                    // test that replace row works on alter added column row.
                    // make result row be: (2, 200)
                    two_column_row.setCol(1, new SQLInteger(200));

                    scan.replace(two_column_row.getRowArray(), (FormatableBitSet) null);

                    break;
                }
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Create a 1 column row. int column = 1.
    T_AccessRow r1 = new T_AccessRow(2);
    SQLInteger c1 = new SQLInteger(1);
    SQLInteger c2 = new SQLInteger(100);
    r1.setCol(0, c1);
    r1.setCol(1, c2);

    // Get a location template
    RowLocation rowloc1 = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc1);

        // create another 2 column row. int column = 2.
    // Get a location template
        r1.setCol(0, new SQLInteger(2));
        r1.setCol(1, new SQLInteger(200));
    RowLocation rowloc2 = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc2);
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Create a 1 column row. int column = 1.
    T_AccessRow r1 = new T_AccessRow(2);
    SQLInteger c1 = new SQLInteger(1);
    SQLInteger c2 = new SQLInteger(100);
    r1.setCol(0, c1);
    r1.setCol(1, c2);

    // Get a location template
    RowLocation rowloc1 = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc1);

        // create another 2 column row. int column = 2.
    // Get a location template
        r1.setCol(0, new SQLInteger(2));
        r1.setCol(1, new SQLInteger(200));
    RowLocation rowloc2 = cc.newRowLocationTemplate();

    // Insert the row and remember its location.
    cc.insertAndFetchLocation(r1.getRowArray(), rowloc2);
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_SERIALIZABLE);

            for (int i = 0; i < numcols; i++)
            {
                r1.setCol(i, new SQLInteger(numcols));
            }

            // time before
            before = System.currentTimeMillis();
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Create a 2 column row.
    T_AccessRow r1 = new T_AccessRow(2);
    SQLInteger c1 = new SQLInteger(1);
    SQLInteger c2 = new SQLInteger(100);
    r1.setCol(0, c1);
    r1.setCol(1, c2);

    // Get a location template
    RowLocation rowloc1 = cc.newRowLocationTemplate();
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

    // Create a 2 column row.
    T_AccessRow r1 = new T_AccessRow(2);
    SQLInteger c1 = new SQLInteger(1);
    SQLInteger c2 = new SQLInteger(100);
    r1.setCol(0, c1);
    r1.setCol(1, c2);

    // Get a location template
    RowLocation rowloc1 = cc.newRowLocationTemplate();
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

    int                   isolation_level)
    throws StandardException, T_Fail
  {
    // Create a 2 column row.
    T_AccessRow r1 = new T_AccessRow(2);
    SQLInteger c1 = new SQLInteger(1);
    SQLInteger c2 = new SQLInteger(100);
    r1.setCol(0, c1);
    r1.setCol(1, c2);

    // Create a heap conglomerate.
    long orig_conglomid =
            tc.createConglomerate(
                "heap",       // create a heap conglomerate
                r1.getRowArray(),
        null,   // column sort order not required for heap
                null,         // default properties
                TransactionController.IS_DEFAULT);       // not temporary

        // add rows 1 and 2
        ConglomerateController cc =
            tc.openConglomerate(
                orig_conglomid,
                false,
                TransactionController.OPENMODE_FORUPDATE,
                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

        // insert (1, 100)
    r1.setCol(0, new SQLInteger(1));
    r1.setCol(1, new SQLInteger(100));
        cc.insert(r1.getRowArray());

        // insert (2, 200)
    r1.setCol(0, new SQLInteger(2));
    r1.setCol(1, new SQLInteger(200));
        cc.insert(r1.getRowArray());

        // insert (3, 300)
    r1.setCol(0, new SQLInteger(3));
    r1.setCol(1, new SQLInteger(300));
        cc.insert(r1.getRowArray());

        cc.close();

        tc.commit();
       
    REPORT("(updatelocks ending.)");

    ScanController sc = tc.openScan(
      orig_conglomid,
      false, // don't hold
      (TransactionController.OPENMODE_FORUPDATE |
       TransactionController.OPENMODE_USE_UPDATE_LOCKS),
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_SERIALIZABLE,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

        int key_value;

        boolean found_row_2 = false;

        while (sc.next())
        {
            sc.fetch(r1.getRowArray());

            key_value = ((SQLInteger) r1.getCol(0)).getInt();

            switch(key_value)
            {
                case 1:
                {
                    // delete first row
                    sc.delete();
                    break;
                }
                   
                   
                case 2:
                {
                    // leave second alone - no update, lock will get coverted
                    // down.
                    found_row_2 = true;
                    break;
                }

                case 3:
                {
                    // update the third row.
                    T_AccessRow update_row = new T_AccessRow(2);
                    r1.setCol(0, new SQLInteger(30));
                    r1.setCol(1, new SQLInteger(3000));
                    sc.replace(r1.getRowArray(), null);
                    break;
                }

                default:
                {
                    throw T_Fail.testFailMsg(
                        "(updatelock) bad row value found in table.");
                }
            }
           
        }

        if (!found_row_2)
            throw T_Fail.testFailMsg(
                "(updatelock) did not find row in first scan.");

        // reposition the scan
    sc.reopenScan(
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.


        found_row_2 = false;

        while (sc.next())
        {
            sc.fetch(r1.getRowArray());

            key_value = ((SQLInteger) r1.getCol(0)).getInt();

            switch(key_value)
            {
                case 2:
                {
                    // leave second alone - no update, lock will get coverted
                    // down.
                    found_row_2 = true;

                    break;
                }

                case 30:
                {
                    // update the third row.
                    T_AccessRow update_row = new T_AccessRow(2);
                    r1.setCol(0, new SQLInteger(40));
                    r1.setCol(1, new SQLInteger(4000));
                    sc.replace(r1.getRowArray(), null);
                    break;
                }

                default:
                {
                    throw T_Fail.testFailMsg(
                        "(updatelock) bad row value found in table.");
                }
            }
           
        }

        if (!found_row_2)
            throw T_Fail.testFailMsg(
                "(updatelock) did not find row in second scan.");

        sc.close();

        tc.commit();

        // try the scan after the first xact has completed.

    sc = tc.openScan(
      orig_conglomid,
      false, // don't hold
      (TransactionController.OPENMODE_FORUPDATE |
       TransactionController.OPENMODE_USE_UPDATE_LOCKS),
            TransactionController.MODE_RECORD,
            TransactionController.ISOLATION_SERIALIZABLE,
      (FormatableBitSet) null, // all columns, all as objects
      null, // start position - first row in conglomerate
            0,    // unused if start position is null.
      null, // qualifier - accept all rows
      null, // stop position - last row in conglomerate
            0);   // unused if stop position is null.

        found_row_2 = false;

        while (sc.next())
        {
            sc.fetch(r1.getRowArray());

            key_value = ((SQLInteger) r1.getCol(0)).getInt();

            switch(key_value)
            {
                case 2:
                {
                    // leave second alone - no update, lock will get coverted
                    // down.
                    found_row_2 = true;
                    break;
                }

                case 40:
                {
                    // update the third row.
                    T_AccessRow update_row = new T_AccessRow(2);
                    r1.setCol(0, new SQLInteger(30));
                    r1.setCol(1, new SQLInteger(3000));
                    sc.replace(r1.getRowArray(), null);
                    break;
                }

                default:
View Full Code Here

Examples of org.apache.derby.iapi.types.SQLInteger

                TransactionController.ISOLATION_SERIALIZABLE);

        try
        {
            // should not be able to do an update in a read only transaction.
            big_row.setCol(0, new SQLInteger(1042));
      child_cc.insert(big_row.getRowArray());

      throw T_Fail.testFailMsg(
                "(nestedUserTransaction) read only xact does not allow upd.");

        }
        catch (StandardException se)
        {
            // expected exception, fall through.
            child_tc.commit();
            child_tc.destroy();
        }

        tc.commit();

        // start an update nested user transaction.
        child_tc = tc.startNestedUserTransaction(false);

        child_cc =
            child_tc.openConglomerate(
                orig_conglomid,
                false,
                TransactionController.OPENMODE_FORUPDATE,
                TransactionController.MODE_RECORD,
                TransactionController.ISOLATION_SERIALIZABLE);

        try
        {
            // should be able to do an update in a read only transaction.
            big_row.setCol(0, new SQLInteger(1043));
      child_cc.insert(big_row.getRowArray());


        }
        catch (StandardException se)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.