Skip to content

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

License

Notifications You must be signed in to change notification settings

oceanbase/obkv-table-client-java

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:

CREATE TABLE IF 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>1.2.13</version>
</dependency>

The code demo:

    // 1. initail ObTableClient
    ObTableClient obTableClient = new ObTableClient();
    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 table
    obTableClient.addRowKeyElement("test_varchar_table", new String[]{"c1"});
    
    // 2. single execute
    // return affectedRows
    obTableClient.insert("test_varchar_table", "foo", new String[] { "c2" }, new String[] { "bar" });
    // return Map<String, Object>
    obTableClient.get("test_varchar_table", "foo", new String[] { "c2" });
    // return affectedRows
    obTableClient.delete("test_varchar_table", "foo");

    // 3. batch execute
    TableBatchOps batchOps = obTableClient.batch("test_varchar_table");
    batchOps.insert("foo", new String[] { "c2" }, new String[] { "bar" });
    batchOps.get("foo", new String[] { "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.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages