aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-03 09:07:04 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-03 09:07:04 +1200
commit4eb88253787e895a3b0e22b2cbde04cd1b6d88ae (patch)
tree83267600ea00a444cc57207737ecd3caf4a19164 /src/org
parent63c80308169e2a27e65b94b8672502f8e4d2e2ed (diff)
downloadtraccar-server-4eb88253787e895a3b0e22b2cbde04cd1b6d88ae.tar.gz
traccar-server-4eb88253787e895a3b0e22b2cbde04cd1b6d88ae.tar.bz2
traccar-server-4eb88253787e895a3b0e22b2cbde04cd1b6d88ae.zip
Fix no generated keys problem
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/database/QueryBuilder.java10
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();