第一种方法:
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;
}
两种方法均是带有返回值的存储过程,希望对您有所帮助