Given an updatable ResultSet that contains the following and this code, what does the code snippet output?
color | count |
---|---|
character varying(255) | integer |
black | 20 |
blue | 5 |
red | 0 |
rs.afterLast(); rs.previous(); rs.updateInt(2, 10); rs = stmt.executeQuery("select * from pens where color = 'red'"); while (rs.next()) { System.out.println(rs.getInt(2)); }
A.
This code tries to update a cell in a ResultSet.
However, it does not call updateRow()
to actually apply the changes in the database.
This means the SELECT query does not see the changes and outputs the original value of 0.
Option A is correct.