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.4.17
  • What is OceanBase Connector J?
    • Overview of OceanBase Connector/J
    • Compatibility requirements
  • Install Driver
    • Install and load OceanBase Connector/J
  • Instructions
    • Quick start
      • Import packages
      • Establish a database connection
      • Create a Statement object
      • Run queries and retrieve ResultSet objects
      • Process ResultSet objects
      • Close ResultSet and Statement objects
      • Manage tables and data
      • Commit changes
      • Close a database connection
      • Examples
    • Data sources and URL
      • Data source overview
      • Database URL
      • clientInfoProvider
    • Java data streams
      • Overview of Java data streams
      • LONG and LONG RAW data types
      • Use LOBs
        • Overview of LOB data types
        • LOB data interface
        • LOB locator interface
      • CHAR, VARCHAR, and RAW data types
    • Statement caching
      • Overview of statement caching
      • Use statement caching
      • Reuse statement objects
    • Call a stored procedure
    • Handle SQL exceptions
    • Result set
      • Overview of result sets
      • Limitations
      • FetchSize
      • refreshRow
      • useCursorFetch
    • Batch processing
    • Failover and Load-Balancing
      • Failover and load balancing modes
      • LoadBalance strategies
      • Load balancing strategy configuration methods
    • Rich client
    • Logging
    • Network overheads
    • Show Trace
    • Security features
    • Troubleshooting
  • Reference
    • Features specific to the Oracle mode
      • Binary Protocol (Prepared Statements)
        • COM_STMT_PREPARE_EXECUTE
        • COM_STMT_SEND_PIECE_DATA
      • Call PL stored procedures
      • Scrollability of a result set
      • Use ARRAY and STRUCT classes
      • Distributed transactions
        • Overview
        • XA components
        • Distributed transaction examples
      • Obtain remarks
      • Data types supported in Oracle mode
      • Error messages in Oracle mode
    • Supported SQL and PL data types
    • Common APIs
      • Overview
      • 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
      • com.oceanbase.jdbc.ObPrepareStatement
  • Release Notes
    • V2.4
      • OceanBase Connector/J V2.4.17
      • OceanBase Connector/J V2.4.16
      • OceanBase Connector/J V2.4.15
      • OceanBase Connector/J V2.4.14
      • OceanBase Connector/J V2.4.13
      • OceanBase Connector/J V2.4.12
      • OceanBase Connector/J V2.4.11
      • OceanBase Connector/J V2.4.8
      • OceanBase Connector/J V2.4.5
      • OceanBase Connector/J V2.4.4
      • OceanBase Connector/J V2.4.3
      • OceanBase Connector/J V2.4.2
      • OceanBase Connector/J V2.4.1
      • OceanBase Connector/J V2.4.0
    • V2.2
      • OceanBase Connector/J V2.2.11
      • OceanBase Connector/J V2.2.10
      • OceanBase Connector/J V2.2.7
      • OceanBase Connector/J V2.2.6
      • 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.4.17

FetchSize

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

Set the fetch size
Preset the fetch direction

FetchSize specifies the number of rows each time the database returns for a request.

When you execute a query by using OceanBase Connector/J, you can specify FetchSize to set the number of rows to be retrieved from the database during each round trip. In OceanBase Connector/J, the default value of FetchSize is the default fetch size for the statement object. The fetch size configured will overwrite the default FetchSize value and takes effect on subsequent queries of the statement object.

FetchSize also applies to result sets. When a statement object runs a query, the FetchSize of the statement object is passed to the result set object of the query.

Notice

After the result set is generated, changes made to the FetchSize of the statement object do not take effect on the result set.

The FetchSize 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.

Set the fetch size

You can use the following methods to set and obtain FetchSize for all Statement, PreparedStatement, CallableStatement, and ResultSet objects:

  • void setFetchSize(int rows) throws SQLException

  • int getFetchSize() throws SQLException

To set the FetchSize for a query, call setFetchSize on the statement object before you run the query. If you set the FetchSize 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 overwrite the statement object fetch size passed to it. This affects the number of rows retrieved by the database in subsequent round trips for the original query and also affects subsequent refetching of rows.

Note

  • In Oracle mode, FetchSize of a Statement object cannot be set to a negative value. The default value is 10, which is the same as that in native Oracle.
  • In MySQL mode, FetchSize of a Statement object cannot be set to any negative value except the value of Integer.MIN_VALUE. The default value is 0, which is the same as that in native MySQL.

Preset the fetch direction

Standard JDBC drivers allow you to pre-specify the result set processing direction, also known as the fetch direction. The setting methods are as follows:

  • void setFetchDirection(int direction) throws SQLException

  • int getFetchDirection() throws SQLException

OceanBase Connector/J supports only a forward preset value, which can be specified by using the ResultSet.FETCH_FORWARD static constant. Constants such as ResultSet.FETCH_REVERSE and ResultSet.FETCH_UNKNOWN are not supported. If you attempt to use these constants, an SQL warning is returned and the setting will be ignored.

Previous topic

Limitations
Last

Next topic

refreshRow
Next
on this page
Set the fetch size
Preset the fetch direction