java 存储 blob,将Java中的Blob存储到BD:显然不是这种类型的数据大小超过最大大小...

Ok, here we go...

I am trying to call a Stored Procedure (PL/SQL), one of the parameters is a blob, but when I execute the OracleCallableStatement I get this error:

java.sql.SQLException: Data size bigger than max size for this type

That is oh so very frustrating..

I have tried to do the following and fails...

oracleCallableStatement.setBinaryStream(3, new ByteArrayInputStream(someByteArray), someByteArray.length);

I get the same error with:

oracleCallableStatement.setBytes(3, someByteArray);

I also changed the oracle driver, since I read web pages like this:

But the problem is persistent

The DB is an Oracle 11g

JavaEE is 1.5 running in Glassfish 2.1

Well, I guess that's it, my someByteArray is not bigger than 4Gb! it has a length of 38678

EDIT:

The exception is firing before the execute.. it fires when I set an attribute for the OracleCallableStatement

Portion of the stack trace:

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)

at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:103)

at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2484)

at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1224)

at oracle.jdbc.driver.OraclePreparedStatement.setBinaryStream(OraclePreparedStatement.java:2710)

EDIT

So, hello again, going to put this here... tell me if I´m doing wrong and I will delete it...

someByteArray was an array that was get from a someString.toByteArray()

That String was holding a representation of a (EDIT: used to say jpeg) PNG image encoded in Base64...

So, I used a method in sun.misc.BASE64Decoder to get the someByteArray from the someString...

then I used

oracleCallableStatement.setBinaryStream(3, new ByteArrayInputStream(someByteArray), someByteArray.length);

And it worked like a charm..

BUUUT...

Usage of the classes in sun.misc is not recommended, read this for further information..

BUT!!!

That doesn't solve the mystery to why I was unable to put the first byte array into the parameters and the mystery of the cryptic exception "java.sql.SQLException: Data size bigger than max size for this type" ...

EDIT:

This error appeared again... this time everything was alright, I was decoding the base64 correctly, but "java.sql.SQLException: Data size bigger than max size for this type" kept returning...

EDIT:

It was the driver, I change it on the server and the app, and I redeployed and everything worked fine...

解决方案

Turns out it was the driver, I changed to ojdbc5.jar as I stated in my question, and I had to make sure that the web server picked the correct one and not the older one, as pointed by Alex Poole, and problem solved.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值