strongduanmu commented on a change in pull request #13874:
URL: https://github.com/apache/shardingsphere/pull/13874#discussion_r760679644
##########
File path:
docs/document/content/user-manual/shardingsphere-jdbc/special-api/sharding/hint.cn.md
##########
@@ -125,3 +127,46 @@ try (HintManager hintManager = HintManager.getInstance();
}
}
```
+
+### 使用 Hint 路由至任意指定数据库
+
+#### 使用手动编程的方式
+
+##### 获取 HintManager
+
+与基于 Hint 的数据分片相同。
+
+##### 设置路由至任意指定数据库
+
+- 使用 `hintManager.setDataSourceName` 设置数据库名称。
+
+##### 完整代码示例
+
+```java
+String sql = "SELECT * FROM t_order";
+try (HintManager hintManager = HintManager.getInstance();
+ Connection conn = dataSource.getConnection();
+ PreparedStatement preparedStatement = conn.prepareStatement(sql)) {
+ hintManager.setDataSourceName("ds_0");
+ try (ResultSet rs = preparedStatement.executeQuery()) {
+ while (rs.next()) {
+ // ...
+ }
+ }
+}
+```
+
+#### 使用 SQL 注释的方式
+
+##### 使用规范
+- 需要开启解析注释的配置
+- 注释格式只支持 `/* */`
+- 注释开头需要包含 `ShardingSphere hint:`
Review comment:
@tuichenchuxin Can we replace ShardingSphere hint with sql hint? sql
hint seems to be easier for users to understand.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]