The conversion from UNKNOWN to UNKNOWN is unsupported

I get the following exception running a stored procedure:

com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.

  • Async Stored Procedure Call in T-SQL
  • How do I flush the PRINT buffer in TSQL?
  • Input a specific day or days to retrieve data
  • Is it safe to use a session-owned SQL Server sp_getapplock with EF6 DbContexts?
  • how to change the account asscoiated with sql server
  • Check if login already added in User Defined Database Role
  • The procedure is defined like this:

    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 like this:

    Object[] params = {“1,2,3”, “d”, ‘2’, “”, “”, 1};

    I think it’s caused by the character. Any ideas why?

  • MYSQL command in JSP code
  • SQL and Java return different dates?
  • Sequential JDBC statement executions not transacting
  • how can i retrieve error messages to my java programmer from sqlserver
  • java.lang.OutOfMemoryError: Java heap space
  • SQLException during executeBatch() when I'm handling BatchUpdateException
  • One Solution collect form web for “The conversion from UNKNOWN to UNKNOWN is unsupported”

    I found it. Clockwork-Muse put me on the path. The char type does not convert to an Object when you set the 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();
        }
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.