NutzCN Logo
问答 如何将byte[]转换成blob存入oracle数据库
发布于 2787天前 作者 qq_813fba71 2683 次浏览 复制 上一个帖子 下一个帖子
标签:

insert into PICTUREDATA(id,data) values(....)

8 回复

报什么, 详细的,完整的日志

insert into PICTUREDATA(id,data) values(....)

改成这样试试

sqlList.params().set("pdata", image);
// 改成 
sqlList.params().set("pdata", new SerialBlob(image));

Caused by: java.sql.SQLException: Error
	at com.alibaba.druid.pool.DruidDataSource.handleConnectionException(DruidDataSource.java:1180)
	at com.alibaba.druid.pool.DruidPooledConnection.handleException(DruidPooledConnection.java:127)
	at com.alibaba.druid.pool.DruidPooledStatement.checkException(DruidPooledStatement.java:68)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.setBlob(DruidPooledPreparedStatement.java:596)
	at org.nutz.dao.impl.jdbc.BlobValueAdaptor.set(BlobValueAdaptor.java:35)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:266)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:82)
	... 49 more
Caused by: java.lang.ClassCastException: javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB
	at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStatement.java:7193)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.setBlob(OraclePreparedStatementWrapper.java:137)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.setBlob(DruidPooledPreparedStatement.java:594)
	... 52 more

这样好像不行

先用pojo的方式插入吧

pojo成功啦!谢谢大神指点

看来要报个issue了

添加回复
请先登陆
回到顶部