user3837019
user3837019

Reputation: 221

Retrieving image from sqlite database java

Trying to retrieve stored images from sqlite database but don't seem to be having any luck. My code:

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();
}

The errors which i'm getting are:

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)

Upvotes: 0

Views: 241

Answers (1)

Bishan
Bishan

Reputation: 15710

The SQLite JDBC implementation you're using doesn't implement getBinaryStream.

You'll need to use the getBytes method instead.

Upvotes: 2

Related Questions