原来的代码:
jdbcTemplate
.
update
(
"INSERT INTO net_uploadcont (id, content, busiid) VALUES (?, ?, ?)"
,
netUploadcont
.
getId
(),
netUploadcont
.
getContent
(),
netUploadcont
.
getBusiid
());
修改后的代码
@
Override
public
void
insert
(
NetUploadcont
netUploadcont
) {
String
sql
=
"INSERT INTO net_uploadcont (id,content,busiid)VALUES(?, ?,?)"
;
jdbcTemplate
.
execute
(
sql
, (
PreparedStatementCallback
<
Integer
>
)
preparedStatement
->
{
{
// 设置ID
preparedStatement
.
setLong
(
1
,
netUploadcont
.
getId
());
byte
[]
bytes
=
netUploadcont
.
getContent
().
getBytes
(
1
, (
int
)
netUploadcont
.
getContent
().
length
());
preparedStatement
.
setBinaryStream
(
2
,
new
ByteArrayInputStream
(
bytes
),
bytes
.
length
);
preparedStatement
.
setLong
(
3
,
netUploadcont
.
getBusiid
());
// 执行更新
preparedStatement
.
executeUpdate
();
}
return
1
;
// 返回插入的记录数
});
}