The OBKV-Table Java client provides rich APIs for accessing OceanBase Cloud. This topic describes how to initialize the OBKV-Table Java client and connect to an instance.
Before you use the OBKV-Table client to connect to an OBKV-Table instance for data processing, make sure that you have completed the required preparations.
Install the OBKV-Table Java SDK
To use the OBKV-Table Java SDK in a Maven project, add the corresponding dependency to your pom.xml file. Add the following to the dependencies section:
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>obkv-table-client</artifactId>
<version>1.2.12</version>
</dependency>
Note the following:
- The OBKV-Table Java SDK requires JDK 1.8 or later.
- Use the latest JAR version when possible. Older JAR versions may not support newer server versions.
- The version number shown here may not be the latest. Check the published OBKV-Table versions in the central repository and replace the version number with the latest release.
Configure the connection string
## Assume the current cluster is configured as follows:
## DatabaseName: test
## UserName: root
#### Required settings
Configuration conf = new Configuration();
## Database username (not the three-part format; use username only)
conf.set(HBASE_OCEANBASE_FULL_USER_NAME, "root");
## User password
conf.set(HBASE_OCEANBASE_PASSWORD, "");
## See the ODP address note below
conf.set(HBASE_OCEANBASE_ODP_ADDR, "");
## The OBKV port is 3307 (fixed)
conf.setInt(HBASE_OCEANBASE_ODP_PORT, "3307");
## Use ODP mode on OceanBase Cloud (fixed)
conf.setBoolean(HBASE_OCEANBASE_ODP_MODE, true);
## Database name
conf.set(HBASE_OCEANBASE_DATABASE, "test");
#### Optional settings
## Request execution timeout (configure based on your workload)
conf.set("rpc.execute.timeout", "1000");
You can obtain the ODP address from the OceanBase Cloud tenant overview page by viewing the deployment topology diagram.
What to do next
- For all operation types supported by OBKV-Table, see Insert data.
- For client data operation examples, see Data operation examples.
- You can view OBKV-Table client connection configuration in the following views: GV$OB_KV_CLIENT_INFO V$OB_KV_CLIENT_INFO
