Skip to content

Repository files navigation

OBKV Table Client

OBKV Table Client is Java Library that can be used to access table data from OceanBase storage layer. Its access method is different from JDBC, it skips the SQL parsing layer, so it has significant performance advantage.

Quick Start

Create table in the OceanBase database:

CREATETABLEIF NOT EXISTS `test_varchar_table` (
`c1`varchar(20) NOT NULL,
`c2`varchar(20) DEFAULT NULL,
PRIMARY KEY (`c1`)
) PARTITION BY KEY(`c1`) PARTITIONS 10;

Import the dependency for your maven project:

<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>obkv-table-client</artifactId>
<version>2.3.0</version>
</dependency>

The code demo:

// 1. initail ObTableClientObTableClientobTableClient = newObTableClient();
obTableClient.setFullUserName("full_user_name");
obTableClient.setParamURL("param_url");
obTableClient.setPassword("password");
obTableClient.setSysUserName("sys_user_name");
obTableClient.setSysPassword("sys_user_passwd");
obTableClient.init();
// set primary key for partition tableobTableClient.addRowKeyElement("test_varchar_table", newString[]{"c1"});
// 2. single execute// return affectedRowsobTableClient.insert("test_varchar_table", "foo", newString[] { "c2" }, newString[] { "bar" });
// return Map<String, Object>obTableClient.get("test_varchar_table", "foo", newString[] { "c2" });
// return affectedRowsobTableClient.delete("test_varchar_table", "foo");
// 3. batch executeTableBatchOpsbatchOps = obTableClient.batch("test_varchar_table");
batchOps.insert("foo", newString[] { "c2" }, newString[] { "bar" });
batchOps.get("foo", newString[] { "c2" });
batchOps.delete("foo");
List<Object> results = batchOps.execute();
// the results include 3 item: 1. affectedRows; 2. Map; 3. affectedRows.

NOTE:

  1. param_url is generated by ConfigServer.
  2. More example Demo
  3. full_user_name: the user for accessing obkv, which format is user_name@tenant_name#cluster_name
  4. sys_user_name: root@sys or proxy@sys, which have privileges to access routing system view

Release Notes

Latest release notes could be found in Release notes

Documentation

Licencing

OBKV Table Client is under MulanPSL - 2.0 licence. You can freely copy and use the source code. When you modify or distribute the source code, please obey the MulanPSL - 2.0 licence.

Contributing

Contributions are warmly welcomed and greatly appreciated. Here are a few ways you can contribute:

Support

In case you have any problems when using OceanBase Database, welcome reach out for help:

About

OBKV Table Client is Java Library that can be used to access table data from OceanBase storage layer.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

32 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages