Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQLException, invalid cursor state

843810May 3 2004 — edited May 10 2004
Came across the weirdest thing... Suppose i use this statement in a servlet:
ResultSet result = statement.executeQuery("SELECT City FROM Destinations");
and the following code in the JSP to which the browser is redirected:
<select name="selectedCity" value="" size="1">
<% ResultSet result = (ResultSet) session.getAttribute("rstCity"); 
while (result.next()) { %>
     <option><%= result.getString(1) %>
<% } %>
</select>
This works properly in my case. (Don't think other code is necessary to provide... please tell me you think it is..)
But because result is full of duplicate rows, i want to change the line into:
ResultSet result = statement.executeQuery("SELECT DISTINCT City FROM Destinations");
A ServletException and SQLException message in the browser (at index.jsp, not servlet/servletname!) both say [Micrisoft][ODBC Driver Manager]Invalid Cursor State...
Now if i (temporarily) remove the expression
<%= result.getString(1) %>
in the JSP file, the error no longer appears. Ofcourse the listbox <select> is now filled with about 100 empty <option>s...
I can't locate the problem this way, can't see any logic in this. It seems like by adding DISTINCT in the SQL statement, the JSP file cannot handle the getString function anymore.
Can anyone help me with this invalid cursor state thing?

Thanks!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2004
Added on May 3 2004
8 comments
541 views