Stop or end a long query in JDBC

Is there a way to stop or terminate a long Oracle query in JDBC? This often causes the application server to restart to force jdbc to disconnect from Oracle DB.

Search for functionality similar to SQL Plus - Kill session in Java or JDBC

in SQL Plus

 SQL> ALTER SYSTEM KILL SESSION 'sid,serial#'; 

any key to execute in java?

+6
source share
3 answers

Perhaps the bit is off, but I would suggest using the JDBC timeout . This has the added benefit of being virtually terminated gracefully rather than by force.

With modern application servers, you can usually determine the JDBC timeout from the data source configuration.

+6
source

except for the jdbc timeout, if you run your request in another thread, you can use Statement.cancel () to kill it.

+4
source

You can try Statement.setQueryTimeout

+1
source

Source: https://habr.com/ru/post/917616/


All Articles