• 1 reply
  • Latest Post - ‏2012-10-24T12:20:00Z by Kulnor
2 Posts

Pinned topic ResultSet multi row fetch from Java/JDBC?

‏2012-10-24T11:15:56Z |
I'm having a hard time trying to enable multi-row fetching from a JDBC connection. When I loop through my ResultSet, the process is very slow and fetches one row at a time (see simple code below)

My driver is db2jcc-4.jar. I'm connecting over a DB2SimpleDataSource and do call
during initialization (not sure if this is necessary)

Any help/suggestion appreciated....


stmt = this.getConnection().createStatement();

ResultSet res = stmt.getResultSet();
logger.debug("Fetch size is "+res.getFetchSize()); // this returns 10000
while( {
Updated on 2012-10-24T12:20:00Z at 2012-10-24T12:20:00Z by Kulnor
  • Kulnor
    2 Posts

    Re: ResultSet multi row fetch from Java/JDBC?

    Further to this, I found out for a result set to support multi row in JDBC, a series of conditions must be satisfied
    in particular the cursor must be scrollable.

    Now to make the cursor scrollable, I need to specify the following resultset type and concurrency.
    stmt = this.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

    The issue now is that when I try this, DB2 return
    DB2 SQL Error: SQLCODE=-270, SQLSTATE=42997, SQLERRMC=63, DRIVER=4.13.127
    which basically seem mean "not supported"

    Suggestions appreciated.