This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
You generally want to state what problem you had and not just post the code you tried. I see two problems though:
1) You always use result and not the index of the statement. Which means this runs the select statement repeatedly.
2) The statements could be run out of order if you have a select after the insert/update.
I noticed you've fixed the result bug pointed out by Jeanne in your post. To prevent a confusion, please refrain from editing posts others have already replied to in a manner that makes the replies meaningless; or at least put a note into the edited post so that the changes are obvious. Thanks.