Entering timeouts into prepared statements

I am trying to use prepared statements that work in a database located quite far away, and there is a significant lag and unreliability in the network connection used to access this database. Downtime up to a minute is normal. The problem is that in the event of such a failure, if my program tries to execute any prepared statement, the whole thread goes to endless waiting. This never expires and just remains stuck waiting for a response from the database.

I tried using the setQueryTimeout () method to explicitly set the timeout to execute, but there seem to be some problems with this method when it does not work properly if the network crashes.

Is there an alternative way?

+5
source share
1 answer

As far as I know, there is no such alternative if the network itself is down.

The exact details of setQueryTimeout include a JDBC driver that is instructed to send an Out Of Band signal (at least in the case of the Oracle JDBC driver) to the database to stop the execution of a prepared statement; this part is important as it depends on the support built into the driver and database. After that, the database must be scheduled to execute this operation "cancel"; it may take some time if everything needs to be canceled or if other transactions need to be completed, etc.

, , โ€‹โ€‹ "" . , (, JTA), , ( ).

, "" , . SO , . , WebLogic Server.

+3

All Articles