Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to go to previous record

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In Java I am using Oracle as my backend and I can go to next record, but I am not able to go to the previous record. I tried using rs.previous() method where rs is the object of ResultSet type but doesn't work. I heard about the setFecthDirection() method but how to use this I dont know.
If anyone of you knows please help me out.
Dharam
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only go backwards if the driver you are using fully supports JDBC 2.0. If I recall, the Oracle drivers are not fully JDBC 2.0 compliant. Check the Oracle web site for details of which functions are not supported.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always keep a copy in your code, either of just the previous result, or of all the results in the resultset. Then you can traverse at will.
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Connection.createStatement(int resultSetType, int resultSetConcurrency) method to create a scrollable ResultSet.
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Paul:
You can only go backwards if the driver you are using fully supports JDBC 2.0. If I recall, the Oracle drivers are not fully JDBC 2.0 compliant. Check the Oracle web site for details of which functions are not supported.

FYI, Oracle drivers do have most of the JDBC 2.0 functionality.
http://technet.oracle.com//tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_29_
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course, it depends on which drivers you are actually using.
------------------
Moderator of the JDBC Forum
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic