无法将图像保存为blob到sqlite [英] cannot save image as blob to sqlite

查看:171
本文介绍了无法将图像保存为blob到sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是SQLite,我无法将图像保存到数据库中。
这是我的代码:

I am using SQLite and I cannot save a image to the database. This is my code :

File file = new File(url);
  try {
    fis = new FileInputStream(file);
  } catch (FileNotFoundException e) {}
fileLenght = (int) file.length();

stat.executeUpdate("create table "+tableName+" (id int,name String ,image Blob, features String);");
prep = conn.prepareStatement("insert into "+tableName+" values (?, ?, ?, ?);");
prep.setBinaryStream(3, fis, fileLenght);

这是我得到的错误:

java.sql.SQLException: not implemented by SQLite JDBC driver
  at org.sqlite.Unused.unused(Unused.java:29)
  at org.sqlite.Unused.setBinaryStream(Unused.java:58)

我使用的是以下jar:sqlitejdbc-v056 。罐。

I am using the following jar : sqlitejdbc-v056.jar.

任何想法?
谢谢

Any ideas? Thanks

推荐答案

您正在使用的SQLite JDBC实现未实现 setBinaryStream (因此SQLite JDBC驱动程序错误消息没有实现准确的)。

The SQLite JDBC implementation you're using doesn't implement setBinaryStream (hence the accurate not implemented by SQLite JDBC driver error message).

您需要使用 setBytes 方法。

这篇关于无法将图像保存为blob到sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆