Ibatis invokes the Oracle stored procedure and returns the processing of the cursor result set
Source: Internet
Author: User
Recent project with Struts+spring+ibatis
I am a novice, the first time with Ibatis
So check the data online, download demo, run ...
The beginning is more smooth, nothing more than some select/update/delete
Later encountered a stored procedure call, no way, online check, a step by step
The stored procedure is not specific, it's a DBA thing.
Pass in one or several integers or strings
It's oraclecursor.
Ibatis configuration file Ibatis.xml:
XML code <resultmap id= "Result-map" class= "com.xxx.xxx.Table" > <result property= "Rsid" column= "id" /> <!--conversion between Java objects and Oracle columns --> </resultMap> <parametermap id= " Parameter-map " class=" Java.util.HashMap " > <parameter property= "param1" jdbctype= "VARCHAR" javatype= "java.lang.String" mode= "in"/> <parameter property= "param2" jdbctype= "Integer" javatype = "Java.lang.Integer" mode= "in"/> <parameter property= "Result" jdbctype= "Oraclecursor" javatype= "Java.sql.ResultSet" mode= "Out" /> </parameterMap> <procedure id= "testcur" resultmap= "Result-map" Parametermap= "ParametEr-map "> {call testprocedures (?, ?, ?)} </procedure>
Then look at the Java inside Call:
Java code MAP Parammap = new HashMap (); String str = request.getparameter (...); int n = request.getparameter (...); Parammap.put ("param1", str); Parammap.put ("param2", N); List detaillist = null; try{detaillist = Getsqlmapclienttemplate (). queryForList ("Testcur", Parammap); You can use Getsqlmapclienttemplate (). queryForObject ("Testcur", Parammap); The return value is object. }catch (Exception ex) {ex.printstacktrace (); return detaillist;
Detaillist is the desired result set.
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.