Why does PreparedStatement.setNull requires sqlType?

前端 未结 3 1940
小蘑菇
小蘑菇 2021-01-01 16:56
  1. According to the java docs of PreparedStatement.setNull: \"Note: You must specify the parameter\'s SQL type\". What is the reason that the method requires the SQL t

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 17:46

    JDBC drivers appear to be moving away from setNull. See Add support for setObject(, null).

    My list of databases supporting the more logical behaviour is:

    1. Oracle
    2. MySQL
    3. Sybase
    4. MS SQL Server
    5. HSQL

    My list of databases NOT supporting this logical behaviour is:

    1. Derby Queries with guarded null Parameter fail
    2. PostgreSQL Cannot pass null in Parameter in Query for ISNULL Suggested solution

提交回复
热议问题