Skip to content

Commit 7801bb9

Browse files
committed
Add check on JsonValue.NULL
1 parent 8f84e98 commit 7801bb9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/io/elastic/jdbc/Utils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,31 @@ public static void setStatementParam(PreparedStatement statement, int paramNumbe
100100
JsonObject body) throws SQLException {
101101
try {
102102
if (isNumeric(colName)) {
103-
if (body.get(colName) != null) {
103+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
104104
statement.setBigDecimal(paramNumber, body.getJsonNumber(colName).bigDecimalValue());
105105
} else {
106106
statement.setBigDecimal(paramNumber, null);
107107
}
108108
} else if (isTimestamp(colName)) {
109-
if (body.get(colName) != null) {
109+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
110110
statement.setTimestamp(paramNumber, Timestamp.valueOf(body.getString(colName)));
111111
} else {
112112
statement.setTimestamp(paramNumber, null);
113113
}
114114
} else if (isDate(colName)) {
115-
if (body.get(colName) != null) {
115+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
116116
statement.setDate(paramNumber, Date.valueOf(body.getString(colName)));
117117
} else {
118118
statement.setDate(paramNumber, null);
119119
}
120120
} else if (isBoolean(colName)) {
121-
if (body.get(colName) != null) {
121+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
122122
statement.setBoolean(paramNumber, body.getBoolean(colName));
123123
} else {
124124
statement.setBoolean(paramNumber, false);
125125
}
126126
} else {
127-
if (body.get(colName) != null) {
127+
if ((body.get(colName) != null) && (body.get(colName) != JsonValue.NULL)) {
128128
statement.setString(paramNumber, body.getString(colName));
129129
} else {
130130
statement.setNull(paramNumber, Types.VARCHAR);

0 commit comments

Comments
 (0)