Jfinal How do I invoke an Oracle stored procedure?

Source: Internet
Author: User
Tags getmessage

Stored procedures Use the Db.execute (Icallback) method, in which you use:
Connection.preparecall (SQL). Execute ();
You can call the stored procedure, and you can also control the return value freely

Example:

Public Boolean setvarvalue (final string processinstanceid, final string varName, final string varvalue) {
Boolean flag = false;
Object o = Db.execute (new Icallback () {
@Override
Public Boolean Call (Connection conn) throws SQLException {
Boolean flag = false;
try {
callablestatement proc = Conn.preparecall ("{Call Process_warn.set_var_value (?,?,?)}");
Proc.setstring (1, Processinstanceid);
Proc.setstring (2, varName);;
Proc.setstring (3, varvalue);
Proc.execute ();
The code comes here to show that your stored procedure has been successfully called, and if there are output parameters, then the process of taking out the output parameters
Flag = true;
} catch (Exception e) {
Flag = false;
Log.error ("EXECUTE procedure process_warn.set_var_value mistakes!!!");
E.printstacktrace ();
}
return flag;
}
});

Flag = (Boolean) o;

return flag;
}

、、、、、、、、、、、、、、、、、、、、、、、、、、、、

With a return value.

public string activetaskforupdate (final string Processinstanceid,
Final string Operationclasskey, final string operationkey, final string taskorgid,
Final string Orgfilterid, final string othertag,final string newType) {
String task_id_list = "";
Object o = Db.execute (new Icallback () {
@Override
Public String Call (Connection conn) throws SQLException {
String task_id_list = "";
try {
callablestatement proc = Conn.preparecall ("{Call Process_warn.active_task_for_update (?,?,?,?,?,?,?,?)}");
Proc.setstring (1, Processinstanceid);
Proc.setstring (2,operationclasskey);
Proc.setstring (3, Operationkey);
Proc.setstring (4, Taskorgid);
Proc.setstring (5, Orgfilterid);
Proc.setstring (6, Othertag);
Proc.setstring (7, NewType);
Proc.registeroutparameter (8, Oracle.jdbc.OracleTypes.VARCHAR);
Proc.execute ();
The code comes here to show that your stored procedure has been successfully called, and if there are output parameters, then the process of taking out the output parameters
Task_id_list = Proc.getobject (8). toString ();
} catch (Exception e) {
Log.error ("EXECUTE procedure process_warn.active_task_for_updatemistakes!!!");
E.printstacktrace ();
if (E.getmessage (). IndexOf ("ORA-20012")! =-1) {
String msg = E.getmessage (). Split ("#") [1];
throw new Noassigneeexception (msg);
}else{
throw new Systemunknownexception (E.getmessage ());
}
}
return task_id_list;
}
});

Task_id_list = (String) o;
return task_id_list;
}

Jfinal How do I invoke an Oracle stored procedure?

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.