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 ShardingKey.Builder
.
The following example illustrates the use of ShardingKey.Builder
to create a
ShardingKey
:
DataSource ds = new MyDataSource();
ShardingKey shardingKey = ds.createShardingKeyBuilder()
.subkey("abc", JDBCType.VARCHAR)
.subkey(94002, JDBCType.INTEGER)
.build();
A ShardingKey
is used for specifying a
JdbcConnectionProperty.SHARDING_KEY
or a
JdbcConnectionProperty.SHARDING_GROUP_KEY
. Databases that support
composite Sharding may use a * to specify a additional level of partitioning
within to specify a additional level of partitioning within the Shard.
The following example illustrates the use of ShardingKey.Builder
to create a
JdbcConnectionProperty.SHARDING_GROUP_KEY
for an eastern region with
a JdbcConnectionProperty.SHARDING_KEY
specified for the Pittsburgh
branch office:
DataSource ds = new MyDataSource();
ShardingKey superShardingKey = ds.shardingKeyBuilder()
.subkey("EASTERN_REGION", JDBCType.VARCHAR)
.build();
ShardingKey shardingKey = ds.shardingKeyBuilder()
.subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
.build();
Connection con = ds.builder()
.property(SHARDING_GROUP_KEY, superShardingKey)
.property(SHARDING_KEY, shardingKey)
.build();
Modifier and Type | Interface | Description |
---|---|---|
static interface |
ShardingKey.Builder |
A builder created from a
DataSource or object, used to create a
ShardingKey with sub-keys of supported data types. |
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, 2017, 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.
DRAFT JDBC 4.4 EA