Lluis Martinez
Lluis Martinez

Reputation: 1973

Abort insert ... select clause

Is it possible to abort an insert ... select clause from Java ? Using either JDBC or Hibernate, it doesn't matter. The DB is Oracle.

I reckon it's not possible because there is a single DB call and the process is running in Oracle, not the JVM.

Upvotes: 0

Views: 176

Answers (1)

ibre5041
ibre5041

Reputation: 5298

Oracle OCI (C driver) provides an OCIBreak() function. It's even thread-safe and you can call it from any bg thread, while the main thread is using the same connection.

Maybe that Statement.cancel() does the same thing.

This OCIBreak() requires round trip to DB server (i.e. the network must be functional) and then the main thread receives an error:

java.sql.SQLException: ORA-01013: user requested cancel of current operation

You should be able to mark this exception as non-critical on JBOSS level (using ExceptionSorter).

PS: I'm really curious if this could be called from hibernate. As JPA leaves many long running queries on our DB servers.

Upvotes: 1

Related Questions