SQL/MX Programming Manual for Java
SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java—523726-003
3-16
Explicit Connection Contexts
WHERE partnum = :partNum};
#sql [ctx1] {DELETE FROM samdbcat.invent.partloc
WHERE partnum = :partNum};
ctx1.close();
#sql [ctx2] {DELETE FROM samdbcat.sales.parts
WHERE partnum = :partNum};
ctx2.close();
}
catch(Exception e)
{
System.err.println("Exception: " + e);
}
}
}
In the previous example, the ctx1.close() and ctx2.close() methods close all
resources used by the connection contexts, ctx1 and ctx2. You should explicitly
close a connection context when it is no longer used rather than waiting for garbage
collection to free resources.
Connection Context Methods
The connection context class includes several methods that enable you to manipulate
or obtain information about a connection in an SQLJ program:
For more information, see sqlj.runtime.ConnectionContext Interface on page B-2.
close() Releases all resources for the specified connection context
object and closes the underlying JDBC Connection
object.
close(boolean) Releases all resources for the specified connection context
object.
If you pass CLOSE_CONNECTION as an argument,
the underlying JDBC connection closes.
If you pass KEEP_CONNECTION as an argument, the
underlying JDBC connection remains open.
getConnection() Returns the underlying JDBC connection.
getExecutionContext() Returns the default execution context for the connection.
isClosed() Returns true if the connection context is closed.
Returns false if the connection context remains open.