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("<HEAD><TITLE>Bulletin Board</TITLE><HEAD>");

int myid;      
String myapproved = "";
while (
myid = rs.getInt("bulletin_ID");
myapproved = "Yes";
                                myStatement.executeUpdate("UPDATE bulletin_board SET approved = '" + myapproved + "' WHERE bulletin_ID = " + myid + "");            
                               out.println("<p>Bulletin_id = " + myid + " ChkApproved = " + myapproved + "</p>");

Error Message:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid cursor state at sun.jdbc.odbc.JdbcOdbc
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How about using prepared statements..

sql = "update bulletin_board set approved = ? where bulletin_board = ?"

The problem could be that two Statement's are needed.   One cannot use Statement myStatement for the update at the same time it is still being used by the result of the Query.  

A book would say that one needs to complete any processing of the current ResultSet object before executing the same statement again.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ScottyMacAuthor Commented:
Great stuff refactor, my buddy came to the same works fine now....thanks....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.