/** * Overrides the parent method to clear parameters in the DatabaseResult object. * * @param cs the Statement object. * @param params the array of Param objects. * @exception Exception if there was a problem clearing the out parameters. */ protected final void clrOutputParameters(final Statement cs, final Param[] params) throws Exception { CallableStatement tcs = (CallableStatement) cs; for (int i = 0; i < params.length; i++) { if (params[i].isOutParameter()) { SymbolTable.removeSymbol(SymbolTable.OUT_PARAM + tcs + ":" + i + "}"); } } }
/** * Overrides the parent method to set the OUT parameters into the DatabaseResult object. * * @param cs the Statement object. * @param params the array of Param objects. * @param result the DatabaseResult object. * @exception Exception if there was a problem setting the OUT params. */ protected final void setOutputParameters( final Statement cs, final Param[] params, final DatabaseResult result) throws Exception { CallableStatement tcs = (CallableStatement) cs; // get a count of outparams List outParamList = new ArrayList(); for (int i = 0; i < params.length; i++) { if (params[i].isOutParameter()) { OutParam outParam = new OutParam(); outParam.setId(params[i].getId()); outParam.setName(params[i].getName()); outParam.setType(params[i].getType()); String outParamSymbol = SymbolTable.removeSymbol(SymbolTable.OUT_PARAM + tcs.hashCode() + ":" + i + "}"); // get the value from the CallableStatement Object value = tcs.getObject(i + 1); if (value instanceof ResultSet) { // value is a resultset ResultSetBean rsb = new ResultSetBean((ResultSet) value, 1); outParam.setValue(rsb); if (outParamSymbol != null) { SymbolTable.setObject(outParamSymbol, rsb); } } else if (params[i].getType().endsWith("STRUCT")) { // value is a user-defined type (UDT) StructBean sb = new StructBean(value); outParam.setValue(sb); if (outParamSymbol != null) { SymbolTable.setObject(outParamSymbol, sb); } } else { // value is a String IType type = TypeFactory.getInstance(params[i].getType()); outParam.setValue(type.toString(value)); if (outParamSymbol != null) { SymbolTable.setValue(outParamSymbol, type.toString(value)); } } outParamList.add(outParam); } } OutParam[] ops = new OutParam[outParamList.size()]; for (int i = 0; i < ops.length; i++) { ops[i] = (OutParam) outParamList.get(i); } result.setOutParams(ops); }