--Dao层的实现类里的调用java代码
public Long getAddTotal(
int a,
int b){
// TODO Auto-generated method stub
try
{
HashMap hm= new HashMap();
//在这里的map参数要与xml配置文件参数名一致,不支持VARCHAR2的类型
hm.put( "pa", a);
hm.put( "pb", b);
hm.put( "pc", "");
this.getSqlMapClientTemplate().update( "testProc", hm);
return Long.valueOf(hm.get( "pc").toString());
} catch(Exception e)
{
System.out.println(e.getMessage());
return Long.valueOf(-1);
}
}
// TODO Auto-generated method stub
try
{
HashMap hm= new HashMap();
//在这里的map参数要与xml配置文件参数名一致,不支持VARCHAR2的类型
hm.put( "pa", a);
hm.put( "pb", b);
hm.put( "pc", "");
this.getSqlMapClientTemplate().update( "testProc", hm);
return Long.valueOf(hm.get( "pc").toString());
} catch(Exception e)
{
System.out.println(e.getMessage());
return Long.valueOf(-1);
}
}
--参数的配置文件:
<
parameterMap
id
="ProcParameters"
class
="java.util.HashMap"
>
< parameter property ="pa" jdbcType ="NUMBER" javaType ="java.lang.Integer" mode ="IN" />
< parameter property ="pb" jdbcType ="NUMBER" javaType ="java.lang.Integer" mode ="IN" />
< parameter property ="pc" jdbcType ="VARCHAR" javaType ="java.lang.String" mode ="OUT" />
</ parameterMap >
< procedure id ="testProc" parameterMap ="ProcParameters" >
{call P_testProc(?,?,?)}
</ procedure >
< parameter property ="pa" jdbcType ="NUMBER" javaType ="java.lang.Integer" mode ="IN" />
< parameter property ="pb" jdbcType ="NUMBER" javaType ="java.lang.Integer" mode ="IN" />
< parameter property ="pc" jdbcType ="VARCHAR" javaType ="java.lang.String" mode ="OUT" />
</ parameterMap >
< procedure id ="testProc" parameterMap ="ProcParameters" >
{call P_testProc(?,?,?)}
</ procedure >
--存储过程
create
or
replace
procedure P_testProc(pa
in number,pb
in number,pc out number )
is
begin
pc:=pa+pb;
end;
is
begin
pc:=pa+pb;
end;
本文转自 yuwenhu 51CTO博客,原文链接:http://blog.51cto.com/yuwenhu/240897,如需转载请自行联系原作者