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条)