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.6
  • 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
      • Example
    • Handle SQL exceptions
    • Use CallableStatements to call stored procedures
    • 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
    • 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
    • Binary Protocol (Prepared Statements)
      • COM_STMT_PREPARE_EXECUTE
      • COM_STMT_SEND_PIECE_DATA
    • 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.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.2.6

Data source characteristics and properties

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

DataSource interface
DataSource properties

By using the data source feature in combination with Java Naming and Directory Interface (JNDI), you do not need to register the JDBC driver class name specified by the vendor, and you can use logical names for URLs and other properties. This ensures that the code used to open database connections can be migrated to other environments.

DataSource interface

JDBC data sources are instances that implement the standard javax.sql.DataSource interface class, for example:

public interface DataSource
{
   Connection getConnection() throws SQLException;
   Connection getConnection(String username, String password)
      throws SQLException;
   ...
}

OceanBase Database uses the OceanBaseDataSource class in the ocanbase.jdbc.pool software package to implement this interface. The overloaded getConnection method returns a connection to the database.

To use other values, you can use the corresponding Setter method to set related properties. You can input alternate usernames and passwords to the getConnection method, which has higher priority over property settings.

DataSource properties

Same as the DataSource interface class, the OceanBaseDataSource class provides a set of properties that specify the database to connect to. These properties follow the JavaBeans design pattern.

The following table describes the standard properties in OceanBaseDataSource in accordance with the Sun Microsystems specification.

Name
Type
Description
databaseName String The name of the specified database on the server.
dataSourceName String The name of the underlying data source class. For connection pools, this is the data source class of underlying pooled connections. For distributed transactions, this is an underlying XA data source class.
description String The description of the data source.
networkProtocol String The network protocol for communication with the server.
password String The password of the logon user.
portNumber int The port number on which the server listens for requests.
serverName String The name of the database server.
user String The logon user name.

The following table describes the extended properties in OceanBaseDataSource.

Name
Type
Description
connectionCacheName String The name of the cache. The cache name cannot be changed after the cache is created.
connection­Cache­Properties java.util.Properties The properties of the implicit connection cache.
connectionCachingEnabled Boolean Specifies whether to to use the implicit connection cache.
connectionProperties java.util.Properties The properties of the connection.
driverType String The JDBC driver type.
fastConnectionFailoverEnabled Boolean Specifies whether to use fast connection failover.
implicitCachingEnabled Boolean Specifies whether to enable the implicit connection cache.
loginTimeout int The maximum amount of time (in seconds) that the data source will wait when it attempts to connect to the database.
logWriter java.io.PrintWriter The log writer for the data source.
maxStatements int The maximum number of statements in the application cache.
serviceName String The database service name of the data source.
tnsEntry String The TNS entry name. The Transparent Network Substrate (TNS) entry name corresponds to the TNS entry specified in the tnsnames.ora configuration file.
url String The URL of the database connection string. You can use this property to replace the tnsEntry and driverType properties and the standard portNumber, networkProtocol, serverName, and databaseName properties.
ONSConfiguration String The Oracle Notification Service (ONS) configuration string used for remote subscription of FAN/ONS events.

You can use the setConnectionProperties method to set the properties of the connection and use the setConnectionCacheProperties method to set the properties of the connection cache. In addition, getConnectionCacheName() returns the cache name only when the ConnectionCacheName property is set for the data source after the cache is enabled for the data source.

Previous topic

Data source overview
Last

Next topic

Create and connect to a data source instance
Next
on this page
DataSource interface
DataSource properties