diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-03 09:07:04 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-03 09:07:04 +1200 |
commit | 4eb88253787e895a3b0e22b2cbde04cd1b6d88ae (patch) | |
tree | 83267600ea00a444cc57207737ecd3caf4a19164 /src/org/traccar/database | |
parent | 63c80308169e2a27e65b94b8672502f8e4d2e2ed (diff) | |
download | trackermap-server-4eb88253787e895a3b0e22b2cbde04cd1b6d88ae.tar.gz trackermap-server-4eb88253787e895a3b0e22b2cbde04cd1b6d88ae.tar.bz2 trackermap-server-4eb88253787e895a3b0e22b2cbde04cd1b6d88ae.zip |
Fix no generated keys problem
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 5e5c163a3..04e29d7a2 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -40,11 +40,13 @@ public class QueryBuilder { private final 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) { String parsedQuery = parse(query.trim(), indexMap); try { @@ -417,9 +419,11 @@ public class QueryBuilder { if (query != null) { try { statement.executeUpdate(); - ResultSet resultSet = statement.getGeneratedKeys(); - if (resultSet.next()) { - return resultSet.getLong(1); + if (returnGeneratedKeys) { + ResultSet resultSet = statement.getGeneratedKeys(); + if (resultSet.next()) { + return resultSet.getLong(1); + } } } finally { statement.close(); |