I was trying to do giving byte array as SqlLobValue() but it doesn't work.
public void sendEmailWithAccountInfoPDF(String toEmail, byte[] pdf) {
String SQL_ADD_EMAIL = "insert into emails_for_sending " +
"(to_email, attach_type, attach_name, attach_body) " +
"values (:to_email, :attach_type, :attach_name, :attach_body);";
Map<String, Object> params = new HashMap<>();
params.put("to_email", toEmail);
params.put("attach_type", "application/pdf");
params.put("attach_name", "info.pdf");
params.put("attach_body", new SqlLobValue(pdf));
jdbcTemplate.update(SQL_ADD_EMAIL, params);
}
But it gives me "SqlLobValue only supports SQL types Blob and Clob".
How to insert file into Oracle with jdbcTemplate properly?
The LobCreator/LobHandler provides the following support for LOB in- and output:
BLOB
byte[] – getBlobAsBytes and setBlobAsBytes
InputStream – getBlobAsBinaryStream and setBlobAsBinaryStream
CLOB
String – getClobAsString and setClobAsString
InputStream – getClobAsAsciiStream and setClobAsAsciiStream
Reader – getClobAsCharacterStream and setClobAsCharacterStream
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.