ScottyMac
asked on
Servlet: Invalid Cursor Error on Update
I'm trying to update a column value by looping through the resultset.
ResultSet rs = myStatement.executeQuery(" Select * from bulletin_board");
out.println("<HTML>");
out.println("<HEAD><TITLE> Bulletin Board</TITLE><HEAD>");
out.println("<BODY>");
int myid;
String myapproved = "";
while (rs.next())
{
myid = rs.getInt("bulletin_ID");
myapproved = "Yes";
myStatement.executeUpdate( "UPDATE bulletin_board SET approved = '" + myapproved + "' WHERE bulletin_ID = " + myid + "");
out.println("<p>Bulletin_i d = " + myid + " ChkApproved = " + myapproved + "</p>");
}
out.println("</BODY></HTML >");
Error Message:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid cursor state at sun.jdbc.odbc.JdbcOdbc
ResultSet rs = myStatement.executeQuery("
out.println("<HTML>");
out.println("<HEAD><TITLE>
out.println("<BODY>");
int myid;
String myapproved = "";
while (rs.next())
{
myid = rs.getInt("bulletin_ID");
myapproved = "Yes";
myStatement.executeUpdate(
out.println("<p>Bulletin_i
}
out.println("</BODY></HTML
Error Message:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid cursor state at sun.jdbc.odbc.JdbcOdbc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great stuff refactor, my buddy came to the same conclusion....it works fine now....thanks....
sql = "update bulletin_board set approved = ? where bulletin_board = ?"