I can read every line of the query perfectly, but I would also like to update the field as it reads.
The following code breaks when I add two lines of rs.update.
Connection con = DriverManager.getConnection(url, user, pass); stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE) ResultSet rs = stmt.executeQuery(query); while (rs.next()) { amount = rs.getInt("amount"); username = rs.getString("username"); rs.updateString("processed", "true"); rs.updateRow(); }
I seem to have found my answer:
[SEVERE] com.mysql.jdbc.NotUpdatable: Result Set not updatable (the referenced table does not have primary keys). This result set should come from an operator that was created with the ResultSet.CONCUR_UPDATABLE result type, the query should select only one table, not use functions, and select all primary keys from this table. See the JDBC 2.1 API Specification, Section 5.6 for more information.
It doesn't hurt to add primary keys to my database, perhaps the right way to do it anyway.
source share