mattyb149 commented on code in PR #7380:
URL: https://github.com/apache/nifi/pull/7380#discussion_r1230112238


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java:
##########
@@ -868,6 +868,33 @@ private void setParameter(PreparedStatement ps, int index, 
Object value, int fie
                     throw new IOException("Unable to parse data as CLOB/String 
" + value, e.getCause());
                 }
             }
+        } else if (sqlType == Types.VARBINARY || sqlType == 
Types.LONGVARBINARY) {
+            if (fieldSqlType == Types.ARRAY || fieldSqlType == Types.VARCHAR) {
+                if (!(value instanceof byte[])) {
+                    if (value == null) {
+                        try {
+                            ps.setNull(index, Types.BLOB);
+                            return;
+                        } catch (SQLException e) {
+                            throw new IOException("Unable to setNull() on 
prepared statement" , e);
+                        }
+                    } else {
+                        throw new IOException("Expected 
VARBINARY/LONGVARBINARY to be of type byte[] but is instead " + 
value.getClass().getName());
+                    }
+                }
+                byte[] byteArray = (byte[]) value;
+                try {
+                    ps.setBytes(index, byteArray);
+                } catch (SQLException e) {
+                    throw new IOException("Unable to parse binary data " + 
value, e.getCause());
+                }
+            } else {
+                try {
+                    ps.setBytes(index, 
value.toString().getBytes(StandardCharsets.UTF_8));

Review Comment:
   This is just in case the data came in as a String



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to