JDBC describe returns INTEGER type for a CHAR field

Unanswered JDBC describe returns INTEGER type for a CHAR field

  • Friday, November 16, 2012 9:41 PM
     
     

    Hello, 

    I'm seeing what seems like a bug in JDBC, which I'm able to reproduce with JDBC Driver 4.0 and SQL Server 2012.  I wanted to check if this was already noted or addressed somewhere before opening a support case.  

    I'm running a query with two parameters.  The second parameter of the query should be  described as type 1 (CHAR), but instead is  returned as type 4 (INTEGER).   The method which returns the incorrect value is  ParameterMetaData.getParameterType()  

    I have a standalone reproduction ready, here is the log for it that shows the query and the returns:

    Excuting statement: CREATE TABLE TESTMSS (FA01SMALLINT SMALLINT, FA02INTEGER INTEGER, FA07CHAR_10 CHAR(10) )

    Issue commit

    Prepare statement: SELECT FA01SMALLINT, FA02INTEGER, FA07CHAR_10 FROM TESTMSS WHERE FA01SMALLINT < ? AND FA02INTEGER > 12345 AND FA07CHAR_10  > ? ORDER BY FA01SMALLINT

    Parameter count is 2

    Parameter 1 type is 5

    Parameter 1 typename is smallint

    Parameter 2 type is 4

    Parameter 2 typename is int

    close connection

All Replies