Available in versions: Dev (3.22) | Latest (3.21) | 3.20 | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12
Fetch server output
Supported by ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Some databases allow procedural code to produce server output, such as Oracle's DBMS_OUTPUT.PUT_LINE(). Such output is buffered on the server and is not returned to JDBC clients unless it is explicitly enabled and fetched. If the fetchServerOutputSize setting is greater than 0, jOOQ enables the server output prior to executing each statement, and fetches up to that many lines of output afterwards, in dialects that support it.
The fetched lines are written to the log, and are also made available to ExecuteListeners through ExecuteContext.serverOutput():
DSLContext ctx = DSL.using(connection, SQLDialect.ORACLE, new Settings()
.withFetchServerOutputSize(10));
ctx.configuration().set(new DefaultExecuteListener() {
@Override
public void end(ExecuteContext c) {
for (String line : c.serverOutput())
System.out.println(line);
}
});
ctx.execute("begin dbms_output.put_line('Hello world'); end;");
Example configuration
Settings settings = new Settings()
.withFetchServerOutputSize(10); // Defaults to 0, i.e. server output isn't fetched
Feedback
Do you have any feedback about this page? We'd love to hear it!