forked from apache/shardingsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: (90 commits) Remove usage of com.google.common.collect.Collections2 (apache#17721) Refactor execute RAL statement reload metaData (apache#17720) Use caffeine instead of guava cache (apache#17712) Minor changes for test cases and code format (apache#17718) Add test case for RuleBasedSchemaMetaDataBuilderFactory . (apache#17709) Update Mockito and ByteBuddy to help with GraalVM integration (apache#17665) fix CI error (apache#17713) Add unit for MetaDataPersistService.persistTransactionRule(final Properties props, final boolean isOverwrit) apache#16091 (apache#17714) Remove useless DatabaseMetaDataContextsBuilder (apache#17717) private MetaDataContextsBuilder.addDatabase and addSystemDatabases (apache#17716) Add unit test for ModShardingAlgorithm (apache#17710) Refactor distribute database lock (apache#17711) Add unit test for Bootstrap use proxy default port from props (apache#17707) Scaling IT optimization (apache#17702) Add test cases for SQLRewriteContextDecoratorFactory and ExecutionPrepareDecoratorFactory . (apache#17701) Use ConfigurationProperties in ContextManager (apache#17706) Use ConfigurationProperties in MetaDataContextsBuilder (apache#17705) Refactor create schema statement parse logic (apache#17703) Revise apache#17695 (apache#17700) add test for DataNodeBuilderFactory (apache#17695) ...
- Loading branch information
Showing
567 changed files
with
7,659 additions
and
4,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
docs/document/content/quick-start/shardingsphere-scaling-quick-start.cn.md
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
docs/document/content/quick-start/shardingsphere-scaling-quick-start.en.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...document/content/user-manual/shardingsphere-jdbc/builtin-algorithm/_index.cn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
+++ | ||
title = "内置算法" | ||
weight = 6 | ||
weight = 7 | ||
chapter = true | ||
+++ | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...document/content/user-manual/shardingsphere-jdbc/builtin-algorithm/_index.en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
+++ | ||
title = "Builtin Algorithm" | ||
weight = 6 | ||
weight = 7 | ||
chapter = true | ||
+++ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
docs/document/content/user-manual/shardingsphere-jdbc/jdbc-driver/_index.cn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
+++ | ||
title = "JDBC 驱动" | ||
weight = 3 | ||
chapter = true | ||
+++ | ||
|
||
## 简介 | ||
|
||
ShardingSphere-JDBC 提供了 JDBC 驱动,可以仅通过配置变更即可使用,无需改写代码。 | ||
|
||
## 使用步骤 | ||
|
||
### 引入 Maven 依赖 | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.apache.shardingsphere</groupId> | ||
<artifactId>shardingsphere-jdbc-core</artifactId> | ||
<version>${shardingsphere.version}</version> | ||
</dependency> | ||
``` | ||
|
||
### 使用驱动 | ||
|
||
#### 使用原生驱动 | ||
|
||
```java | ||
Class.forName("org.apache.shardingsphere.driver.ShardingSphereDriver"); // 或者使用标准 SPI 注册数据库驱动 | ||
String jdbcUrl = "jdbc:shardingsphere:classpath:config.yaml"; | ||
|
||
String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.user_id=? AND o.order_id=?"; | ||
try ( | ||
Connection conn = DriverManager.getConnection(jdbcUrl); | ||
PreparedStatement ps = conn.prepareStatement(sql)) { | ||
ps.setInt(1, 10); | ||
ps.setInt(2, 1000); | ||
try (ResultSet rs = preparedStatement.executeQuery()) { | ||
while(rs.next()) { | ||
// ... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### 使用数据库连接池 | ||
|
||
```java | ||
String driverClassName = "org.apache.shardingsphere.driver.ShardingSphereDriver"; | ||
String jdbcUrl = "jdbc:shardingsphere:classpath:config.yaml"; | ||
|
||
// 以 HikariCP 为例 | ||
HikariDataSource dataSource = new HikariDataSource(); | ||
dataSource.setDriverClassName(driverClassName); | ||
dataSource.setJdbcUrl(jdbcUrl); | ||
|
||
String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.user_id=? AND o.order_id=?"; | ||
try ( | ||
Connection conn = dataSource.getConnection(); | ||
PreparedStatement ps = conn.prepareStatement(sql)) { | ||
ps.setInt(1, 10); | ||
ps.setInt(2, 1000); | ||
try (ResultSet rs = preparedStatement.executeQuery()) { | ||
while(rs.next()) { | ||
// ... | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### 配置说明 | ||
|
||
#### 驱动类名称 | ||
|
||
`org.apache.shardingsphere.driver.ShardingSphereDriver` | ||
|
||
#### URL 配置说明 | ||
|
||
- 以 `jdbc:shardingsphere:` 为前缀 | ||
- 配置文件:`xxx.yaml`,配置文件格式与 [YAML 配置](/cn/user-manual/yaml-config/)一致 | ||
- 配置文件加载规则: | ||
- 无前缀表示从绝对路径加载配置文件 | ||
- `classpath:` 前缀表示从类路径中加载配置文件 |
Oops, something went wrong.