jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Storing blob > 4kb in oracle db through jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Storing blob > 4kb in oracle db through jdbc" Watch "Storing blob > 4kb in oracle db through jdbc" New topic

Storing blob > 4kb in oracle db through jdbc

IM Mahesh

Joined: Mar 09, 2006
Posts: 18
Hello friends,

I am facing problem to store a file data in oracle blob having file size grater than 4kb. However if i try to store file smaller than 4kb it's working fine.

I get following error.

java.sql.SQLException: Io exception: Software caused connection abort: socket write error
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:345)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2094)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1986)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2697)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:457)
at com.evermind.sql.FilterPreparedStatement.executeUpdate(FilterPreparedStatement.java:240)
at com.evermind.sql.FilterPreparedStatement.executeUpdate(FilterPreparedStatement.java:240)
at com.evermind.sql.FilterPreparedStatement.executeUpdate(FilterPreparedStatement.java:240)

What could be the solution for this?

Thanks in advance.


viju vi

Joined: Nov 15, 2007
Posts: 7
Hi man,

even im getting the same kind of error, i tried all possible ways but its giving me the same error. you see if you try a file or data less than 4k it works well and fine but data which exceeds that you get this error. Can you post the code and which database you are trying to use...

"No problem can be solved from the same level of consciousness that created it." Albert Einstein
viju vi

Joined: Nov 15, 2007
Posts: 7
i found one. database using oracle 8i

first what you do is get the OracleConnection instead of jdbc.Connection object. next insert a empty blob object into database then select the blob object that was inserted previously by using
for update
clause because we do update when we are fetching it.
now read the file and input it into the blob object.

hope below code might help.

hope this code helps you
Kajal Chakole

Joined: Nov 14, 2011
Posts: 2
it worked.. thanks viju vi.
i was also getting same exception in oracle10g with type 4 jdbc driver.
instead of overcoming the limitation of the existing driver by upgrading it, (cannot upload > 4k data) we can use this code with little modifications.

Nothing is impossible.
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3718

Welcome to the Ranch!

You can use the code tag to make your code much more readable. I've added it for you this time, so you can see how much better it looks

Kajal Chakole wrote:instead of overcoming the limitation of the existing driver by upgrading it...

Upgrading the driver should be the first option. Even the newest driver is compatible with older databases (all the way back to 9i) and contains some important optimizations. See also our Oracle FAQ.
Have you checked out Aspose?
subject: Storing blob > 4kb in oracle db through jdbc
It's not a secret anymore!