【发布时间】:2015-05-15 08:30:53
【问题描述】:
我正在尝试将字节 [] 转换为 blob。我的代码如下
byte [] hashValue = HashClass.hash256Bytes(messageValue);
//query = "insert into message values (?)";
connection = ConnectionFactory.getConnection();
//Blob blob = new javax.sql.rowset.serial.SerialBlob(hashValue);
Blob blob = new SerialBlob(hashValue);
//blob.setBytes(1, hashValue);
preStatement = (PreparedStatement)
connection.prepareStatement(query);
preStatement. setBlob(1, blob);
rs = preStatement.executeQuery();
但它在 preStatement 中中断。 setBlob(4,斑点)。我做了一点谷歌并尝试了下面的代码,但它在 connection.createBlob() 处给出了 null。
Blob blob = connection.createBlob();
blob.setBytes(1, bytes);
【问题讨论】:
-
你有没有试过只打电话给
preStatement.setBytes(1, bytes)? stackoverflow.com/questions/6090170/… 为什么要担心 256 字节的 BLOB? -
添加堆栈跟踪和查询
-
connection.createBlob() 处为空。表示未创建连接。添加堆栈跟踪或完整代码
-
connection.createBlob() 给我 null 并创建连接对象。请找到堆栈跟踪。目标 VM 中发生异常:SQLite JDBC 驱动程序未实现 java.sql.SQLException:SQLite JDBC 驱动程序未在 preStatement 上实现。 setBlob(1, blob)