• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC - ResultSet- Pls help

 
gayathri sundarachar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi....
I need the following information on ResultSet very urgently. can someone pls help me or let me know where can I get this info?
1). We can use SetFetchsize() to datasize to be retrieved from Result Set at one shot. When we use SetFetchSize(1024) and the there are only 10 records in ResultSet, what is the impact?
2). If we use the following to set the FetchSize equal to the number of rows and bring back cursor for fetching in normal, any impact on time?
rs.last()
nRows=rs.getRow();
rs.setFetchSize(nRows);
rs.beforeFirst();
while(rs.next())
{
....
}
3). If we set FETCH_FORWARDONLY, any gain in the execution speed
4). Any other features in JDBC2.0 that can improve performance?
5). Setting FetchSize same as RowCount(select count(*) from table), is it optimal?
also if u know any web sites or books I can refer to this pls pls let me know...
Thanx in advance!
Regards,
Gayathri.
 
gayathri sundarachar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone pls give some info on this...pls!
Any books to refer or any site??
I searched on web...didnt get any info on this.
any help would be very great help!
Regards,
Gayathri.
 
Dakshinamurthy Ramachandran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
From my understanding of concepts, i'll try to give the answers to your questions.
1. There is no impact, if actual values are less than the "size" which was set.
2. This way you can't set the size, and will fail for 'TYPE_FORWARD_ONLY'. Refer JDK API.
3. Definitly yes, but it is default, so no need to set explicit.
4. No idea !
5. Definitly NOT ... why additional query ? count(*) is as costly as retrieving all the values ...
Cheers
Murthy
 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use Oracle then there is a great book by O'reilly "Java Programming with Oracle JDBC" by Donald Bales.
Even without Oracle you can get alot out of this book.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic