Skip to content

Commit 25a88ac

Browse files
Update common-Extractor.md
1 parent eeeb828 commit 25a88ac

File tree

2 files changed

+38
-27
lines changed

2 files changed

+38
-27
lines changed

docs/lab/smt/common-Extractor.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
toc: content
3+
nav:
4+
path: /lab/smt
5+
---
6+
7+
# common - Extractor
8+
9+
- `Extractor` 迭代`ResultSet`并封装为样例类的集合。
10+
- 默认提供22个`GenericRowN`实例,即支持22个列的select,允许拓展。
11+
- 支持自定义类型映射函数。
12+
13+
## 使用
14+
```scala
15+
16+
val statement = DriverManager
17+
.getConnection(
18+
"jdbc:h2:mem:zim?caseSensitive=false;MODE=MYSQL;TRACE_LEVEL_FILE=2;INIT=RUNSCRIPT FROM 'classpath:test.sql'"
19+
)
20+
.createStatement()
21+
statement.execute(s"""select * from T_USER""".stripMargin)
22+
23+
val rowSet: ResultSet = statement.getResultSet
24+
25+
// default type mapping
26+
val rows = Extractor[GenericRow4[Int, String, String, String]].from(rowSet)
27+
// 再也不用到处写 `while(rowSet.next) { }` 了
28+
```
29+
30+
## 优化
31+
```scala
32+
import org.bitlap.common.jdbc._
33+
34+
implicit lazy val conn = DriverManager.getConnection(
35+
"jdbc:h2:mem:zim?caseSensitive=false;MODE=MYSQL;TRACE_LEVEL_FILE=2;INIT=RUNSCRIPT FROM 'classpath:test.sql'"
36+
)
37+
val ret1 = Extractor[GenericRow4[Int, String, String, String]].from(sql"select * from T_USER")
38+
```

docs/lab/smt/common-ResultSetTransformer.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)