开发者

Whether resultset is directly connected with database

开发者 https://www.devze.com 2023-02-01 04:19 出处:网络
In Java, Whether DB driver request to DB for each row of resultset? Means if there are total 200 rows are fetched then would there be 200 开发者_如何转开发requests to database? Or the result set is s

In Java,

Whether DB driver request to DB for each row of resultset? Means if there are total 200 rows are fetched then would there be 200 开发者_如何转开发requests to database? Or the result set is stored locally not in DB?

If i populate a resultset (based on some conditions in SQL statement) and then i do some updation/changes in data in database. Whether resultset will return updated data?


You should clarify exactly what you mean by "request." It varies by driver and configuration where the data is cached. However, no driver will do 200 separate queries.

For the second question, it depends on the isolation level.


Each JDBC driver may implement their own fetching strategy. The driver will fetch a number of rows prior to you iterating through them. Thus a large result set would not pre-fetch ALL rows, but scroll through in fetch-sized batches.

You can provide the JDBC driver a hint as to how many you'd like to get.

Just as with in-progress SQL statements, you should not expect dirty reads by other transactions unless you'd really like to and set the isolation levels as such.

Most commonly, the Connection establishes the session and network connection the the DB and the 200 records of which you speak will be streamed (& multiplexed) through the network connection, with proper flow control.

Another approach is to use RowSet instead of ResultSet whereby you can be notified via events of changes to those rows that are affected.


I know that if you close your Statement,you can not iterate through the ResultSet.

0

精彩评论

暂无评论...
验证码 换一张
取 消