日期:2014-05-17 浏览次数:20511 次
DECLARE @return_value int,@o_bool varchar(1) EXEC @return_value = [dbo].[p_check_workday] @i_empno = N'$empno$' @i_workdt = N'$sdate$',@o_bool = @o_bool OUTPUT SELECT @o_bool as N'@o_bool'
public void callProcedure(Connection conn, String procedure_name, List<Object> list) throws Exception { CallableStatement cast = null; StringBuffer strb = new StringBuffer(); strb.append("{call " + procedure_name + "("); if (null != list) { int listSize = list.size(); for (int i = 0; i < listSize; i++) { if (i == listSize - 1) { strb.append("?"); } else { strb.append("?,"); } } } strb.append(")}"); cast = conn.prepareCall(strb.toString()); for (int i = 0; i < list.size(); i++) { cast.setString(i + 1, list.get(i).toString()); } cast.executeUpdate(); conn.commit(); cast.close(); } List list = new ArrayList(); list.add("empno");//第一个参数 list.add("sdate");//第二个参数 callProcedure("[dbo].[p_check_workday]",list);