это мой тестовый jsp код и код функции javabean db:
jsp:
<%
conn.init();
ResultSet rs = conn.selectProductById (request.getParameter("pid"));
while (rs.next()) {
System.out.println(rs.getString("pid"));
}
}
%>
javabean:
public ResultSet selectProductById (String pid) {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String query = "select * from product where pid = ? ;";
pstmt = connection.prepareStatement(query); // create a statement
pstmt.setString(1, pid); // set input parameter
System.out.println(pstmt);
rs = pstmt.executeQuery();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
rs.close();
pstmt.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return rs;
}
ошибка:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.sql.SQLException: Operation not allowed after ResultSet closed
root cause
java.sql.SQLException: Operation not allowed after ResultSet closed
note The full stack traces of the exception and its root causes are available in the GlassFish Server
JSP-код пытается получить набор результатов из метода javabean, но есть ошибка.как это исправить?
спасибо