wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes BLOB insertion into the database hangs 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 "BLOB insertion into the database hangs" Watch "BLOB insertion into the database hangs" New topic

BLOB insertion into the database hangs

Anup Bansal
Ranch Hand

Joined: Sep 12, 2006
Posts: 69

I want to insert BLOB data > 4k into the database. I am using the package oracle.sql.blob.
We are using classes12.jar for the drivers.

Attached is the snippet of the code:

The above worked fine on WAS 5.1 with JDK 1.4.2 and classes12.zip. The oracle version being used is 10g
However we recently migrated to WAS 6.1. The JDK version being used is 1.5.1 and the driver calsses were replaced from classwes 12.zip to classes12.jar whcih is compatible with Oracle 10g
The database version is the same
However we observe that under load conditions, the query where we are inserting the empty blob takes an awfully long time and sometimes the session even hangs.
The method BLOB.empty_blob() is deprecated in the new calsses12.jar and so is the method getBinaryOutputStream().
Can this be cause of these delayed performance?

What methods can be used insted of the deprecated ones? (Java doc for Oracle.sql is not very exhausitve)

Can we use ojdbc.jar to get rid of this issue?

Kindly advise.

Thanks & regards,
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

We are using classes12.jar for the drivers.

Why? Are you using JDK 1.3 or lower? If not I'd upgrade to the latest driver your environment will support (see the Oracle JDBC page for info).

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Anup Bansal
Ranch Hand

Joined: Sep 12, 2006
Posts: 69
I have upgraded the driver to Ojdbc14.jar but still facing the same issue
Any ideas??
Phaneendra Pochinapeddi

Joined: Feb 02, 2005
Posts: 7
It is because below select statement might be returning multiple results. I have seen this happening and by making sure that the select query returns only single result, hanging of executeQuery will not happen

Regards<br />Phaneenda P
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
I'm not sure if this may help, but I personally don't ever use one database connection to execute more than one query at a time. Consider the following code:

By the time that the Statement stmt2 is created, stmt, the Connection connection may be still be in use by stmt, especially if the select-statement returned more than one row.
As a rule of thumb, I always make the inner SQL-statement run on a separate database connection, as in:

Try it.
I agree. Here's the link: http://aspose.com/file-tools
subject: BLOB insertion into the database hangs
It's not a secret anymore!