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!!