/**
* 删除 流向单主表,支持批量删除
* @param flowCardNOs 流向单号
* @throws DaoException Dao层异常
*/
@Override
public void delFlowCardMaster(String[] flowCardNOs) throws DaoException {
// 表示 流向单号 的占位符
StringBuilder flowCardNOsMarks = new StringBuilder();
// 最终的效果 ?,?,?
for (int i = 0; i < flowCardNOs.length; i++) {
flowCardNOsMarks.append("?");
if (i < flowCardNOs.length - 1) {
flowCardNOsMarks.append(",");
}
}
// 删除 流向单 的 sql
/*
delete from t_flow_card_master
where Flow_card_no in ('');
*/
StringBuffer sql = new StringBuffer();
sql.append("delete from t_flow_card_master ")
.append("where Flow_card_no in (")
.append(flowCardNOsMarks)
.append(")");
// JDBC
PreparedStatement preparedStatement = null;
Connection connection = ConnectionManager.getConnection();
批量删除,可作为JDBC DAO层模板代码
最新推荐文章于 2022-06-20 10:32:13 发布
该代码展示了如何在DAO层使用JDBC进行批量删除操作,具体针对流向单主表。通过循环构建SQL的占位符,并利用PreparedStatement设置参数,执行删除流向单的SQL语句,如果出现SQLException则抛出DaoException。
摘要由CSDN通过智能技术生成