从sqlite数据库java中检索图像

时间:2014-07-17 14:54:39

标签: java database image sqlite

尝试从sqlite数据库中检索存储的图像,但似乎没有运气。我的代码:

int i = 0;
while (resultSet.next()) {
    InputStream in = resultSet.getBinaryStream(1);
    OutputStream f = new FileOutputStream(new File("PeoplesInfo"+i+".jpg"));
    i++;
    int c = 0;
    while ((c = in.read()) > -1) {
        f.write(c);
    }
    f.close();
    in.close();
}

我得到的错误是:

java.sql.SQLException: not implemented by SQLite JDBC driver
at org.sqlite.Unused.unused(Unused.java:29)
at org.sqlite.Unused.getBinaryStream(Unused.java:92)
at Database.main(Database.java:50)

1 个答案:

答案 0 :(得分:2)

您正在使用的SQLite JDBC实现未实现getBinaryStream

您需要改为使用getBytes方法。