i am new in the coding world. i got the error "Exhausted ResultSet" when i run the project. i think the error is somewhere in the resultSet coding. Can anyone suggest to me what should i do to solve this kind of problem?
Here is my servlet code name DisplayItemServlet:
PreparedStatement ps = con.prepareStatement("select images from item where itemId = ?");
String itemId = request.getParameter("itemId");
ps.setString(1,itemId);
ResultSet rs = ps.executeQuery();
if (rs!= null) {
while(rs.next()){
Blob b = rs.getBlob("images");
response.setContentType("image/jpeg");
response.setContentLength( (int) b.length());
InputStream is = b.getBinaryStream();
OutputStream os = response.getOutputStream();
byte buf[] = new byte[(int) b.length()];
is.read(buf);
os.write(buf);
os.close();
}}
And here is my ListItemServlet:
PreparedStatement ps = con.prepareStatement("select * from item");
ResultSet rs = ps.executeQuery();
while ( rs.next()) {
response.sendRedirect("catalog.jsp");
}
con.close();
Thanks in advance !