Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
33acc2da
提交
33acc2da
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved connection pool documentation
上级
b6ea5cc6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
25 行删除
+29
-25
tutorial.html
h2/src/docsrc/html/tutorial.html
+15
-14
JdbcConnectionPool.java
h2/src/main/org/h2/jdbcx/JdbcConnectionPool.java
+14
-11
没有找到文件。
h2/src/docsrc/html/tutorial.html
浏览文件 @
33acc2da
...
@@ -721,23 +721,24 @@ A simple connection pool is included in H2. It is based on the
...
@@ -721,23 +721,24 @@ A simple connection pool is included in H2. It is based on the
<a
href=
"http://www.source-code.biz/snippets/java/8.htm"
>
Mini Connection Pool Manager
</a>
<a
href=
"http://www.source-code.biz/snippets/java/8.htm"
>
Mini Connection Pool Manager
</a>
from Christian d'Heureuse. There are other, more complex connection pools available, for example
from Christian d'Heureuse. There are other, more complex connection pools available, for example
<a
href=
"http://jakarta.apache.org/commons/dbcp/"
>
DBCP
</a>
.
<a
href=
"http://jakarta.apache.org/commons/dbcp/"
>
DBCP
</a>
.
For H2, it is about
50 time
s faster to get a connection from the built-in connection pool than to get
For H2, it is about
twice a
s faster to get a connection from the built-in connection pool than to get
one using DriverManager.getConnection(). The build-in connection pool is used as follows:
one using DriverManager.getConnection(). The build-in connection pool is used as follows:
</p>
</p>
<pre>
<pre>
// init
import java.sql.*;
import org.h2.jdbcx.*;
import org.h2.jdbcx.JdbcConnectionPool;
...
public class Test {
JdbcConnectionPool cp = JdbcConnectionPool.create(
public static void main(String[] args) throws Exception {
"jdbc:h2:~/test", "sa", "sa");
JdbcConnectionPool cp = JdbcConnectionPool.create(
"jdbc:h2:~/test", "sa", "sa");
// use
for (int i = 0; i
<
args.length; i++) {
Connection conn = cp.getConnection();
Connection conn = cp.getConnection();
...
conn.createStatement().execute(args[i]);
conn.close();
conn.close();
}
// dispose
cp.dispose();
cp.dispose();
}
}
</pre>
</pre>
<br
/><a
name=
"fulltext"
></a>
<br
/><a
name=
"fulltext"
></a>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbcx/JdbcConnectionPool.java
浏览文件 @
33acc2da
...
@@ -42,17 +42,20 @@ import org.h2.message.Message;
...
@@ -42,17 +42,20 @@ import org.h2.message.Message;
* MiniConnectionPoolManager written by Christian d'Heureuse (Java 1.5)
* MiniConnectionPoolManager written by Christian d'Heureuse (Java 1.5)
* </a>. It is used as follows:
* </a>. It is used as follows:
* <pre>
* <pre>
* // init
* import java.sql.*;
* import org.h2.jdbcx.*;
* import org.h2.jdbcx.JdbcConnectionPool;
* ...
* public class Test {
* JdbcConnectionPool cp = JdbcConnectionPool.create(
* public static void main(String[] args) throws Exception {
* "jdbc:h2:~/test", "sa", "sa");
* JdbcConnectionPool cp = JdbcConnectionPool.create(
* // use
* "jdbc:h2:~/test", "sa", "sa");
* Connection conn = cp.getConnection();
* for (int i = 0; i < args.length; i++) {
* ...
* Connection conn = cp.getConnection();
* conn.close();
* conn.createStatement().execute(args[i]);
* // dispose
* conn.close();
* cp.dispose();
* }
* cp.dispose();
* }
* }
* </pre>
* </pre>
*
*
* @author Christian d'Heureuse
* @author Christian d'Heureuse
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论