sql server - The formal parameter "@valueOne" was not declared as an OUTPUT parameter, but the actual paramete

we have a simple java code with a call to a user-defined procedure on SQLSERVER database.We were using

we have a simple java code with a call to a user-defined procedure on SQLSERVER database. We were using sqljdbc42-6.0.8112 driver and everything was fine. here's the call

   String sql="{ CALL DBO.MY_PROCEDURE('ValueOne',valueTwo,'ValueThree',?)}";
   CallableStatement cstmt = connection.prepareCall(sql);
   cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
   cstmt.execute();

Please note the use of litteral values and the last one is the optput of Integer type.

And Here's the definition of the procedure

CREATE PROCEDURE [dbo].[MY_PROCEDURE](@valueOne NVARCHAR(30),@valueTwo NUMERIC,@valueThree NVARCHAR(500),@returnValue SMALLINT OUTPUT)

But, recently, we upgraded our system and we upgraded JDBC driver to mssql-jdbc-12.6.2.jre11 and this call started throwing errors

The formal parameter "@valueOne" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output.

I re-wrote the code to use the bind values instead of litteral values.

String sql = "{ CALL MY_PROCEDURE (?,?,?,?) }";
CallableStatement cstmt = connection.prepareCall(sql);
cstmt.setString(1, valueOne);
cstmt.setLong(2, valueTwo);
cstmt.setString(3, valueThree);
cstmt.registerOutParameter(4, java.sql.Types.INTEGER);

and this is perfectly working.

I just don't understand why this gives an error when used with litteral values but works with bind values.

Anybody has any idea please?

Thanks in advance!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744021794a4544985.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信