|
18 | 18 | * [http://java-source.net/open-source/sql-clients](http://java-source.net/open-source/sql-clients) |
19 | 19 | * JPA标准API [https://github.com/Blazebit/blaze-persistence](https://github.com/Blazebit/blaze-persistence) |
20 | 20 | * 链式SQL框架 [https://github.com/jOOQ](https://github.com/jOOQ) |
| 21 | +* [https://github.com/jenetics/facilejdbc](https://github.com/jenetics/facilejdbc) |
| 22 | +* [https://github.com/eclipse-vertx/vertx-sql-client](https://github.com/eclipse-vertx/vertx-sql-client) |
21 | 23 | * [https://github.com/querydsl/querydsl](https://github.com/querydsl/querydsl) |
22 | 24 | * [https://github.com/BatooOrg/BatooJPA](https://github.com/BatooOrg/BatooJPA) |
23 | 25 | * [https://github.com/aaberg/sql2o](https://github.com/aaberg/sql2o) |
|
79 | 81 |
|
80 | 82 |
|
81 | 83 |
|
| 84 | +## JDBC驱动 |
| 85 | + |
| 86 | +- [https://github.com/pgjdbc/pgjdbc](https://github.com/pgjdbc/pgjdbc) |
| 87 | +- [https://github.com/xerial/sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) |
| 88 | +- [https://github.com/arthurblake/log4jdbc](https://github.com/arthurblake/log4jdbc) |
| 89 | + |
| 90 | + |
| 91 | +**注意使用的MySQL Connector/J驱动** |
| 92 | + |
| 93 | +- `org.gjt.mm.mysql.Driver` 用于`3.x`版本之前,在`5.1.47`以上版本不存在该类,由一个名为MM (Monty's MySQL) 的项目开发的,该项目后来被Sun Microsystems收购 |
| 94 | +- `com.mysql.jdbc.Driver` 用于`5.1.6`版本之前,在MySQL AB(后被Oracle Corporation收购)接手并继续开发JDBC驱动之后使用的 |
| 95 | +- `com.mysql.cj.jdbc.Driver` 用于`5.1.6`版本之后 |
| 96 | + |
| 97 | +> 从Java 6 `JDBC 4.0`开始,显式加载驱动类的步骤`Class.forName(…)`通常是不必要的,因为JDBC服务提供者机制会自动加载驱动 |
| 98 | +
|
| 99 | + |
| 100 | + |
| 101 | +**URL及参数** |
| 102 | + |
| 103 | +* [(https://mysql-net.github.io/MySqlConnector/connection-options]((https://mysql-net.github.io/MySqlConnector/connection-options) |
| 104 | + * [https://mysqlconnector.net/connection-options](https://mysqlconnector.net/connection-options) |
| 105 | + |
| 106 | +> `jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false` |
| 107 | +> `&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai` |
| 108 | +
|
| 109 | +| 参数名称 | 参数说明 | 缺省值 | 最低版本要求 | |
| 110 | +|----------------------- |--------------------------------------------------------------------------------- |-------- |-------------- | |
| 111 | +| user | 数据库用户名(用于连接数据库) | | 所有版本 | |
| 112 | +| password | 用户密码(用于连接数据库) | | 所有版本 | |
| 113 | +| useUnicode | 是否使用Unicode字符集,使用参数characterEncoding,本参数值必须设置为true | FALSE | 1.1g | |
| 114 | +| characterEncoding | 当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk、UTF-8 | FALSE | 1.1g | |
| 115 | +| autoReconnect | 当数据库连接异常中断时,是否自动重新连接? | FALSE | 1.1 | |
| 116 | +| autoReconnectForPools | 是否使用针对数据库连接池的重连策略 | FALSE | 3.1.3 | |
| 117 | +| failOverReadOnly | 自动重连成功后,连接是否设置为只读? | TRUE | 3.0.12 | |
| 118 | +| maxReconnects | autoReconnect设置为true时,重试连接的次数 | 3 | 1.1 | |
| 119 | +| initialTimeout | autoReconnect设置为true时,两次重连之间的时间间隔,单位:秒 | 2 | 1.1 | |
| 120 | +| connectTimeout | 和数据库服务器建立socket连接时的超时,单位:毫秒 | 0 | 3.0.1 | |
| 121 | +| socketTimeout | socket操作(读写)超时,单位:毫秒。 0表示永不超时 | 0 | 3.0.1 | |
| 122 | +| useSSL | 是否进行ssl连接 | | | |
| 123 | +| zeroDateTimeBehavior | 把零值日期转换为`null` | | | |
| 124 | +| serverTimezone | `GMT%2B8` `%2B`是`+`的转义字符,其实就是`GMT+8`('+8:00'),代表东八区`Asia/Shanghai` | | | |
| 125 | + |
| 126 | +- `useTimeZone` 为true时,会开启服务器和客户端之间的时区转换,只有`useLegacyDatetimeCode = true`时才回生效 |
| 127 | +- `useLegacyDatetimeCode` 默认为true,为false时: `useTimezone`, `useJDBCCompliantTimezoneShift`, `useGmtMillisForDatetimes`, `useFastDateParsing` 这几个参数都会无效 |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | +## 连接池 |
| 133 | + |
| 134 | +> 其主要目的是减少执行数据库连接和读写作的开销。在最基本的层面,连接池是一种数据库连接缓存实现 |
| 135 | +
|
| 136 | + |
| 137 | +**为什么要连接池?** |
| 138 | + |
| 139 | +> 如果我们分析典型数据库连接生命周期中涉及的步骤顺序,就能明白原因: |
| 140 | +1. 使用数据库驱动打开数据库连接 |
| 141 | +2. 打开 TCP 套接字以读写数据 |
| 142 | +3. 通过套接字读取/写入数据 |
| 143 | +4. 关闭连接 |
| 144 | +5. 关闭套接字 |
| 145 | +> 显而易见,**数据库连接(创建套接字连接)是相当昂贵的操作**,因此在所有可能的使用场景中都应尽量减少(在极端情况下,最好避免)。 |
| 146 | +> |
| 147 | +> 连接池仅仅实现一个数据库连接容器,允许我们重用多个现有连接,就能有效节省大量昂贵数据库访问的成本。这提升了我们数据库驱动应用的整体性能。 |
82 | 148 |
|
83 | | -**连接池** |
84 | 149 |
|
85 | 150 | + [https://github.com/topics/connection-pool](https://github.com/topics/connection-pool) |
86 | 151 |
|
87 | 152 |
|
88 | | -- [https://github.com/brettwooldridge/HikariCP](https://github.com/brettwooldridge/HikariCP) |
| 153 | +- [https://github.com/brettwooldridge/HikariCP](https://github.com/brettwooldridge/HikariCP) |
89 | 154 | - [https://github.com/alibaba/druid](https://github.com/alibaba/druid) |
90 | 155 | - [https://alphahinex.github.io/2022/05/15/use-druid-to-transform-sql](https://alphahinex.github.io/2022/05/15/use-druid-to-transform-sql) |
91 | 156 | - [记一次 Druid 超时配置的问题 → 引发对 Druid 时间配置项的探究](https://www.cnblogs.com/youzhibing/p/16458860.html) |
|
96 | 161 | - [https://github.com/apache/commons-dbcp](https://github.com/apache/commons-dbcp) |
97 | 162 | - [https://github.com/apache/commons-pool](https://github.com/apache/commons-pool) |
98 | 163 | - [https://github.com/agroal/agroal](https://github.com/agroal/agroal) |
99 | | -- [https://github.com/vibur](https://github.com/vibur) |
100 | 164 | - [https://github.com/Chris2018998/BeeCP](https://github.com/Chris2018998/BeeCP) |
101 | | -- [https://sourceforge.net/projects/proxool](https://sourceforge.net/projects/proxool) |
| 165 | +- [https://github.com/vibur/vibur-dbcp](https://github.com/vibur/vibur-dbcp) |
| 166 | +- [https://github.com/proxool/proxool](https://github.com/proxool/proxool) |
| 167 | + - [https://sourceforge.net/projects/proxool](https://sourceforge.net/projects/proxool) |
102 | 168 | - [https://github.com/swaldman/c3p0](https://github.com/swaldman/c3p0) |
103 | 169 | - [https://sourceforge.net/projects/c3p0](https://sourceforge.net/projects/c3p0) |
| 170 | + - [https://github.com/metabase/connection-pool](https://github.com/metabase/connection-pool) |
| 171 | +- [https://github.com/jakubBone/Connection-Pool-Library](https://github.com/jakubBone/Connection-Pool-Library) |
104 | 172 | - [https://github.com/wwadge/bonecp](https://github.com/wwadge/bonecp) |
| 173 | +- [https://github.com/davidmoten/rxjava2-jdbc](https://github.com/davidmoten/rxjava2-jdbc) |
| 174 | +- [https://github.com/CarmJos/EasySQL](https://github.com/CarmJos/EasySQL) |
| 175 | +- [https://sourceforge.net/projects/smartpool](https://sourceforge.net/projects/smartpool) |
| 176 | +- [https://github.com/chdh/miniconnectionpoolmanager](https://github.com/chdh/miniconnectionpoolmanager) |
105 | 177 |
|
106 | 178 |
|
107 | 179 | * [https://github.com/vladmihalcea/flexy-pool](https://github.com/vladmihalcea/flexy-pool) |
108 | 180 |
|
109 | 181 |
|
110 | 182 |
|
111 | | -**Transaction** |
| 183 | + |
| 184 | +## 事务管理 |
112 | 185 |
|
113 | 186 | * [https://github.com/atomikos/transactions-essentials](https://github.com/atomikos/transactions-essentials) |
114 | 187 | * [Atomikos开源版本的事务管理器实现TransactionEssentials](https://blog.csdn.net/dengjili/article/details/88203047) |
|
127 | 200 | - X/Open [https://publications.opengroup.org/s243](https://publications.opengroup.org/s243) |
128 | 201 |
|
129 | 202 |
|
130 | | -## JDBC驱动 |
131 | | - |
132 | | - |
133 | | -**注意使用的MySQL Connector/J驱动** |
134 | | - |
135 | | -- `org.gjt.mm.mysql.Driver` 用于`3.x`版本之前,在`5.1.47`以上版本不存在该类,由一个名为MM (Monty's MySQL) 的项目开发的,该项目后来被Sun Microsystems收购 |
136 | | -- `com.mysql.jdbc.Driver` 用于`5.1.6`版本之前,在MySQL AB(后被Oracle Corporation收购)接手并继续开发JDBC驱动之后使用的 |
137 | | -- `com.mysql.cj.jdbc.Driver` 用于`5.1.6`版本之后 |
138 | | - |
139 | | -> 从Java 6 `JDBC 4.0`开始,显式加载驱动类的步骤`Class.forName(…)`通常是不必要的,因为JDBC服务提供者机制会自动加载驱动 |
140 | | -
|
141 | | - |
142 | | - |
143 | | -**URL及参数** |
144 | | - |
145 | | -* [(https://mysql-net.github.io/MySqlConnector/connection-options]((https://mysql-net.github.io/MySqlConnector/connection-options) |
146 | | - * [https://mysqlconnector.net/connection-options](https://mysqlconnector.net/connection-options) |
147 | | - |
148 | | -> `jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false` |
149 | | -> `&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai` |
150 | | -
|
151 | | -| 参数名称 | 参数说明 | 缺省值 | 最低版本要求 | |
152 | | -|----------------------- |--------------------------------------------------------------------------------- |-------- |-------------- | |
153 | | -| user | 数据库用户名(用于连接数据库) | | 所有版本 | |
154 | | -| password | 用户密码(用于连接数据库) | | 所有版本 | |
155 | | -| useUnicode | 是否使用Unicode字符集,使用参数characterEncoding,本参数值必须设置为true | FALSE | 1.1g | |
156 | | -| characterEncoding | 当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk、UTF-8 | FALSE | 1.1g | |
157 | | -| autoReconnect | 当数据库连接异常中断时,是否自动重新连接? | FALSE | 1.1 | |
158 | | -| autoReconnectForPools | 是否使用针对数据库连接池的重连策略 | FALSE | 3.1.3 | |
159 | | -| failOverReadOnly | 自动重连成功后,连接是否设置为只读? | TRUE | 3.0.12 | |
160 | | -| maxReconnects | autoReconnect设置为true时,重试连接的次数 | 3 | 1.1 | |
161 | | -| initialTimeout | autoReconnect设置为true时,两次重连之间的时间间隔,单位:秒 | 2 | 1.1 | |
162 | | -| connectTimeout | 和数据库服务器建立socket连接时的超时,单位:毫秒 | 0 | 3.0.1 | |
163 | | -| socketTimeout | socket操作(读写)超时,单位:毫秒。 0表示永不超时 | 0 | 3.0.1 | |
164 | | -| useSSL | 是否进行ssl连接 | | | |
165 | | -| zeroDateTimeBehavior | 把零值日期转换为`null` | | | |
166 | | -| serverTimezone | `GMT%2B8` `%2B`是`+`的转义字符,其实就是`GMT+8`('+8:00'),代表东八区`Asia/Shanghai` | | | |
167 | | - |
168 | | -- `useTimeZone` 为true时,会开启服务器和客户端之间的时区转换,只有`useLegacyDatetimeCode = true`时才回生效 |
169 | | -- `useLegacyDatetimeCode` 默认为true,为false时: `useTimezone`, `useJDBCCompliantTimezoneShift`, `useGmtMillisForDatetimes`, `useFastDateParsing` 这几个参数都会无效 |
170 | | - |
171 | | - |
172 | 203 |
|
173 | 204 |
|
174 | 205 | ## Mybatis |
|
0 commit comments