0
点赞
收藏
分享

微信扫一扫

JDBC预编译方法


在jdbc中,有三种方式执行sql,分别是使用Statement(sql拼接),PreparedStatement(预编译),还有一种CallableStatement(存储过程), 

 

//校验信息集有效性 使用execute回调方法,防止sql注入
String ProcSql= "call xxxx(?,'01','01')" ;
this.jdbcTemplate.execute(ProcSql,
new PreparedStatementCallback(){
public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
ps.setString(1, A00);//这里的参数对应?
ps.addBatch();
return ps.executeBatch();
}
});

 如果是拼接表名的话

举报

相关推荐

0 条评论