Skip to content

Commit a63bbdc

Browse files
committed
Add logging
1 parent 4ac49b5 commit a63bbdc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/main/java/fi/hsl/transitdata/pubtransredisconnect/QueryProcessor.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public QueryProcessor(final Connection connection) {
2121

2222
public void executeAndProcessQuery(final AbstractResultSetProcessor processor) {
2323
final String processorName = processor.getClass().getName();
24-
log.info("Starting query with result set processor {}.", processorName);
2524
long now = System.currentTimeMillis();
25+
log.info("Starting query with result set processor {}. {}", processorName, now);
2626

2727
ResultSet resultSet = null;
2828
try {
@@ -35,7 +35,7 @@ public void executeAndProcessQuery(final AbstractResultSetProcessor processor) {
3535
} catch (Exception e) {
3636
log.error("Failed to process query", e);
3737
} finally {
38-
closeQuery(resultSet);
38+
closeQuery(resultSet, now);
3939
}
4040

4141
long elapsed = (System.currentTimeMillis() - now) / 1000;
@@ -48,15 +48,21 @@ private ResultSet executeQuery(final String query) throws SQLException {
4848
return resultSet;
4949
}
5050

51-
private static void closeQuery(final ResultSet resultSet) {
51+
private static void closeQuery(final ResultSet resultSet, long now) {
5252
Statement statement = null;
5353
try { statement = resultSet.getStatement(); } catch (Exception e) {
5454
log.error("Failed to get Statement", e);
5555
}
56-
if (resultSet != null) try { resultSet.close(); } catch (Exception e) {
56+
if (resultSet != null) try {
57+
resultSet.close();
58+
log.info("ResultSet closed. {}", now);
59+
} catch (Exception e) {
5760
log.error("Failed to close ResultSet", e);
5861
}
59-
if (statement != null) try { statement.close(); } catch (Exception e) {
62+
if (statement != null) try {
63+
statement.close();
64+
log.info("Statement closed. {}", now);
65+
} catch (Exception e) {
6066
log.error("Failed to close Statement", e);
6167
}
6268
}

0 commit comments

Comments
 (0)