我正在使用SQLite,我无法将图像保存到数据库.这是我的代码:
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);
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
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)
Run Code Online (Sandbox Code Playgroud)
我使用以下jar:sqlitejdbc-v056.jar.
有任何想法吗?谢谢
我使用SQLite创建了一个数据库.我想更新"功能"列的值(类型Blob)...但我不知道如何编写"更新"语句.这是我试过的:
try {
stat = conn.createStatement();
} catch (SQLException e) {
}
try {
byte[] b = getFunction();
stat.executeUpdate("update table set features="+b);
} catch (SQLException e) {
}
Run Code Online (Sandbox Code Playgroud)
我得到了以下错误:
java.sql.SQLException: unrecognized token: "[B@13a317a"
Run Code Online (Sandbox Code Playgroud)
所以我猜"b"是问题?