JDBC 标志
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
JDBC 知道一些执行标志和模式,可以通过 jOOQ API 进行设置。 jOOQ 本质上支持这些标志和执行模式
public interface Query extends QueryPart, Attachable {
// [...]
// The query execution timeout.
// -----------------------------------------------------------
Query queryTimeout(int timeout);
}
public interface ResultQuery<R extends Record> extends Query {
// [...]
// The query execution timeout.
// -----------------------------------------------------------
@Override
ResultQuery<R> queryTimeout(int timeout);
// Flags allowing to specify the resulting ResultSet modes
// -----------------------------------------------------------
ResultQuery<R> resultSetConcurrency(int resultSetConcurrency);
ResultQuery<R> resultSetType(int resultSetType);
ResultQuery<R> resultSetHoldability(int resultSetHoldability);
// The buffer size for JDBC cursors
// -----------------------------------------------------------
ResultQuery<R> fetchSize(int size);
// The maximum number of rows to be fetched by JDBC
// -----------------------------------------------------------
ResultQuery<R> maxRows(int rows);
}
将 ResultSet 并发与 ExecuteListeners 一起使用
此处给出了一个示例,说明了为什么您可能想要手动将 ResultSet 的并发标志设置为非默认值
DSL.using(new DefaultConfiguration()
.set(connection)
.set(SQLDialect.ORACLE)
.set(ExecuteListener.onRecordStart(ctx -> {
try {
// Change values in the cursor before reading a record
ctx.resultSet().updateString(BOOK.TITLE.getName(), "New Title");
ctx.resultSet().updateRow();
}
catch (SQLException e) {
throw new DataAccessException("Exception", e);
}
)))
.select(BOOK.ID, BOOK.TITLE)
.from(BOOK)
.orderBy(BOOK.ID)
.resultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)
.resultSetConcurrency(ResultSet.CONCUR_UPDATABLE)
.fetch(BOOK.TITLE);
在上面的示例中,您的自定义 ExecuteListener 回调在 jOOQ 从 java.sql.ResultSet加载新的 Record之前被触发。将并发设置为 ResultSet.CONCUR_UPDATABLE 后,您现在可以通过标准 java.sql.ResultSet API 修改数据库游标。
反馈
您对此页面有任何反馈吗? 我们很乐意听到您的反馈!