/** * Execute Stored procedure (currently only supports returning one cursor) never null * * @param sql * executed statements * @param index * subscript of the current cursor * @param obj * parameters (used to replace the? in SQL statements) * @param rop * Register the output parameters of Oracle (note that if the subscript is 1, the input parameter is 2 output parameter * the cursor is to be obtained by the subscript of the output parameter, if the subscript 3 to 6 is the input parameter, 7 output parameter, then obtains the content according to the 7th, and so on ....) * resultset rs = * oraclecallablestatement.getcursor ( The subscript must be aligned with the subscript at the time of registration); * @return &NBSP;&NBSP;*/PUBLIC&NBSP;LIST<MAP< String, object>> searchtomaplistforproduce (string sql,int index, object Obj[], int[] rop) {List<Map<String, Object>> l = new Arraylist<map<string, object>> (); Connection userconn = ins.getconn ();try {oraclecallablestatement ocs = ( oraclecallablestatement) userconn.preparecall (SQL); // callablestatement cs = Con.preparecall (SQL); Ocs.registeroutparameter (index, rop[0]);// register the output parameters, so you can register with the loop for (int i = 0; i < obj.length; i++) {ocs.setobject (i + 1, Obj[i]);} Set parameter Ocs.execute (); Resultset rs = ocs.getcursor (Index);// This method is Oracle's special if (rs != null) { Int cl = rs.getmetadata (). getColumnCount ();while (Rs.next ()) {Map<String, Object> each = new hashmap<sTring, object> ();for (int i = 0; i < cl; i++) {String key = rs.getmetadata (). getColumnName (i + 1); object val = rs.getobject (key); Each.put (key, val);} L.add (each);}} &NBSP;ELSE&NBSP;{SYSTEM.OUT.PRINTLN ("current cursor for null!!!!!");}} catch (exception e) {system.out.println ("Query stored procedure error:" +e.getcause (). GetMessage ());} finally {dbconnectionmanager.getinstance (). Freeconnection (Ins.getcus (), userConn);} Return l;} Description: Originally this code is not difficult, mainly to waste time on the registration parameters and read the data on the piece.
Java read Oracle stored procedure return cursor (CURSOR) format read to list