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.