Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes java.sql.sqlexception data size bigger than max size for this type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.sqlexception data size bigger than max size for this type" Watch "java.sql.sqlexception data size bigger than max size for this type" New topic
Author

java.sql.sqlexception data size bigger than max size for this type

A Shehadi
Greenhorn

Joined: Jul 13, 2009
Posts: 19
Hello ranchers.

I'm developing an application using Apache Turbine + Torque and Oracle 10g for my DB and am encountering this error:

java.sql.sqlexception data size bigger than max size for this type.

I've searched it in Google and everyone says that you should use a BLOB type instead of a LONG RAW, but my problem is that I'm using BLOB to store a 17k image in the database. My code is as follows:



I have trimmed the rest of it as it is non-relevant, but the basics are there. I'm using a Torque object (entryIntratImagenes) to save into the database, and am getting the image bytes through a regular SQL Query.

My table is as follows:



What could be wrong? Why is it telling me the max size for BLOB is not big enough to save 17k bytes?

Thanks a lot!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Are you sure that is the code that is causing your error? LOBs don't have a maximum size, and data truncation error only usually occur on update or insert not select.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
A Shehadi
Greenhorn

Joined: Jul 13, 2009
Posts: 19
I have found the error.

It lies within the Oracle JDBC driver. Apparently there's a bug in the version I was using that sets LOB file types to a maximum size of 4K, which renders them almost useless.

I just downloaded a new driver version (10.2.0.4 I believe) and it all worked flawlessly. At least in my local machine....because as soon as I deploy it on our webserver (Oracle App Server) it breaks again


A Shehadi
Greenhorn

Joined: Jul 13, 2009
Posts: 19
Well, it turns out that for some reason my App Server is not using the updated ojdbc14 library, so the error persists.

If anyone is still interested, the workaround was to insert every other piece of data besides the Blob (insert null in the blob) and the either update the blob field using an OutputStream or directly from another table in the same database and it will work fine.

I hope this helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.sqlexception data size bigger than max size for this type