aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2011-11-15 08:48:41 +0000
committerAnton Tananaev <anton.tananaev@gmail.com>2011-11-15 08:48:41 +0000
commit77b9680d22af11684bc8e8d08c65407bd3ebc87e (patch)
tree5b5d841e9721ce982ac86ef92db3a59d26429176 /src/org/traccar/helper
parenta4c24b7883140ece7b534f94921408e39a0e8725 (diff)
downloadtrackermap-server-77b9680d22af11684bc8e8d08c65407bd3ebc87e.tar.gz
trackermap-server-77b9680d22af11684bc8e8d08c65407bd3ebc87e.tar.bz2
trackermap-server-77b9680d22af11684bc8e8d08c65407bd3ebc87e.zip
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/NamedParameterStatement.java42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/org/traccar/helper/NamedParameterStatement.java b/src/org/traccar/helper/NamedParameterStatement.java
index 63c31fb04..9464d86a8 100644
--- a/src/org/traccar/helper/NamedParameterStatement.java
+++ b/src/org/traccar/helper/NamedParameterStatement.java
@@ -5,6 +5,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
+import java.sql.Types;
import java.util.Map;
import java.util.HashMap;
@@ -113,35 +114,51 @@ public class NamedParameterStatement {
statement.close();
}
- public void setInt(String name, int value) throws SQLException {
+ public void setInt(String name, Integer value) throws SQLException {
List indexList = (List) indexMap.get(name);
if (indexList != null) for (Object index: indexList) {
- statement.setInt((Integer) index, value);
+ if (value != null) {
+ statement.setInt((Integer) index, value);
+ } else {
+ statement.setNull((Integer) index, Types.INTEGER);
+ }
}
}
- public void setLong(String name, long value) throws SQLException {
+ public void setLong(String name, Long value) throws SQLException {
List indexList = (List) indexMap.get(name);
if (indexList != null) for (Object index: indexList) {
- statement.setLong((Integer) index, value);
+ if (value != null) {
+ statement.setLong((Integer) index, value);
+ } else {
+ statement.setNull((Integer) index, Types.INTEGER);
+ }
}
}
- public void setBoolean(String name, boolean value) throws SQLException {
+ public void setBoolean(String name, Boolean value) throws SQLException {
List indexList = (List) indexMap.get(name);
if (indexList != null) for (Object index: indexList) {
- statement.setBoolean((Integer) index, value);
+ if (value != null) {
+ statement.setBoolean((Integer) index, value);
+ } else {
+ statement.setNull((Integer) index, Types.BOOLEAN);
+ }
}
}
- public void setDouble(String name, double value) throws SQLException {
+ public void setDouble(String name, Double value) throws SQLException {
List indexList = (List) indexMap.get(name);
if (indexList != null) for (Object index: indexList) {
- statement.setDouble((Integer) index, value);
+ if (value != null) {
+ statement.setDouble((Integer) index, value);
+ } else {
+ statement.setNull((Integer) index, Types.DOUBLE);
+ }
}
}
@@ -149,9 +166,12 @@ public class NamedParameterStatement {
List indexList = (List) indexMap.get(name);
if (indexList != null) for (Object index: indexList) {
- statement.setTimestamp(
- (Integer) index,
- new Timestamp(value.getTime()));
+ if (value != null) {
+ statement.setTimestamp(
+ (Integer) index, new Timestamp(value.getTime()));
+ } else {
+ statement.setNull((Integer) index, Types.TIMESTAMP);
+ }
}
}