@@ -31,37 +31,37 @@ implementation 'com.databend:databend-jdbc:0.3.7'
31
31
## 主要特性
32
32
33
33
- ✅ ** 兼容 JDBC 4.0** :支持标准 JDBC 接口
34
- - ✅ ** 连接池 (Connection Pooling) ** :内置连接管理
35
- - ✅ ** 预处理语句 (Prepared Statements) ** :高效的参数化查询
36
- - ✅ ** 批处理操作 (Batch Operations) ** :支持批量插入和更新
34
+ - ✅ ** 连接池** :内置连接管理
35
+ - ✅ ** 预处理语句** :高效的参数化查询
36
+ - ✅ ** 批量操作 ** :支持批量插入和更新
37
37
38
38
## 数据类型映射
39
39
40
- | Databend | Java | 说明 |
41
- | -------------------- | -------------- | ---------- ---------|
42
- | ** 整数** | | |
43
- | ` TINYINT ` | ` Byte ` | |
44
- | ` SMALLINT ` | ` Short ` | |
45
- | ` INT ` | ` Integer ` | |
46
- | ` BIGINT ` | ` Long ` | |
47
- | ` TINYINT UNSIGNED ` | ` Short ` | |
48
- | ` SMALLINT UNSIGNED ` | ` Integer ` | |
49
- | ` INT UNSIGNED ` | ` Long ` | |
50
- | ` BIGINT UNSIGNED ` | ` BigInteger ` | |
51
- | ** 浮点数** | | |
52
- | ` FLOAT ` | ` Float ` | |
53
- | ` DOUBLE ` | ` Double ` | |
54
- | ` DECIMAL ` | ` BigDecimal ` | 精度保留 |
55
- | ** 其他类型** | | |
56
- | ` BOOLEAN ` | ` Boolean ` | |
57
- | ` STRING ` | ` String ` | |
58
- | ` DATE ` | ` Date ` | |
59
- | ` TIMESTAMP ` | ` Timestamp ` | |
60
- | ` ARRAY(T) ` | ` String ` | JSON 编码 |
61
- | ` TUPLE(...) ` | ` String ` | JSON 编码 |
62
- | ` MAP(K,V) ` | ` String ` | JSON 编码 |
63
- | ` VARIANT ` | ` String ` | JSON 编码 |
64
- | ` BITMAP ` | ` String ` | Base64 编码 |
40
+ | Databend | Java | 备注 |
41
+ | ----------| ------| ---------|
42
+ | ** 整数** | | |
43
+ | ` TINYINT ` | ` Byte ` | |
44
+ | ` SMALLINT ` | ` Short ` | |
45
+ | ` INT ` | ` Integer ` | |
46
+ | ` BIGINT ` | ` Long ` | |
47
+ | ` TINYINT UNSIGNED ` | ` Short ` | |
48
+ | ` SMALLINT UNSIGNED ` | ` Integer ` | |
49
+ | ` INT UNSIGNED ` | ` Long ` | |
50
+ | ` BIGINT UNSIGNED ` | ` BigInteger ` | |
51
+ | ** 浮点数** | | |
52
+ | ` FLOAT ` | ` Float ` | |
53
+ | ` DOUBLE ` | ` Double ` | |
54
+ | ` DECIMAL ` | ` BigDecimal ` | 保留精度 |
55
+ | ** 其他类型** | | |
56
+ | ` BOOLEAN ` | ` Boolean ` | |
57
+ | ` STRING ` | ` String ` | |
58
+ | ` DATE ` | ` Date ` | |
59
+ | ` TIMESTAMP ` | ` Timestamp ` | |
60
+ | ` ARRAY(T) ` | ` String ` | JSON 编码 |
61
+ | ` TUPLE(...) ` | ` String ` | JSON 编码 |
62
+ | ` MAP(K,V) ` | ` String ` | JSON 编码 |
63
+ | ` VARIANT ` | ` String ` | JSON 编码 |
64
+ | ` BITMAP ` | ` String ` | Base64 编码 |
65
65
66
66
---
67
67
@@ -82,7 +82,19 @@ PreparedStatement pstmt = conn.prepareStatement("INSERT INTO users VALUES (?, ?,
82
82
pstmt. setInt(1 , 1 );
83
83
pstmt. setString(2 , " Alice" );
84
84
pstmt
. setString(
3 ,
" [email protected] " );
85
- pstmt. executeUpdate();
85
+ int result = pstmt. executeUpdate();
86
+
87
+ // 写入:使用 executeBatch 插入数据
88
+ pstmt = conn. prepareStatement(" INSERT INTO users VALUES (?, ?, ?)" );
89
+ pstmt. setInt(1 , 2 );
90
+ pstmt. setString(2 , " Bob" );
91
+ pstmt
. setString(
3 ,
" [email protected] " );
92
+ pstmt. addBatch();
93
+ pstmt. setInt(1 , 3 );
94
+ pstmt. setString(2 , " John" );
95
+ pstmt
. setString(
3 ,
" [email protected] " );
96
+ pstmt. addBatch();
97
+ int [] results = pstmt. executeBatch();
86
98
87
99
// 查询:选择数据
88
100
ResultSet rs = stmt. executeQuery(" SELECT id, name, email FROM users WHERE id = 1" );
@@ -101,16 +113,16 @@ conn.close();
101
113
102
114
## 配置参考
103
115
104
- 关于 databend-jdbc 驱动的完整配置选项 ,包括:
116
+ 关于 databend-jdbc 驱动程序的完整配置选项 ,包括:
105
117
- 连接字符串参数
106
118
- SSL/TLS 配置
107
119
- 身份验证方法
108
120
- 性能调优参数
109
121
110
- 请参考 [ 官方 databend-jdbc 连接指南] ( https://github.com/databendlabs/databend-jdbc/blob/main/docs/Connection.md ) 。
122
+ 请参阅 [ 官方 databend-jdbc 连接指南] ( https://github.com/databendlabs/databend-jdbc/blob/main/docs/Connection.md ) 。
111
123
112
- ## 相关资源
124
+ ## 资源
113
125
114
- - ** Maven Central** : [ databend-jdbc] ( https://repo1.maven.org/maven2/com/databend/databend-jdbc/ )
115
- - ** GitHub Repository ** : [ databend-jdbc] ( https://github.com/databendlabs/databend-jdbc )
116
- - ** JDBC Documentation ** : [ Oracle JDBC Guide ] ( https://docs.oracle.com/javase/tutorial/jdbc/ )
126
+ - ** Maven Central** : [ databend-jdbc] ( https://repo1.maven.org/maven2/com/databend/databend-jdbc/ )
127
+ - ** GitHub 仓库 ** : [ databend-jdbc] ( https://github.com/databendlabs/databend-jdbc )
128
+ - ** JDBC 文档 ** : [ Oracle JDBC 指南 ] ( https://docs.oracle.com/javase/tutorial/jdbc/ )
0 commit comments