Oracle connection / query timeout

Can I specify the connection / query timeout for Oracle database queries? Either on the Oracle side or in the Oracle JDBC driver (10.2.0.4)? So this Java client just got an error, say 2 minutes instead of waiting for Oracle to complete the query?

+2


source to share


2 answers


If you are executing a request in the context of a transaction, the JTA TP Monitor Transaction Timeout value will determine the request timeout value. The configuration for this depends on one application server from another.

On a query-by-query basis (if no JTA TP monitor is available), the setQueryTimeout method can be used to set a timeout when a Statement / PreparedStatement / CallableStatement is executed.



Update

setQueryTimeout should not be relied upon, although it does work (at least from a J2SE client). It works through a JDBC driver doing a full round to the Oracle database server. Then to make the database stop executing the query, the database. Don't rely on it for mission-critical applications.

+5


source


Take a look at Oracle profiles. This allows you to specify multiple constraints at the database level. One is the maximum CPU time for each request.



If you have queries running for more than 2 minutes on a regular basis, you might want to do some tweaking of your queries first.

+2


source







All Articles