[英]createArrayOf string in hsqldb.jdbc returns AbstractMethodError
I am writing test cases for my java program that runs with an Oracle database. 我正在为与Oracle数据库一起运行的Java程序编写测试用例。 My code is : 我的代码是:
st = conn.prepareStatement( MY_QUERY, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
Array array = conn.createArrayOf("VARCHAR", ids);
st.setArray(1, array);
rs = st.executeQuery();
where the query is 查询在哪里
QUERY = "SELECT * from TABLE where id in ?"
We are using the hsqldb database for our testing. 我们正在使用hsqldb数据库进行测试。 However, running the above code in tests gives 但是,在测试中运行上面的代码可以
java.lang.AbstractMethodError: org.hsqldb.jdbc.jdbcConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;
on the createArrayOf
line. 在createArrayOf
行上。
I haven't been able to find a solution to this problem. 我还没有找到解决此问题的方法。 Would appreciate any help given. 将不胜感激。 Thanks 谢谢
In the official HSQLDB JavaDoc (Version 2.x) of the class JDBCConnection
(which implements java.sql.Connection
) the createArrayOf
method is availble and documented: 在JDBCConnection
类的正式HSQLDB JavaDoc (版本2.x)(实现java.sql.Connection
)中, createArrayOf
方法createArrayOf
并记录如下:
createArrayOf createArrayOf
public Array createArrayOf(String typeName, Object[] elements) throws SQLException 公共数组createArrayOf(String typeName,Object [] elements)抛出SQLException
This method is supported since HSQLDB version 2.x. 从HSQLDB 2.x版本开始支持此方法。 Therefore, you should update your application to use the latest HSQLDB driver which can be downloaded here . 因此,您应该更新您的应用程序,以使用可以在此处下载的最新HSQLDB驱动程序 。
According to the changelist , you should use at least version 2.2.1 of HSQLDB driver as the dev team " fixed type limitations of Connection#createArrayOf " method with this release. 根据更改列表 ,在此版本中,至少应使用HSQLDB驱动程序2.2.1版作为开发团队的“ Connection#createArrayOf的固定类型限制 ”方法。
HSQLDB中的SQL查询语法不同:
SELECT * from TABLE WHERE id IN(UNNEST(?))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.