Scrollable ResultSet and Connection

Scrollable ResultSet and Connection

Post by Mais » Wed, 06 Mar 2002 09:29:58



I'd like to use the scrollable resultSet but I don't want to hold any
connections.
Is it possible to do the following:
1. Open the connection
2. Run the statement
3. Using the ResultSet, get the first X records
4. Close the statement
5. Close the connection
6. Show the information retrieved in my page and when the user clicks
the Next Button, get the Next records from the ResultSet. (Should I go
to step 1 again or is there any other way to retrieve the stament and
the connection from the ResultSet?)

My second question:
How costly it is to use the Scrollable ResultSet?

Any help would be apreciated,
Thanks,
Maisa.

 
 
 

Scrollable ResultSet and Connection

Post by Dirk » Thu, 07 Mar 2002 06:11:13



Quote:> I'd like to use the scrollable resultSet but I don't want to hold any
> connections.
> Is it possible to do the following:
> 1. Open the connection
> 2. Run the statement
> 3. Using the ResultSet, get the first X records
> 4. Close the statement
> 5. Close the connection
> 6. Show the information retrieved in my page and when the user clicks
> the Next Button, get the Next records from the ResultSet. (Should I go
> to step 1 again or is there any other way to retrieve the stament and
> the connection from the ResultSet?)

AFAIK, you cannot access the ResultSet after closing the connection. So you
have to open another connection to get the next couple of rows. Be aware
that you're now in another transaction and you won't get consistent results
with the first statement if there happened updates inbetween (your app may
not be that transactional).

Also, if you don't work with a connection pool, openening a connection is
expensive.

May I ask why you don't want to keep your connections open?

Quote:> My second question:
> How costly it is to use the Scrollable ResultSet?

compared to what?

Regards, Dirk

 
 
 

1. Scrollable ResultSets in JRun4

A while ago we were having problems (I no longer remember the
symptoms) with our app running on JRun4. The solution that was
suggested was to use SelectMethod=cursor, which we implemented, and it
seemed to work.

Now, I'm trying to use scrollable ResultSets, and am having problems.
Can anybody recommend what settings to use, and tell me if the default
JDBC driver for JRun4 (with current patches) will work with scrollable
ResultSets?

Settings:
SelectMethod=cursor
Then in code:
java.sql.Statement s =
c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = s.executeQuery(sql);
    int totalRowCount = 0;
     while(rs.next()) {
      totalRowCount++;
     }
    rs.beforeFirst(); //not working

Thanks,
Jamie

2. FoxPro Shareware CDROM

3. scrollable resultsets problem with store procedures

4. Writing a ODBC driver

5. I want to use Scrollable ResultSet

6. Using ADO/OLE DB and Sybase

7. Oracle 9i Scrollable Remote ResultSet

8. Documenting "Description" field in an MDB via VB5/DAO?

9. Scrollable ResultSet and ROWID

10. Scrollable ResultSet and ROWID, problems

11. How to get Scrollable ResultSet using CallableStatement

12. Scrollable ResultSet using proc out cursor

13. scrollable ResultSet