diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-08 10:37:52 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-08 10:37:52 +1200 |
commit | 49ef740b5a2a0ed40c59225a3ccf2b8fbc12139e (patch) | |
tree | a52c1433fe212989a3c87e4404e3dacffe365561 | |
parent | 2fcdb41728dab59f97db9ad2b3b7ed8db7b2c994 (diff) | |
download | trackermap-server-49ef740b5a2a0ed40c59225a3ccf2b8fbc12139e.tar.gz trackermap-server-49ef740b5a2a0ed40c59225a3ccf2b8fbc12139e.tar.bz2 trackermap-server-49ef740b5a2a0ed40c59225a3ccf2b8fbc12139e.zip |
Fix database connection leaking (fix #1292)
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 04e29d7a2..88183f525 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -36,18 +36,17 @@ import org.traccar.model.Factory; public class QueryBuilder { - private final Map<String, List<Integer>> indexMap; - private final Connection connection; + private final Map<String, List<Integer>> indexMap = new HashMap<String, List<Integer>>(); + private Connection connection; private PreparedStatement statement; private final String query; private final boolean returnGeneratedKeys; private QueryBuilder(DataSource dataSource, String query, boolean returnGeneratedKeys) throws SQLException { - indexMap = new HashMap<String, List<Integer>>(); - connection = dataSource.getConnection(); this.query = query; this.returnGeneratedKeys = returnGeneratedKeys; if (query != null) { + connection = dataSource.getConnection(); String parsedQuery = parse(query.trim(), indexMap); try { if (returnGeneratedKeys) { |