ShardingKey (Java SE 12 & JDK 12 )
-
public interface ShardingKeyInterface used to indicate that this object represents a Sharding Key. A
ShardingKeyinstance is only guaranteed to be compatible with the data source instance that it was derived from. AShardingKeyis created usingShardingKeyBuilder.The following example illustrates the use of
ShardingKeyBuilderto create aShardingKey:DataSource ds = new MyDataSource(); ShardingKey shardingKey = ds.createShardingKeyBuilder() .subkey("abc", JDBCType.VARCHAR) .subkey(94002, JDBCType.INTEGER) .build();A
ShardingKeymay also be used for specifying asuperShardingKey. Databases that support composite Sharding may use asuperShardingKeyto specify a additional level of partitioning within the Shard.The following example illustrates the use of
ShardingKeyBuilderto create asuperShardingKeyfor an eastern region with aShardingKeyspecified 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
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.