mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 03:57:35 +08:00
[Docs] Support SDK integration documentation
This commit is contained in:
parent
14d649540b
commit
05f633bbe0
61
docs/docs/developer/sdk/home.md
Normal file
61
docs/docs/developer/sdk/home.md
Normal file
@ -0,0 +1,61 @@
|
||||
---
|
||||
title: SDK 集成
|
||||
icon: material/desk
|
||||
---
|
||||
|
||||
本文章主要用来介绍如何集成 datacap 提供的 plugin 插件快速访问对应数据源。在本文中我们使用 `datacap-jdbc-mysql` SDK 来访问 MySQL 数据源。
|
||||
|
||||
### 准备工作
|
||||
|
||||
---
|
||||
|
||||
引入插件依赖
|
||||
|
||||
- Apache Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-jdbc-mysql</artifactId>
|
||||
<version>VERSION</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- Gradle
|
||||
|
||||
```xml
|
||||
implementation group: 'io.edurt.datacap', name: 'datacap-jdbc-mysql', version: 'VERSION'
|
||||
```
|
||||
|
||||
!!! danger
|
||||
|
||||
请将 `VERSION` 替换为对应的版本号
|
||||
|
||||
### 使用插件
|
||||
|
||||
---
|
||||
|
||||
```java
|
||||
String sql = "SHOW TABLES";
|
||||
|
||||
// 构建连接配置
|
||||
Configure configure = new Configure();
|
||||
configure.setHost("localhost");
|
||||
configure.setPort(3306);
|
||||
configure.setUsername(Optional.of("root"));
|
||||
configure.setPassword(Optional.of("12345678"));
|
||||
|
||||
// 初始化 MySQL 插件
|
||||
MySQLPlugin plugin = new MySQLPlugin();
|
||||
plugin.connect(configure);
|
||||
|
||||
// 获取执行结果
|
||||
Response response = plugin.execute(sql);
|
||||
response.columns.forEach(item -> {
|
||||
log.info(item);
|
||||
});
|
||||
```
|
||||
|
||||
!!! note
|
||||
|
||||
请注意 `datacap-jdbc-mysql` 插件仅支持 MySQL 数据源,如果需要其他 SDK 请使用其他的插件。
|
@ -215,6 +215,7 @@ nav:
|
||||
- developer/server/home.md
|
||||
- developer/web/home.md
|
||||
- developer/doc/home.md
|
||||
- developer/sdk/home.md
|
||||
- NavDeveloperPlugin:
|
||||
- developer/plugin/java/home.md
|
||||
- developer/plugin/kotlin/home.md
|
||||
|
Loading…
Reference in New Issue
Block a user