This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes running the result from the end Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "running the result from the end" Watch "running the result from the end" New topic

running the result from the end

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
Hi All,

I am runnung an example in which i want to fetch the results from the end means running the resultset from backward

I have wriiten this code

The problem is its compiling fine and when i am running it its showing an errorwhich state "Invalid column name"

I am using oracle 10g and table name is emp

Thanks in advance
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
its resolved
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3606

Two notes on this:

1) You're trying to process the resultset "backwards", but your query does not contain the ORDER BY clause and therefore the database is free to send you the data in any order it feels like. Since the order of the records is undefined in your case, it does not make sense to process them backwards.

2) If you want to obtain the data from database in defined order, you need to use the ORDER BY clause. You can easily tell the database to revert the order using the DESC keyword (eg. ORDER BY ENAME DESC, EMPNO DESC) - the records will come out of the database sorted as you need them and you'll iterate them forwards, not backwards.

You should use normal, forward-only recordset whenever possible, as it is much more efficient and resource-friendly.
Jan Cumps

Joined: Dec 20, 2006
Posts: 2491

deepak carter wrote:its resolved

Because of this?

OCUP UML fundamental and ITIL foundation
youtube channel
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: running the result from the end
Similar Threads
JDBC: What is the concrete class that implements the jdbc interfaces
Not Quite sure how there is a SQLException on this line...
Scroll Sensitive ResultSet
Resultset Exception