call the stored procedure with returned result set:
/*** Call the stored procedure with returned result set ** @ Param procname * @ Param * @ return * @ throws sqlexception * @ throws nofreeconnectionexception */Public datasource execuceproc (string procname, string [] PARAM) throws sqlexception, nofreeconnectionexception {connection con = NULL; callablestatement getresults = NULL; resultset rs = NULL; stringbuffer build = new stringbuffer (); build. append ("{call "). append (procname); build. Append ("("); If (Param! = NULL & Param. length> 0) {for (INT I = 0; I <Param. length; I ++) {build. append ("'"). append (Param [I]). append ("',") ;}} build. append ("?)} "); Try {con = connectdbbean. getconnection (readwritedbpool. readpool); getresults = con. preparecall (build. tostring (), resultset. type_scroll_sensitive, resultset. concur_updatable); getresults. registeroutparameter (1, oracletypes.cursorrentaskgetresults.exe cute (); RS = (resultset) getresults. getObject (1); this. rstodatasource (RS);} finally {try {If (RS! = NULL) {Rs. Close ();} If (getresults! = NULL) {getresults. close () ;}} catch (sqlexception e) {log. error (E);} connectdbbean. closeconnection (readwritedbpool. readpool, con);} return New datasourcetype ();}
Call the stored procedure with parameters:
/*** Call the stored procedure with parameters ** @ Param procname * @ Param * @ return * @ throws sqlexception * @ throws nofreeconnectionexception */@ suppresswarnings ("unchecked ") public static void execuceproc (string procname, list PARAM) throws sqlexception, nofreeconnectionexception {connection con = NULL; callablestatement getresults = NULL; stringbuffer build = new stringbuffer (); build. append ("{call "). append (procname); Bui LD. append ("("); If (Param! = NULL & Param. size ()> 0) {for (INT I = 0; I <Param. size (); I ++) {if (I> 0) build. append (","); build. append ("'"). append (Param. get (I )). append ("'") ;}} build. append (")}"); try {con = connectdbbean. getconnection (readwritedbpool. readpool); getresults = con. preparecall (build. tostring (), resultset. type_scroll_sensitive, resultset.concur_updatableappsgetresults.exe cute ();} finally {try {If (getresults! = NULL) {getresults. Close () ;}} catch (exception e) {log. Error (E);} connectdbbean. closeconnection (readwritedbpool. readpool, con );}}