gpt4 book ai didi

java - SQLite JDBC驱动程序错误: getarray not implemented

转载 作者:太空宇宙 更新时间:2023-11-04 11:28:12 32 4
gpt4 key购买 nike

我正在尝试获取 ResultSet 并将其内容添加到字符串数组中。

Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery(String.format("SELECT * FROM %s", TABLE_STUDENTS));

Array resultArrayStudent = resultSetStudent.getArray(1);
String[] studentIds = (String[])resultArrayStudent.getArray();

但是我收到以下错误:

java.sql.SQLException: not implemented by SQLite JDBC driver
at org.sqlite.jdbc4.JDBC4ResultSet.unused(JDBC4ResultSet.java:333)
at org.sqlite.jdbc4.JDBC4ResultSet.getArray(JDBC4ResultSet.java:340)
at models.DataSource.classesTakenByEachStudent(DataSource.java:400)
at Main.main(Main.java:81)

什么可能导致抛出此异常?我正在使用 sqlite jdbc 3.18.0。

最佳答案

不,你不能直接获取数组,你必须循环抛出你的结果集并获取标识,你可以使用:

ResultSet resultSet = statement.executeQuery(String.format("....", TABLE_STUDENTS));
List<String> list = new ArrayList<>();//create a List
while (resultSet.next()){//loop throw the result set
list.add(resultSetStudent.getString("id"));//use the name of your col you want to get
}

关于java - SQLite JDBC驱动程序错误: getarray not implemented,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44122533/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com