Canceling a Statement

NuoDB does not support a Statement#cancel() call, but does supply killStatement() in the implementation class RemStatement. Implementing Statement#cancel() in NuoDB's JDBC driver is complicated because each connection to the database processes requests synchronously.

To use RemStatement#killStatement(), cast a Statement object to RemStatement and supply the connection URL and connection properties, including credentials. This will cause a second connection to be created and a KILL STATEMENT command to be executed.

Caution: Casting from Statement to RemStatement should be done with extreme caution as the underlying RemStatement implementation class is subject to change.

// Assume pStatement is a PreparedStatement object that needs to be killed...
final String dburl = "jdbc:com.nuodb://broker_host:48004/my_database";
final Properties properties = new Properties()
            put("user", getDBUser());
            put("password", getDBPassword());
            put("schema", getDBSchema());
((RemStatement)pStatement).killStatement(dburl, properties);