Tim Cooke wrote:This is not how you update a row in a database. The ResultSet in JDBC is just a copy of the data set in your db. You need to explicitly run an insert or update command with JDBC to write to your database. There are plenty of tutorials and examples on the web so I won't go into it here.
Actually, this is not true.
ResultSets are meant to be updatable, if some conditions are met (see the
Oracle's tutorial, for example).
That said, I prefer to do database updates using the
INSERT,
UPDATE and
DELETE SQL command myself, so I don't have much experience with updatable resultsets. I'd say that given the
ResultSet.CONCUR_UPDATABLE is used when creating the statement, the resultset should be updatable; if the database wouldn't support it, an exception should be thrown earlier in the program.
I'd probably try to change
ResultSet.TYPE_SCROLL_SENSITIVE to
ResultSet.TYPE_SCROLL_INSENSITIVE, but that would be just my hunch. I don't see anything that would indicate a problem in the given code (apart from not using
PreparedStatement, empty catch clause and so on, but that is not immediately connected to the problem).