I got it to work by hacking I just passed the datasource into the execute. I think spring closes the connection and by passing the data source the connection stays open it is really strange
This Spring stored procedure passes in an array of tab delimited strings the procedure validates the strings if there are errors in validation an error is added to the error array and the array is passed back
public class JdbcUpLoadPOLinesDAOImpl extends StoredProcedure implements JdbcUploadPOLinesDAO {
private static final
String UPLOAD_PO_LINES = "necxadm.po_upload_lines";
private static final String p_po_line_array= "p_po_line_array";
public JdbcUpLoadPOLinesDAOImpl(DataSource dataSource) {
super(dataSource, UPLOAD_PO_LINES);
final String[] errorList=new String[50];
declareParameter(new SqlParameter("poid", Types.BIGINT));
declareParameter(new SqlParameter("insert_user",Types.BIGINT));
declareParameter(new SqlParameter("version",Types.VARCHAR));
declareParameter(new SqlParameter("PO_LINES", Types.ARRAY,"STRING_ARRAY"));
declareParameter(new SqlOutParameter("results",Types.VARCHAR));
declareParameter(new SqlOutParameter("ERRORS", Types.ARRAY, "STRING_ARRAY", new SqlReturnType() {
public Object getTypeValue(CallableStatement cs, int paramIndex, int sqlType, String typeName) throws SQLException {
Connection con = cs.getConnection();
Map typeMap = con.getTypeMap();
typeMap.put(typeName, errorList);
Object o = cs.getObject(paramIndex);
return o;
}
}));
compile();
}
public Map upLoadLines(DriverManagerDataSource ds ,Long poid,Long loginUser,String version,String[] poLines) {
Map inParameters = new HashMap();
final String[] temp = poLines;
inParameters.put( "poid", poid );
inParameters.put( "insert_user", loginUser );
inParameters.put( "version", version );
inParameters.put("PO_LINES", new AbstractSqlTypeValue() {
protected Object createTypeValue(Connection con, int type, String typeName)
throws SQLException {
if( con.isClosed()){
System.out.println("connection is closed");
}else{
System.out.println("connection is open");
}
ArrayDescriptor desc = new ArrayDescriptor(typeName, con);
return new ARRAY(desc, con, temp);
}
});
Map out = execute( inParameters ); // Call on parent class
System.out.println("results="+out.get("results"));
ARRAY simpleArray=(ARRAY )out.get("ERRORS");
Object[] obj;
try {
obj = (Object[]) simpleArray.getArray(out);
System.out.println("obj[0]"+obj[0]);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return out;
}
This is the the outpput and it is what I expected
[STDOUT] obj[0]Header: Invalid Label for 'Part Number': xPart Number