您的位置:首页 > 数据库

[Microsoft][SQLServer JDBC Driver]Invalid parameter binding(s).错误求解

2006-04-25 13:29 645 查看
最近做一个项目,需要用到存储过程,在java程序调用,可是执行时产生错误:

[Microsoft][SQLServer JDBC Driver]Invalid parameter binding(s).

at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.preImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
at com.jinchuang.huizong.Huizong2UseStoredPro.query(Huizong2UseStoredPro.java:146)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.jinchuang.sys.GenericAction.dispatchMethod(GenericAction.java:82)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:113)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:90)[12:52:59.609] releaseConnection(), activeCount=1, useCount=0
forwardname:[TestdisplayBiao2]
Action执行完 query 方法,forward向TestdisplayBiao2

at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)
at com.jinchuang.runtime.SetEncoding.doFilter(SetEncoding.java:21)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:207)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:249)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:327)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:450)
at com.caucho.util.ThreadPool.run(ThreadPool.java:394)
at java.lang.Thread.run(Thread.java:534)

--------------------------------------------------------------------------------------------

这是测试存储过程:

CREATE PROCEDURE dbo.ZXQY_huiong2Test
(

@orderIndex char OUTPUT, --省合计索引
@shidi char OUTPUT, --地市
@zh_flag integer --审核标示
)

AS
Begin
select '1' as orderIndex, '全省合计(108个)' as shidi
into temp_huizong2
from xxhxxk where flag=@zh_flag
union
select '11' as orderIndex, '济南' as shidi
from xxhxxk where flag=@zh_flag and area_id like '531%'

select @orderIndex=orderIndex,@shidi=shidi from temp_huizong2

END
print @orderIndex

return 100
------------------------------------------------------------------------------------------------------

JAVA 程序中调用:

CallableStatement cstmt2 = myConnection.prepareCall("{?=call dbo.ZXQY_huizong2Test(?,?,?)}");
cstmt2.registerOutParameter(1,java.sql.Types.CHAR);
cstmt2.registerOutParameter(2,java.sql.Types.CHAR);

cstmt2.setInt(3,2);

System.out.println("-------------->Register Out Parameter<----------------");
cstmt2.executeQuery(); //执行

System.out.println("-------------->Test the Stored Procedure<-------------------");
System.out.println(cstmt2.getString(1));

------------------------------------------------------------------------------------------------------

结果在cstmt2.executeQuery(); //执行 这儿产生错误。

在网络上找了好多,但是也没有很好的解决方法,有说是驱动的原因,我的sqlserver2000,sp3,操作系统:XP sp2(英文),服务器:resin-3.0.9

请教高手,谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐