I am trying to modify an existing legacy application by porting few queries and making them compatible with MSSQL server. Some part is already written and I am actually integrating TVP with Java code.
But when I try to execute my code I get a weird exception
java.lang.ClassCastException:
com.microsoft.sqlserver.jdbc.SQLServerCallableStatement cannot be cast to com.microsoft.sqlserver.jdbc.SQLServerCallableStatement
This is the code I have written. MY_NUMBER
is actually a Table type.
CallableStatement stmt = ((WrappedCallableStatementJDK7) cstmt).getUnderlyingStatement();
SQLServerDataTable tbl = new SQLServerDataTable();
tbl.addColumnMetadata("key", Types.INTEGER);
tbl.addColumnMetadata("value", Types.INTEGER);
tbl.addRow(0, 0);
SQLServerCallableStatement statement = (SQLServerCallableStatement) stmt;
statement.setStructured(thisPSParamObj.getParameterName(), "DBO.MY_NUMBER", tbl);