OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Connector/J

V2.4.3

  • What is OceanBase Connector J?
    • Overview of OceanBase Connector/J
    • Compatibility requirements
  • Install Driver
    • Install and load the OceanBase Connector/J driver
  • Instructions
    • Quick start
      • Import packages
      • Create 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
      • Example
    • Data sources and URL
      • Data source overview
      • Database URL
    • 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 API
      • 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
    • Security features
    • Rich client
    • Network overheads
    • Show Trace
    • 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 comments
      • 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
  • Release
    • V2.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

Overview of OceanBase Connector/J Compatibility requirements Install and load the OceanBase Connector/J driver Import packages Create 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 Example Data source overviewDatabase URL Overview of Java data streams LONG and LONG RAW data types CHAR, VARCHAR, and RAW data types Overview of statement caching Use statement caching Reuse statement objects Call a stored procedure Handle SQL exceptions Overview of result sets Limitations FetchSize refreshRow useCursorFetch Batch processing Failover and load balancing modes LoadBalance strategies Load balancing strategy configuration methods Security features Rich client Network overheads Show Trace Troubleshooting Call PL stored procedures Scrollability of a result set Use ARRAY and STRUCT classes Obtain comments Data types supported in Oracle mode Error messages in Oracle mode Supported SQL and PL data types 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 OceanBase Connector/J V2.4.3 OceanBase Connector/J V2.4.2 OceanBase Connector/J V2.4.1 OceanBase Connector/J V2.4.0 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
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Connector/J
  3. V2.4.3
iconOceanBase Connector/J
V 2.4.3
  • V 2.4.17
  • V 2.4.16
  • V 2.4.15
  • V 2.4.14
  • V 2.4.5
  • V 2.4.4
  • V 2.4.3
  • V 2.4.2
  • V 2.4.1
  • V 2.4.0
  • V 2.2.11
  • V 2.2.10
  • V 2.2.7
  • V 2.2.6
  • V 2.2.3
  • V 2.2.0

javax.naming.Context

Last Updated:2026-04-09 07:21:44  Updated
share
What is on this page
Description
Field
Exceptions
Concurrent access
Parameters
Environment properties
Resource files
Provider resource files
Application resource files
Search algorithm for properties
Methods

folded

share

javax.naming.Context is a context interface for connection configuration.

Description

javax.naming.Context consists of a set of name-to-object bindings, and contains methods for examining and updating these bindings.

Field

Each name passed as a parameter to the Context method is related to the context. An empty name is used to name the context itself. A name parameter cannot be null.

Most of the methods have overloaded versions, for example, a method that uses a Name parameter and a method that uses a String. These overloaded versions are equivalent. If the Name and String parameters are just different representations of the same name, the overloaded versions of the same methods exhibit same behaviors.

Exceptions

All methods in this interface can throw a NamingException or any exceptions of the subclasses of NamingException.

Concurrent access

It cannot be guaranteed that a Context is synchronous with concurrent access of multiple threads. For threads that need to access a single Context instance concurrently, synchronization must be implemented between these threads and necessary locking needs to be provided. Synchronization is not required among multiple threads that each operate on a different Context instance. Note that when an empty name is passed, the lookup method will return a new Context instance that represents the same naming context.

To achieve concurrency control, a Context operation that returns NamingEnumeration is considered uncompleted if the enumeration is still in use or any referrals generated by the operation are still in use.

Parameters

The service provider will not modify the Name parameter passed to a method of the Context interface or a method of its subinterfaces. The service provider may keep a reference to the Name parameter during operations, for example, during the enumeration of the method results and the processing of any referrals generated. The caller must not modify the object defined by the Name parameter during this period. A Name returned by any such method is owned by the caller. The name may be subsequently modified by the caller, but not by the service provider.``

Environment properties

Java Naming and Directory Interface (JNDI) applications require methods for transferring various preferences and attributes. These preferences and attributes define an environment for accessing naming and directory services. For example, security credentials may need to be specified for a context for accessing services. In another method, an environment of a context is used to provide server configuration information. The Context interface provides methods for retrieving and updating this environment.

The environment is inherited from the parent context when a context method proceeds from one context to the next. Changes to the environment of one context do not directly affect those of other contexts.

The use and validity verification of environment properties depend on the implementation. For example, the service provider uses some security-related properties to "log on" to the directory. This logon process may occur when the context is created or when the first time a method is invoked on the context. When and whether this occurs depends on the implementation. When environment properties are added to or removed from a context, verification of the validity of the changes also depends on the implementation. For example, verification of some properties may occur when a change is made or when the next operation is performed on the context, or property verification will not be performed

Any object with a reference to a context may examine the environment of the context. Do not store sensitive information such as plain-text passwords in a context unless protection measures are unavailable.

Resource files

To simplify the process for setting up the environment required by a JNDI application, the application components and service providers may be distributed along with resource files. A JNDI resource file is a file in the properties file format and contains a list of key/value pairs. A key is the name of a property, and a value is a string in the format defined for the property.

The JNDI class library reads the resource files and makes the property values available. There are two kinds of JNDI resource files: provider resource files and application resource files.

Provider resource files

Each service provider has an optional resource that lists properties specific to this provider. The name of this resource is in the following format:

[prefix/]jndiprovider.properties

prefix is the package name of the context implementation of the provider, with each period (".") converted to a slash ("/").

The following methods in the JNDI class library use the standard JNDI properties that specify lists of JNDI factories:

  • java.naming.factory.object

  • java.naming.factory.state

  • java.naming.factory.control

  • java.naming.factory.url.pkgs

When the JNDI library determines the values of these properties, it will refer to the provider resource file. The documentation of the service provider must clearly state the properties allowed. Then, other properties in the file will be ignored.

Application resource files

When an application is deployed, the classpath of the application usually contains multiple codebase directories and JAR packages. JNDI locates all application resource files named jndi.properties in the classpath by using ClassLoader.getResources(). In addition, if the Java installation directory contains a built-in property file, for example, conf/jndi.properties, JNDI treats it as an additional application resource file. All of the properties contained in these files are placed into the environment of the initial context. This environment may be then inherited by other contexts.

For a property that can be found in more than one application resource file, JNDI uses the first value found, or concatenates all of the values in some cases. For example, if the "java.naming.factory.object" property is found in three jndi.properties resource files, the list of object factories is a concatenation of the property values from all these three files. JNDI automatically collects and uses all of these export lists when it searches for factory classes.

Search algorithm for properties

When JNDI constructs an initial context, the environment of the context is initialized by using properties defined in the environment parameter that is passed to the constructor and using the system properties and the application resource files. This initial environment can be subsequently inherited by other context instances.

When the JNDI class library needs to determine the value of a property, it merges the values from the following two sources in order:

  1. The environment of the context being operated on.

  2. The provider resource file (jndiprovider.properties) for the context being operated on.

For a property found in both of these two sources, JNDI determines the property value in the following manner:

  • If the property is one of the standard JNDI properties that specify a list of JNDI factories, the values are concatenated into a single colon-separated list.

  • Otherwise, only the first value found is used.

When a service provider needs to determine the value of a property, it will generally obtain the value directly from the environment. A service provider may define provider-specific properties and place them in its own provider resource file. In that case, it should merge values. In this way, the developer of each service provider can specify a list of factories that the service provider can use. The list of factories can be modified by the application resources specified by the deployer of the application, and the resources in turn can be modified by the user.

Methods

Method Return type Whether JDBC 4 is supported in Oracle mode Whether JDBC 4 is supported in MySQL mode
lookup(Name name) Object No No
lookup(String name) Object No No
bind(Name name,Object obj) void No No
bind(String name,Object obj) void No No
rebind(Name name,Object obj) void No No
rebind(String name,Object obj) void No No
unbind(Name name) void No No
unbind(String name) void No No
rename(Name oldName,Name newName) void No No
rename(String oldName,String newName) void No No
list(Name name) NamingEnumeration<NameClassPair> No No
list(String name) NamingEnumeration<NameClassPair> No No
listBindings(Name name) NamingEnumeration<Binding> No No
listBindings(String name) NamingEnumeration<Binding> No No
destroySubcontext(Name name) void No No
destroySubcontext(String name) void No No
createSubcontext(Name name) Context No No
createSubcontext(String name) Context No No
lookupLink(Name name) Object No No
lookupLink(String name) Object No No
getNameParser(Name name) NameParser No No
getNameParser(String name) NameParser No No
composeName(Name name) Name No No
composeName(String name) Name No No
addToEnvironment(String propName,Object propVal) Object No No
removeFromEnvironment(String propName) Object No No
getEnvironment() Hashtable No No
close() void No No
getNameInNamespace() String No No

Previous topic

javax.sql.ConnectionPoolDataSource
Last

Next topic

javax.sql.PooledConnection
Next
What is on this page
Description
Field
Exceptions
Concurrent access
Parameters
Environment properties
Resource files
Provider resource files
Application resource files
Search algorithm for properties
Methods