HSQLDB cryptic exception message: “feature not supported”

前端 未结 3 1103
执笔经年
执笔经年 2021-01-17 18:56

I have JDBC code which inserts into a database table by executing a PreparedStatement. When I run the code on an in-memory HSQLDB database (as part of a JUnit test) I get a

3条回答
  •  醉话见心
    2021-01-17 19:47

    You need to call preparedStatement.executeUpdate() (without the parameter sql).

    You called the method PreparedStatement.executeUpdate(String sql), which is illegal according to the JDBC specification. It doesn't really make sense to pass the SQL statement again, because you have already passed it when you created the PreparedStatement object. Even thought you pass the same string, it's not legal to call this method. It's a bit strange that calling a method is not legal :-) but that's the way it is. All standard conforming JDBC drivers need to throw an exception in this case.

    But I agree the error message is cryptic.

提交回复
热议问题