Calling HSQLDB IDENTITY function with CallableStatement to get output

给你一囗甜甜゛ 提交于 2019-12-11 07:55:58

问题


I'm trying to use CallableStatements to get the value of IDENTITY() in HSQLDB from Java JDBC.

I can prepareCall fine. The issue is with registerOutputParameter. I get "parameter index out of range" no matter what index I pass in.

I've tried SQL snippets like "{? = CALL IDENTITY()}" with no luck.

Any clues? Am I completely off track in how to invoke HSQLDB function routines from JDBC?


回答1:


Instead of using IDENTITY(), use getGeneratedKeys() to retrieve any keys generated by the (insert) statement.

Note that you do need to use one of the Statement.execute... or Connection.prepare... methods that will enable this feature.




回答2:


Gah.

http://sourceforge.net/tracker/index.php?func=detail&aid=3530755&group_id=23316&atid=378134

Output parameters for function invocation is not supported. Use executeQuery and grab the ResultSet.



来源:https://stackoverflow.com/questions/12221960/calling-hsqldb-identity-function-with-callablestatement-to-get-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!