Non-holdable result set example

The following example uses Connection.createStatement to return a ResultSet that will close after a commit is performed.

Connection conn = ds.getConnection(user, passwd);
Statement stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                  ResultSet.CONCUR_READ_ONLY,
                  ResultSet.CLOSE_CURSORS_AT_COMMIT);
Related concepts
Holdable result sets and autocommit