java CachedRowSet和SQLite JDBC驱动程序
我正在尝试将CachedRowSet与SQLite和Xerial驱动程序https://bitbucket.org/xerial/sqlite-jdbc一起使用
如果我这样调用execute()方法:
Connection connection = DriverManager.getConnection("jdbc:sqlite:sample.db");
CachedRowSet crs = new CachedRowSetImpl();
crs.setCommand("select * from person");
crs.execute(connection);
我得到了SQLException“不是由SQLite JDBC驱动程序实现的”:
at com.sun.rowset.internal.CachedRowSetReader.readData(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.execute(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.execute(Unknown Source)
at com.oracle.tutorial.jdbc.CachedRowSetSample.testPaging(CachedRowSetSample.java:100)
at com.oracle.tutorial.jdbc.CachedRowSetSample.main(CachedRowSetSample.java:273)
另一方面,ResultSet和populate()代替excecute()工作正常:
Connection connection = DriverManager.getConnection("jdbc:sqlite:sample.db");
statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select * from person");
CachedRowSet crs = new CachedRowSetImpl();
crs.populate(rs);
有人知道execute()有什么问题吗
# 1 楼答案
不幸的是,在使用SQLite时,有一些JDBC函数需要实现变通方法。这恰好是其中之一。可能最好的替代解决方案是将整个结果集放入列表中<&燃气轮机;并与之合作:
this post中的答案包含一条注释,说明如果驱动程序不支持某个函数,该函数将被模拟