0
我有一个数据库表,其中一列(declatationform)的类型是“BYTEA”我要存储在此列图像[]所以我必须返回一个方法是准备语句字节在Java中
public void uploadRentProofDeclaration(final MultipartFile declarationForm,
final int rentProofInfoId, int year) {
String updateSql = "update plit_landlordinfo" + year
+ " set filename=?,declarationform=? where cid=?";
getJdbcTemplate().execute(updateSql, new PreparedStatementCallback() {
public Object doInPreparedStatement(
final PreparedStatement pSstatement) throws SQLException,
DataAccessException {
pSstatement.setString(1, declarationForm.getOriginalFilename());
try {
pSstatement.setBinaryStream(2, new ByteArrayInputStream(
declarationForm.getBytes()), declarationForm
.getBytes().length);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pSstatement.setInt(3, rentProofInfoId);
pSstatement.execute();
return null;
}
});
}
这里正在发生的事情是文件名是越来越节省,但字节[]不保存仍然是列在我的表空白,它是不会放弃任何错误任何一个可以帮助我什么问题