SpringJDBC调用oracle存储过程的方法

第一种方法:
public Map<String, Object> paymentCheckTenpay(final Map<String, Object> maps) {
	// TODO Auto-generated method stub
	Map<String,Object> resultMaps = (Map<String, Object>) this.getJdbcTemplate().execute(new CallableStatementCreator() {
		@Override
		public CallableStatement createCallableStatement(Connection connection)
				throws SQLException {
			// TODO Auto-generated method stub
			CallableStatement callableStatement = connection.prepareCall("{call wx_payment_check_package.proc_payment_check_tenpay(?,?,?,?,?,?)}");
			callableStatement.setString("tenpay_time", maps.get("tenpay_time").toString());
			callableStatement.registerOutParameter("error_total",OracleTypes.VARCHAR);
			callableStatement.registerOutParameter("success_count", OracleTypes.VARCHAR);
			callableStatement.registerOutParameter("error_count", OracleTypes.VARCHAR);
			callableStatement.registerOutParameter("result_code", OracleTypes.VARCHAR);
			callableStatement.registerOutParameter("result_message", OracleTypes.VARCHAR);
			return callableStatement;
		}
	},new CallableStatementCallback() {
		@Override
		public Object doInCallableStatement(CallableStatement callableStatement)
				throws SQLException, DataAccessException {
			Map<String,Object> maps = new HashMap<String, Object>();
			// TODO Auto-generated method stub
			callableStatement.execute();
			maps.put("error_total", callableStatement.getString("error_total"));
			maps.put("success_count", callableStatement.getString("success_count"));
			maps.put("error_count", callableStatement.getString("error_count"));
			maps.put("result_code", callableStatement.getString("result_code"));
			maps.put("result_message", callableStatement.getString("result_message"));
			return maps;
		}
	});
	return resultMaps;
}
第二种方法:
 public Map<String, Object> paymentMendRecharge(final Map<String, Object> maps) {
  // TODO Auto-generated method stub
  String sql = "{call wx_payment_check_package.proc_payment_mend_recharge(?,?,?,?,?)}";
  Map<String,Object> resultMaps = (Map<String, Object>) this.getJdbcTemplate().execute(sql, new CallableStatementCallback() {
   @Override
   public Object doInCallableStatement(CallableStatement callableStatement)
     throws SQLException, DataAccessException {
    // TODO Auto-generated method stub
    Map<String,Object> resultMap = new HashMap<String, Object>();
    callableStatement.setString("tenpay_time", maps.get("tenpay_time").toString());
    callableStatement.registerOutParameter("success_count", Types.INTEGER);
    callableStatement.registerOutParameter("error_count", Types.INTEGER);
    callableStatement.registerOutParameter("result_code", Types.VARCHAR);
    callableStatement.registerOutParameter("result_message", Types.VARCHAR);
    callableStatement.execute();
    resultMap.put("success_count", callableStatement.getInt("success_count"));
    resultMap.put("error_count", callableStatement.getInt("error_count"));
    resultMap.put("result_code", callableStatement.getString("result_code"));
    resultMap.put("result_message", callableStatement.getString("result_message"));
    return resultMap;
   }
  });
  return resultMaps;
 }

两种方法均是带有返回值的存储过程,希望对您有所帮助
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值