当前位置: 技术问答>java相关
高手请进,java调用oracle存储过程(含输出参数).执行总报错,请各位帮忙.
来源: 互联网 发布时间:2017-04-10
本文导语: 存储过程: (Iname out number) is begin Iname:=2; end; 调用函数: try{ Connection conn; ResultSetMetaData rsmd=null; conn=GetConnect(); CallableStatemen...
存储过程:
(Iname out number)
is
begin
Iname:=2;
end;
调用函数:
try{
Connection conn;
ResultSetMetaData rsmd=null;
conn=GetConnect();
CallableStatement callst=conn.prepareCall("{ ?=call WU_GETCUSTNAME()}");
callst.registerOutParameter(1,java.sql.Types.INTEGER);
callst.execute();
conn.close();
}catch(Exception ee){
ee.printStackTrace();
}
}
执行到callst.execute();总报错:
java.sql.SQLException: ORA-06550: 行 1、列 13:
PLS-00306: 'WU_GETCUSTNAME'的输出参数不正确.
ORA-06550: 行 1、列 7:
PL/SQL: Statement ignored.赐教.
(Iname out number)
is
begin
Iname:=2;
end;
调用函数:
try{
Connection conn;
ResultSetMetaData rsmd=null;
conn=GetConnect();
CallableStatement callst=conn.prepareCall("{ ?=call WU_GETCUSTNAME()}");
callst.registerOutParameter(1,java.sql.Types.INTEGER);
callst.execute();
conn.close();
}catch(Exception ee){
ee.printStackTrace();
}
}
执行到callst.execute();总报错:
java.sql.SQLException: ORA-06550: 行 1、列 13:
PLS-00306: 'WU_GETCUSTNAME'的输出参数不正确.
ORA-06550: 行 1、列 7:
PL/SQL: Statement ignored.赐教.
|
过程是通过参数返回值的(参数为out,应用传递),函数才有返回值,
看看java api文档吧,http://java.sun.com/j2se/1.4/docs/guide/jdbc/getstart/callablestatement.html#999652
看看java api文档吧,http://java.sun.com/j2se/1.4/docs/guide/jdbc/getstart/callablestatement.html#999652
|
try
callst=conn.prepareCall("begin ?=call UW_GETCUSTNAME(); end;");
callst=conn.prepareCall("begin ?=call UW_GETCUSTNAME(); end;");