Converting from UNKNOWN to UNKNOWN is not supported

I get the following exception executing the stored procedure:

com.microsoft.sqlserver.jdbc.SQLServerException: conversion from UNKNOWN to UNKNOWN is not supported.

The procedure is defined as follows:

CREATE PROCEDURE spTest ( @p1 varchar(1024) , @p2 varchar(1024) , @p3 char(1) , @p4 varchar(254), @p5 varchar(254), @debug bit ) 

My parameters in Java are defined as follows:

Object [] params = {"1,2,3", "d", '2', "," ", 1};

I think this is caused by the character. Any ideas why?

+4
source share
1 answer

I found him. Clockwork Muse set me on the road. The char type is not converted to an object when setting parameters. The following will work:

  try (PreparedStatement st = con.prepareStatement(query)) { int n = 1; for (Object o : params) { if (o instanceof Character) { o = "" + o; } st.setObject(n, o); n++; } st.executeQuery(); } 
+6
source

Source: https://habr.com/ru/post/1491713/


All Articles