Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当JDBC驱动程序未实现PreparedStatement.setBlob()时,如何将BLOB写入数据库_Java_Sqlite_Jdbc - Fatal编程技术网

Java 当JDBC驱动程序未实现PreparedStatement.setBlob()时,如何将BLOB写入数据库

Java 当JDBC驱动程序未实现PreparedStatement.setBlob()时,如何将BLOB写入数据库,java,sqlite,jdbc,Java,Sqlite,Jdbc,在我使用以下代码将BLOB值写入数据库之后: // bb is of type ByteBuffer Blob blob = new SerialBlob(bb.array()); sqlStatement = "UPDATE Words SET Examples=? WHERE Word=\"" + word + "\""; // c is of type Connection PreparedStatement pstmt = c.prepareSta

在我使用以下代码将BLOB值写入数据库之后:

    // bb is of type ByteBuffer
    Blob blob = new SerialBlob(bb.array());
    sqlStatement = "UPDATE Words SET Examples=? WHERE Word=\"" + word + "\"";
    // c is of type Connection
    PreparedStatement pstmt = c.prepareStatement(sqlStatement);
    pstmt.setBlob(1, blob);
    pstmt.executeUpdate();
    c.commit();
我得到了以下错误:

java.sql.SQLException:不是由SQLite JDBC驱动程序实现的


无论我从何处下载此驱动程序,我的问题是您是否知道有任何安全的方法将BLOB值写入SQLite数据库。

我想您忘记了为
示例
列设置值

st.setAsciiStream(1, fin, (int) file.length());//if you are storing file in database

我想我找到了一个有用的方法。最后我使用了下面的代码,它成功了

pstmt.setBytes(1, blob.getBytes(1, bb.capacity()));

例如,您在哪里设置该值?使用setAsCistream()或setBinaryStream()而不是setBlob()是一种很好的做法