I am trying to insert blob in table using jdbctemplate by following code
LobHandler handler = new DefaultLobHandler();
int dbresponse = jdbcTemplate.update(DBConstants.INSERT_INVOICE, new Object[]{invoiceBean.getVendorid(),
new SqlLobValue(invoiceBean.getInvoiceImage(), invoiceBean.getInvoiveImageLength(), handler), invoiceBean.getInvoiceDate()},
Types.INTEGER,Types.BLOB, Types.VARCHAR);
but getting following error
Caused by: java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
.......
Caused by: java.io.NotSerializableException: org.springframework.jdbc.core.support.SqlLobValue
I had made invoiceBean class as Serializable but getting same error.
NOTE: Images with small size are inserted succesfully to database but issue comes with large image size typically greater than 1 MB
Kindly advice !!!
I think the last parameter should be an int array:
LobHandler handler = new DefaultLobHandler();
int dbresponse = jdbcTemplate.update(
DBConstants.INSERT_INVOICE,
new Object[]{
invoiceBean.getVendorid(),
new SqlLobValue(invoiceBean.getInvoiceImage(), invoiceBean.getInvoiveImageLength(), handler),
invoiceBean.getInvoiceDate()},
new int[] {Types.INTEGER, Types.BLOB, Types.VARCHAR});
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.