Forums Register Login

Does Result set returns everything or we need hit DB

+Pie Number of slices to send: Send
One of my friend asked a simple question around JDBC result set. When you get a result set after executing a query, is every thing returned to you (to java, residing some where Java process memory)? So if you say like resultset.next() you are just accessing a something in the memory itself or you have to make a database call every time. I am assuming its that you get every in one go its just traversal in the memory but will appreciate if I can get some reference about how thing work with result sets internally.

Thanks in advance

Cheers
+Pie Number of slices to send: Send
JDBC has a "fetch size" property that determines how many results are returned for each trip to the database. This means that you get a bunch of records from the database and then go back later for more.

You can read more about it here. I've quoted the beginning of that documentation page.

By default, when Oracle JDBC runs a query, it retrieves a result set of 10 rows at a time from the database cursor. This is the default Oracle row fetch size value. You can change the number of rows retrieved with each trip to the database cursor by changing the row fetch size value.

Standard JDBC also enables you to specify the number of rows fetched with each database round-trip for a query, and this number is referred to as the fetch size. In Oracle JDBC, the row-prefetch value is used as the default fetch size in a statement object. Setting the fetch size overrides the row-prefetch setting and affects subsequent queries run through that statement object.

Fetch size is also used in a result set. When the statement object run a query, the fetch size of the statement object is passed to the result set object produced by the query. However, you can also set the fetch size in the result set object to override the statement fetch size that was passed to it.

 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 798 times.
Similar Threads
Hibernate performance issues using huge databases
Keys are getting expired in Ehcache
How to execute an scalar query ?
Increase processing time
hi all problem in resultset
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:33:31.