This is a type of Scope that can manage resources on behalf of the
call site, and free / close those resources once the scope ends.
For example, Binding implementations may wish to create Clob
or InputStream or other kinds of resources in order to bind them to
JDBC. Instead of remembering to close them manually through some delicate
logic involving e.g. clever usage of ThreadLocal, implementations can
register their resources with the methods exposed here, and jOOQ will take
care of freeing / closing them at the right moment.
Example:
class StreamingLobBinding implements Binding<String, File> {
...
public void set(BindingSetStatementContext<File> ctx) {
ctx.statement()
.setBinaryStream(ctx.index(), ctx.closeAfterExecution(new FileInputStream(ctx.value())));
}
}
This type is a Scope with whose lifecycle is typically tied to an
ExecuteContext, sharing the latter's data() map.
| Modifier and Type | Method and Description |
|---|---|
| public <R extends Closeable> R | |
| public <R extends AutoCloseable> R | Returns: The argument closeable, for convenience.Register an |
| public Array | |
| public Blob | |
| public Clob | |
| public SQLXML |
| autoClose | back to summary |
|---|---|
| public <R extends Closeable> R autoClose(R closeable) Register a
| |
| autoClose | back to summary |
|---|---|
| public <R extends AutoCloseable> R autoClose(R closeable) Register an
| |
| autoFree | back to summary |
|---|---|
| public Array autoFree(Array array) Register a
| |
| autoFree | back to summary |
|---|---|
| public Blob autoFree(Blob blob) Register a
| |
| autoFree | back to summary |
|---|---|
| public Clob autoFree(Clob clob) Register a
| |
| autoFree | back to summary |
|---|---|
| public SQLXML autoFree(SQLXML xml) Register a
| |