50分求存储过程问题,调用和参数传出!

stoneopen1 2003-09-29 05:46:50
现有一存储过程getmonthdata,调用5个参数,返回一个植,是int类型的,是1,现使用下述方法调用存储过程,使用prepareStatement应该可以调用的吧。
public void report_Data_Prepare(String prepare_month , String prepare_branch,int payflag,int oper_type,int oper_step)
throws Exception
{
int i;
String strsql="";
try
{
strsql="execute procedure getmonthdata("+prepare_month+","+prepare_branch+","+payflag+","+oper_type+","+oper_step+")";
dbc.prepareStatement(strsql);
dbc.executeUpdate();
}

catch(SQLException sqles)
{
throw new Exception (sqles + strsql);
}
}
然后在jsp里这里调用这个方法,rdm.report_Data_Prepare(prepare_date,prepare_branch,payflag,oper_type,oper_step);
但是调用的结果是这样的一个错误啊,java.sql.SQLException: Function (hrms.getmonthdata)
returns too many values.execute procedure getmonthdata(200312,330000,1,1,1)
at com.hrms.form.ReportDataPrepare.ReportDataManage.report_Data_Prepare(ReportDataManage.java:64)
请高手指点啊。谢谢!
...全文
51 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fft123 2003-09-30
  • 打赏
  • 举报
回复
下面是个例子,2个输入参数,1个输出参数
楼主自己对着看看吧
CallableStatement cstmt = conn.prepareCall("{call yourproc(?,?,?)}");
cstmt.setInt(1, Integer.parseInt(para1));
cstmt.setInt(2, Integer.parseInt(para2));
cstmt.registerOutParameter(3, java.sql.Types.INTEGER);
cstmt.executeQuery();
stoneopen1 2003-09-30
  • 打赏
  • 举报
回复
怎么没人回答啊?大家都不懂吗?
noratong 2003-09-30
  • 打赏
  • 举报
回复
c表示的是connection对象。
noratong 2003-09-30
  • 打赏
  • 举报
回复
存储过程的类不是像你这样调用的。
strsql="execute procedure getmonthdata("+prepare_month+","+prepare_branch+","+payflag+","+oper_type+","+oper_step+")";
dbc.prepareStatement(strsql);
dbc.executeUpdate();
应该是:
CallableStatement ps = c.prepareCall("{call getimformation (?,?,?,?,?)}");
ps.setString(1, prepare_month);
ps.setString(2, prepare_branch);
ps.setInt(3, Integer.parseInt(payflag));
ps.setInt(4, Integer.parseInt(oper_type));
ps.registerOutParameter(5,Types.INTEGER);//取得返回值的参数
int oper_step = ps.getInt(5);
ps.execute();
stoneopen1 2003-09-30
  • 打赏
  • 举报
回复
还是不行啊
mailguoyy 2003-09-29
  • 打赏
  • 举报
回复
使用prepareStatement好象不支持返回参数吧?‘
应该用CallableStatemet?

up

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧