diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-08-17 20:55:15 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-20 11:36:41 +0000 |
commit | 0475ecf70de7b8e2aaabcd015b0424326da677ef (patch) | |
tree | 8b67f009ceaa2a3163e7258f0c37c773ca5a794e /server/src/com/vaadin/data | |
parent | af0b89f04bd530f2ca48a73c93ad7dca908a7bf2 (diff) | |
download | vaadin-framework-0475ecf70de7b8e2aaabcd015b0424326da677ef.tar.gz vaadin-framework-0475ecf70de7b8e2aaabcd015b0424326da677ef.zip |
Handle byte[] type in StatementHelper and correct SQLException (#13305).
Change-Id: I235ebe6250b9c03bbea393df7e8eb8823d119a2c
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r-- | server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java b/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java index ed849b51ec..379b319207 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java @@ -119,30 +119,34 @@ public class StatementHelper implements Serializable { private void handleNullValue(int i, PreparedStatement pstmt) throws SQLException { - if (BigDecimal.class.equals(dataTypes.get(i))) { - pstmt.setBigDecimal(i + 1, null); - } else if (Boolean.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.BOOLEAN); - } else if (Byte.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.SMALLINT); - } else if (Date.class.equals(dataTypes.get(i))) { - pstmt.setDate(i + 1, null); - } else if (Double.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.DOUBLE); - } else if (Float.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.FLOAT); - } else if (Integer.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.INTEGER); - } else if (Long.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.BIGINT); - } else if (Short.class.equals(dataTypes.get(i))) { - pstmt.setNull(i + 1, Types.SMALLINT); - } else if (String.class.equals(dataTypes.get(i))) { - pstmt.setString(i + 1, null); - } else if (Time.class.equals(dataTypes.get(i))) { - pstmt.setTime(i + 1, null); - } else if (Timestamp.class.equals(dataTypes.get(i))) { - pstmt.setTimestamp(i + 1, null); + Class<?> dataType = dataTypes.get(i); + int index = i + 1; + if (BigDecimal.class.equals(dataType)) { + pstmt.setBigDecimal(index, null); + } else if (Boolean.class.equals(dataType)) { + pstmt.setNull(index, Types.BOOLEAN); + } else if (Byte.class.equals(dataType)) { + pstmt.setNull(index, Types.SMALLINT); + } else if (Date.class.equals(dataType)) { + pstmt.setDate(index, null); + } else if (Double.class.equals(dataType)) { + pstmt.setNull(index, Types.DOUBLE); + } else if (Float.class.equals(dataType)) { + pstmt.setNull(index, Types.FLOAT); + } else if (Integer.class.equals(dataType)) { + pstmt.setNull(index, Types.INTEGER); + } else if (Long.class.equals(dataType)) { + pstmt.setNull(index, Types.BIGINT); + } else if (Short.class.equals(dataType)) { + pstmt.setNull(index, Types.SMALLINT); + } else if (String.class.equals(dataType)) { + pstmt.setString(index, null); + } else if (Time.class.equals(dataType)) { + pstmt.setTime(index, null); + } else if (Timestamp.class.equals(dataType)) { + pstmt.setTimestamp(index, null); + } else if (byte[].class.equals(dataType)) { + pstmt.setBytes(index, null); } else { if (handleUnrecognizedTypeNullValue(i, pstmt, dataTypes)) { @@ -150,7 +154,7 @@ public class StatementHelper implements Serializable { } throw new SQLException("Data type not supported by SQLContainer: " - + parameters.get(i).getClass().toString()); + + dataType.getClass().toString()); } } |