Connecting Tech Pros Worldwide Forums | Help | Site Map

JSP - Invalid Cursor State

Member
 
Join Date: Nov 2007
Posts: 125
#1: May 21 '09
hello,
i get an "Invalid Cursor State" error after querying an Ms Access database,

i get top 3 records from a table, it works fine when there are 3 or less records in the table, but after i inserting the fourth record, "Invalid Cursor State" occur


Here's the code

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     rs = statement.executeQuery("select top 3 * from buku where baru=1 order by tgl_entry desc");
  3.  
  4.  
  5.     while(rs.next()) {
  6. %>
  7.  
  8.     <div style="text-align:center;">
  9.     <img src="<%= rs.getString(5) %>"> <br />
  10.     <%= rs.getString(2) %>
  11.     </div>
  12.  
  13. <%
  14.     }
  15. %>
  16.  
it raises the error on the following line.

Expand|Select|Wrap|Line Numbers
  1. <img src="<%= rs.getString(5) %>"> <br />
  2.  

what possible the cause is?
Thank you

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: May 22 '09

re: JSP - Invalid Cursor State


Start by removing all that Java code from the JSP and put it into a Servlet or a utility class. Use the JSP for presentation only.
It will also be easier to see what the problem is when the separation is done.
Reply