java存储过程调用

@Override
public int executeUpdate(Connection conn, String sql, List<Date> param) throws CMSException {
// TODO Auto-generated method stub
// PreparedStatement prep = null;
CallableStatement cs = null;
try {
// prep = conn.prepareStatement(sql);
cs = conn.prepareCall("{call proc_clear_log(?)}");
cs.setString(1, sql);
cs.execute();
return 0;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new CMSException(CMSException.SERVER_DB_DIS_CONNECT, "数据库连接异常!");
} finally {
if(cs != null) {
try {
cs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

posted @ 2017-06-13 14:09  youdream  阅读(137)  评论(0编辑  收藏  举报