JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.update("delete from my_table where value=? ", new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException {
ps.setLong(1, 2L);//or setString or whatever
}
});
# 1 楼答案
jdbc模板。update()可用于删除
例如
您还可以在不使用PreparedStatementSetter的情况下执行删除,如下所示:http://www.java2s.com/Code/Java/Spring/UseJdbcTemplateToExecuteDeleteStatementWithParameter.htm
# 2 楼答案
您可以像这样使用
PreparedStatement
进行删除