Jfinal calling an Oracle stored procedure to return a result set

Source: Internet
Author: User

    • Table structure
    • Stored Procedures
CREATE OR REPLACE PROCEDURE TEST3 (TID in Integer,o out sys_refcursor) as BEGIN  IF (tid>0) then     OPEN O for SELECT * FROM Xhsck. T_administrative_level T WHERE t.administrative_level_id = TID;  ELSE    OPEN O for SELECT * from Xhsck. T_administrative_level T WHERE t.administrative_level_id = 1;  END IF; END;

    • Java code (calling Class)

Wallfilter wallfilter = new Wallfilter ();D ruidplugin druid = new Druidplugin (GetProperty ("Jdbc.url"), GetProperty (" Jdbc.username "), GetProperty (" Jdbc.password "). Trim ()  , GetProperty (" Jdbc.driver "));d Ruid.addfilter (new Statfilter ());d Ruid.addfilter (Wallfilter),///connection pool maximum number of connections used druid.setmaxactive (Getpropertytoint ("maxactive", 100)); /connection Pool min idle druid.setminidle (getpropertytoint ("Minidle", 10));//Initialize Size druid.setinitialsize (Getpropertytoint (" InitialSize ",");d Ruid.start (); Config cfg = new config ("1", Druid.getdatasource ());D bkit.addconfig (CFG); list<record> list = (list<record>) db.use ("1"). Execute (New Mycallback (6,cfg)); System.out.println (List.get (0). GETSTR ("Administrative_level_name"));

    • Java code (callback Class)
public class Mycallback implements Icallback {public int tid;public Config CFG;    public ResultSet rs = null;    Mycallback (int tid,config cfg) {    this.tid=tid;    this.cfg=cfg;    } @Overridepublic Object Call (Connection conn) throws SQLException {callablestatement proc = null;         proc = Conn.preparecall ("{Call Test3 (?,?)}");         Proc.setint (1, tid);         Proc.registeroutparameter (2, oracletypes.cursor);         Proc.execute ();         ResultSet s =  (ResultSet) Proc.getobject (2);         list<record> list = (list<record>) recordbuilder.build (CFG, s);         return list;}}

Jfinal calling an Oracle stored procedure to return a result set

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.