Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7719757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:29:43+00:00 2026-06-01T03:29:43+00:00

I am using oracle jdbc cachedrowset implementation to select several rows returning from a

  • 0

I am using oracle jdbc cachedrowset implementation to select several rows returning from a query. Then i update some data using cachedrowset.updateInt() or other update methods. I get the cursor back at first using cachedrowset.beforeFirst() and then traverse through the rowset again to print data.

The thing is the data i get using getInt() again is the original data.I want get the data that is replaced with the original one. I am not intended to commit changes to db.

I thought i can use Rowset object as a data wrapper without changing any data on the db, only for data manipulation and view. Is there any way i can get the updated date instead of the original one ? I didn’t want to code a data wrapper object of my own

Edit: This is how i get data, and below is how i update it

public OracleCachedRowSet getCachedRowset( String query, Connection con)
        throws DTSException {
    try {
        OracleCachedRowSet cachedRowSet = new OracleCachedRowSet();
        cachedRowSet.setReadOnly(false);
        cachedRowSet.setCommand(query);
        cachedRowSet.execute(con);
        return cachedRowSet;
    } catch (SQLException sqle) {
        throw new DTSException("Error fetching data! :" + sqle.getMessage(), sqle);
    }
}

Update Code:

public void updateRowSetData(CachedRowSet cachedRowSet, int columnIndex, int columnType,    Object data)
        throws SQLException {

    switch (columnType) {
    case Types.NUMERIC:
    case Types.DECIMAL:
        cachedRowSet.updateBigDecimal(columnIndex, (BigDecimal) data);
        return;
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGNVARCHAR:
        cachedRowSet.updateString(columnIndex, data == null ? null : data.toString());
        return;
    case Types.INTEGER:
        cachedRowSet.updateInt(columnIndex, (Integer) data);
        return;
    case Types.DATE:
        cachedRowSet.updateDate(columnIndex, (Date) data);
        return;
    case Types.TIMESTAMP:
        cachedRowSet.updateTimestamp(columnIndex, (Timestamp) data);
        return;
    case Types.TIME:
        cachedRowSet.updateTime(columnIndex, (Time) data);
        return;
    case Types.BIGINT:
        cachedRowSet.updateLong(columnIndex, data == null ? null : Long.parseLong(data.toString()));
        return;
    case Types.DOUBLE:
    case Types.FLOAT:
        cachedRowSet.updateDouble(columnIndex, (Double) data);
        return;
    case Types.SMALLINT:
        cachedRowSet.updateShort(columnIndex, data == null ? null : Short.parseShort(data.toString()));
        return;
    case Types.TINYINT:
        cachedRowSet.updateByte(columnIndex, Byte.parseByte(data == null ? null : data.toString()));
        return;
    case Types.BINARY:
    case Types.VARBINARY:
        cachedRowSet.updateBytes(columnIndex, (byte[]) data);
        return;
    case Types.CLOB:
        if (data != null) {
            cachedRowSet.updateClob(columnIndex, ((Clob) data).getCharacterStream());
        } else {
            cachedRowSet.updateClob(columnIndex, (Clob) data);
        }
        return;
    case Types.ARRAY:
        cachedRowSet.updateArray(columnIndex, (Array) data);
        return;
    case Types.BLOB:
        if (data != null) {
            cachedRowSet.updateBlob(columnIndex, data == null ? null : ((Blob) data).getBinaryStream());
        } else {
            cachedRowSet.updateBlob(columnIndex, (Blob) data);
        }
        return;
    case Types.REAL:
        cachedRowSet.updateFloat(columnIndex, (Float) data);
        return;
    case Types.BIT:
    case Types.BOOLEAN:
        cachedRowSet.updateBoolean(columnIndex, (Boolean) data);
        return;
    case Types.REF:
        cachedRowSet.updateRef(columnIndex, (Ref) data);
        return;
    case Types.LONGVARBINARY:
        cachedRowSet.updateBinaryStream(columnIndex, (InputStream) data);
        return;
    default:
        cachedRowSet.updateObject(columnIndex, data);
        return;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:29:45+00:00Added an answer on June 1, 2026 at 3:29 am

    The solution is to call cachedRowSet.updateRow() after using appropriate update method( updateInt(), updateString() etc. ) to make changes written to memory. I didn’t use it before because JavaDoc of this upateRow() says: “Updates the underlying database with the new contents of the current row of this ResultSet object.”

    Only that is not what happens. updateRow() updates the data on memory, not on the underlying db. I have found the solution in the document at the link: http://www.scribd.com/doc/68052701/8/Setting-Up-a-CachedRowSet-Object

    So what i did was simply call updateRow after updating the data:

        while (cachedRowSet.next()) {
            for (int i = 0; i < columnCount; i++) {
    
                    dataHandler.updateRowSetData(cachedRowSet, i + 1, columnTypes[i], getUpdatedData());
                    cachedRowSet.updateRow(); //Adding this line solves the problem. Otherwise changes are not made
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Oracle 11.1.0.6.0 and ADO.NET (System.Data.OracleClient) to run a query that works
We are using the Oracle JDBC driver version 9.0.2.0.0 and are having some trouble
Using JDBC (Oracle) I need to insert about thousand rows into each of two
There is a way to specify IBatis query timeout using oracle jdbc and Java?
i'm doing my first applications using JDBC/Oracle... Today i had a problem and i
Using Oracle, how can I find index names and creation dates from systables/information_schema? How
I've been using Oracle for quite some time since Oracle 8i was released. I
When using an Oracle JDBC connection pool, is there a way to control how
I am using weblogic JDBC datasource and my DB is Oracle 10g, below is
static void firequery(String q) { try { query=q; Class.forName (oracle.jdbc.OracleDriver);/*driver*/ //System.out.println(call); con = DriverManager.getConnection(dbUrl,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.