OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/J

V2.2.3
  • What is OceanBase Connector J?
    • JDBC overview
    • Compatibility requirements
  • Instructions
    • Install OceanBase Client
    • Basic operations
      • Import packages
      • Create a database connection
      • Create a Statement object
      • Run queries and retrieve ResultSet objects
      • Process a ResultSet object
      • Close ResultSet and Statement objects
      • Modify a database
      • Commit changes
      • Close a database connection
    • Handle SQL exceptions
    • Java data streams
      • Overview of Java data streams
      • LONG and LONG RAW data types
      • LOB data types
    • Use LOBs
      • Overview of LOB data types
      • LOB data API
      • LOB locator API
      • CHAR, VARCHAR, and RAW data types
    • Use CallableStatements to call stored procedures
    • Data sources and URL
      • Data source overview
      • Data source characteristics and properties
      • Create and connect to a data source instance
      • Database URL
    • Result set
      • Limits and degradation rules
      • Fetch size
      • Refetch rows
      • Cursor result sets
    • Statement caching
      • Statement caching overview
      • Use statement cache
      • Reuse statement objects
    • Failover and load balancing modes
    • Batch processing
    • JDBC security features
    • SQL NetworkCostInfo
    • Troubleshooting
    • Common APIs
      • java.sql.Connection
      • java.sql.CallableStatement
      • java.sql.DatabaseMetaData
      • java.sql.Driver
      • java.sql.PreparedStatement
      • java.sql.ParameterMetaData
      • java.sql.ResultSet
      • java.sql.ResultSetMetaData
      • java.sql.Statement
      • javax.sql.ConnectionPoolDataSource
      • javax.naming.Context
      • javax.sql.PooledConnection
    • Reference
      • Supported SQL and PL data types
  • Features specific to the Oracle mode
    • Call PL stored procedures
    • Result set performance
    • Use ARRAY and STRUCT classes
    • Distributed transactions
      • Overview of distributed transactions
      • XA components
      • Distributed transaction examples
    • Error messages in Oracle mode
    • Data types supported in Oracle mode
  • Release Notes
    • V2.2
      • OceanBase Connector/J V2.2.11
      • OceanBase Connector/J V2.2.10
      • OceanBase Connector/J V2.2.3
      • OceanBase Connector/J V2.2.0

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/J
  3. V2.2.3

Fetch size

Last Updated:2026-09-04 08:24:25

Set the fetch size
Preset the fetch direction

You can use Fetch Size to change the row fetch size to change the number of rows retrieved each time the database cursor is accessed.

By default, when the OceanBase JDBC driver runs a query, it retrieves a result set of 10 rows from the database cursor at a time.

The standard JDBC also allows you to specify the number of rows to be retrieved from the database during each round trip, which is called the fetch size. In OceanBase JDBC, the row-prefetch value is the default fetch size for the statement object. The fetch size configured will override the row-prefetch value and takes effect on subsequent queries of the statement object.

Fetch Size also applies to result sets. When a statement object runs a query, the fetch size of the statement object is passed to the result set object of the query. However, you can also specify the fetch size in the result set object to override the statement fetch size passed to it. Notice

After the result set is generated, changes made to the fetch size of the statement object does not take effect on the result set.

The fetch size of the result set, no matter explicitly set or by default equal to the statement fetch size passed to the result set, can determine the number of rows retrieved during subsequent database access for the result set, including all the trips still required to complete the query and all the trips to refetch the data into the result set. You can refetch data explicitly or implicitly to update a scroll-sensitive result set or a scroll-insensitive/updatable result set.

Set the fetch size

You can use the following method to set and obtain the fetch size for all Statement, PreparedStatement, CallableStatement, and ResultSet objects:

  • void setFetchSize(int rows) throws SQLException

  • int getFetchSize() throws SQLException

To set the fetch size for a query, call setFetchSize on the statement object before you run the query . If you set the fetch size to N, N rows are obtained during each access to the database.

After you run the query, you can call setFetchSize on the result set object to override the statement object fetch size passed to it. The setting takes effect on subsequent trips to the database to obtain more rows for the original query and on subsequent row refetching.

Preset the fetch direction

standard JDBC allows you to pre-specify the result set processing direction, also known as the fetch direction. Use the following result set methods:

  • void setFetchDirection(int direction) throws SQLException

  • int getFetchDirection() throws SQLException

The OceanBase JDBC driver supports only a forward preset value, which can be specified by entering the ResultSet.FETCH_FORWARD static constant value.

Values such as ResultSet.FETCH_REVERSE and ResultSet.FETCH_UNKNOWN are not supported. If you attempt to use these values, an SQL warning is returned and the setting will be ignored.

Previous topic

Limits and degradation rules
Last

Next topic

Refetch rows
Next
on this page
Set the fetch size
Preset the fetch direction