Interface ShardingKey
public interface ShardingKey
ShardingKey
instance is only guaranteed to be compatible with the data source instance that it was derived from. A ShardingKey
is created using ShardingKeyBuilder
. The following example illustrates the use of ShardingKeyBuilder
to create a ShardingKey
:
DataSource ds = new MyDataSource();
ShardingKey shardingKey = ds.createShardingKeyBuilder()
.subkey("abc", JDBCType.VARCHAR)
.subkey(94002, JDBCType.INTEGER)
.build();
A ShardingKey
may also be used for specifying a superShardingKey
. Databases that support composite Sharding may use a superShardingKey
to specify a additional level of partitioning within the Shard.
The following example illustrates the use of ShardingKeyBuilder
to create a superShardingKey
for an eastern region with a ShardingKey
specified for the Pittsburgh branch office:
DataSource ds = new MyDataSource();
ShardingKey superShardingKey = ds.createShardingKeyBuilder()
.subkey("EASTERN_REGION", JDBCType.VARCHAR)
.build();
ShardingKey shardingKey = ds.createShardingKeyBuilder()
.subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
.build();
Connection con = ds.createConnectionBuilder()
.superShardingKey(superShardingKey)
.shardingKey(shardingKey)
.build();
- Since:
- 9
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/ShardingKey.html