Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FORWARD_ONLY Resultset

 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read in JDBC doc on http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/resultset.html#1003004

For maximum portability with forward only result sets, values should be retrieved from left to right, and column values should be read only once. With scrollable result sets, however, there are no such restrictions.

Does this mean we cant read column value more than once from FORWARD_ONLY ResultSet?
 
manoj r patil
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so. Resultset is nothing but a cursor to your dataset at database layer. As long as you are on that row, you should be able to read that particular column multiple times, but once you moved to next, you can not go back if its FORWARD_ONLY.
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should be able to read that particular column multiple times
Hi,
are you certain of this?
 
Fatih Keles
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

java version : 1.5.0_06
jdbc driver : ojdbc14dms.jar
database : Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi


Output:


No exception!

Regards,

Fatih.
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are lucky.
http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once.


In this case, it went wrong.
 
Fatih Keles
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right. After I saw your post, I remember facing this issue myself with my older 8i database.
I suppose underlying jdbc implementation has improved jdbc specs

Regards,

Fatih.
 
manoj r patil
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so does it mean that Oracle 10g driver has removed this shortcoming? But I guess as per jdbc3.0 spec, reading a field multiple times should be supported, though I am not sure.
 
Tim Holloway
Saloon Keeper
Posts: 18366
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder about this. You can retrieve column data by column number, but you can also retrieve (as their examples show) by column name. We did a lot of that under Oracle 8 and I don't recall ever having to specify named-based retrieval in the order of the column numbers. And, in, fact, being forced to do so would remove one of the primary advantages of name-based retrieval: independence of the table's column ordering.

Unless you've got really wide columns, it would generally make more sense for the entire row to be retrieved and cached at once, so I'd expect column-ordering issues to be mostly a safety precaution.
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never had issues with reading columns in a different order than their sequence in the select statement.
But I have had issues when trying to read a column's value twice from a RecordSet. That is the reason why I remembered the quote I posted earlier in this thread.

Unfortunately, that is how far my memory goes. Don't remember database make, version or driver anymore (I'm in my 40s).
The other Rancher that had the same issue doesn't mention what database or driver he used either. I'm going to ask it.
 
manoj r patil
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan, you have great energy at this age to hook up to ranch and great memory as well!
 
Campbell Ritchie
Sheriff
Posts: 51419
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manoj r patil wrote:Jan, you have great energy at this age . . .
At this age??

Cheeky so-and-so! Jan is a mere child.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic