Using the JDBC driver provided by Microsoft (sqljdbc4.jar), I cannot call the stored procedure using the synonym defined for it. That is, for a synonym defined as:
CREATE SYNONYM dbo.synonym_name for dbo.procedure_name
when starting the called statement created:
CallableStatement callStmt = conn.prepareCall("{ call [dbo].[synonym_name] (?,?,?,?,?,?) }");
I get an exception:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Parameter param_name was not defined for stored procedure [dbo].[synonym_name]. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171) at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.findColumn(SQLServerCallableStatement.java:1217) at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.setString(SQLServerCallableStatement.java:1563) at testmssql.main(testmssql.java:53)
Even if the parameters are set correctly (if I call the procedure directly (bypassing the synonym), everything works fine).
Also, if I replaced the Microsoft JTDS driver, everything will be fine.
How to run CallableStatement using a synonym for a stored procedure with a Microsoft SQL Server JDBC driver?
diciu source share