while inserting a base64 encoded image (now string) to DB2 the following error is given:
Illegal conversion: can not convert from "java.lang.String" to "java.sql.Blob" ERRORCODE=-4474, SQLSTATE=null
答案 0 :(得分:1)
您需要使用base64解码器:
byte[] imageBlob = Decoder.decode(imageBase64String);
preparedStatement.setBytes(blobColumn,imageBlob);
如果要保存Base64编码的字符串,请使用
preparedStatement.setBytes(blobColumn,imageBase64String.getBytes());