I’m using a quite straightforward setup to generate a CSV file from a SELECT query. How do I reduce (or at least control) the time window where the query locks the database for reads?
Here’s a typical example:
private List<String[]> getData(final ResultSet rs) throws SQLException {
final List<String[]> res = new LinkedList<String[]>();
int i = 0;
int stride = 10;
while (rs.next()) {
if (++i % stride == 0) {
System.out.println("Row " + i);
}
if (i >= stride * 10) {
stride = stride * 10;
}
res.add(getRow(rs));
}
System.out.println("*** Total " + i + " rows");
return res;
}
JDBC Transaction Isolation levels
Java Tutorial