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 a TE processes requests synchronously (any attempt to cancel would only run after that statement has already completed).

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.

Casting from Statement to RemStatement should be done with extreme caution as the underlying RemStatement implementation class is subject to change.
final String dburl = "jdbc:com.nuodb://host:48004/my_database";
final Properties properties = new Properties()
            put("user", getDBUser());
            put("password", getDBPassword());
            put("schema", getDBSchema());

if (pStatement instanceof RemStatement)
    ((RemStatement)pStatement).killStatement(dburl, properties);