However, it is possible that getXXX methods called after insertion will not
retrieve values for newly-inserted rows. If this is the case with a particular database,
then it will be necessary to close the ResultSet and create a new one (using the original
query), in order for the new insertions to be recognised.
To delete a row without using SQL, there are just two steps:
move to the appropriate row;
call method deleteRow .
results.absolute(3); //Move to row 3.
Note that JDBC drivers can handle deletions differently. Some remove the row
completely from the ResultSet , while others use a blank row as a placeholder. With
the latter, the original row numbers are not changed.
Now to bring together all the above 'snippets' of code into one program…
We shall use program JDBCChange from Sect. 7.5 as the starting point for this
example and make the necessary modifi cations to it. The new lines will be shown in
public class JDBC2Mods
private static Connection connection;
private static Statement statement;
private static ResultSet results;
public static void main(String args)