Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7f2e888b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7f2e888b
编写于
7月 05, 2021
作者:
Z
Zhiyu Yang
提交者:
GitHub
7月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-4939]<test>: add a Proxool Connection Pool Demo (#6657)
* [TD-4939]<test>: add a Proxool Connection Pool Demo * change
上级
c4f96ffc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
123 addition
and
13 deletion
+123
-13
tests/examples/JDBC/connectionPools/pom.xml
tests/examples/JDBC/connectionPools/pom.xml
+40
-13
tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ProxoolDemo.java
...Pools/src/main/java/com/taosdata/example/ProxoolDemo.java
+56
-0
tests/examples/JDBC/connectionPools/src/main/resources/proxool.xml
...mples/JDBC/connectionPools/src/main/resources/proxool.xml
+27
-0
未找到文件。
tests/examples/JDBC/connectionPools/pom.xml
浏览文件 @
7f2e888b
...
...
@@ -9,12 +9,12 @@
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<!-- taos -->
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.18
</version>
</dependency>
<!-- druid -->
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
@@ -50,6 +50,12 @@
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
</dependency>
<!-- proxool -->
<dependency>
<groupId>
com.cloudhopper.proxool
</groupId>
<artifactId>
proxool
</artifactId>
<version>
0.9.1
</version>
</dependency>
</dependencies>
<build>
...
...
@@ -57,25 +63,46 @@
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
3.1.0
</version>
<configuration>
<archive>
<manifest>
<mainClass>
com.taosdata.example.ConnectionPoolDemo
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
<version>
3.3.0
</version>
<executions>
<execution>
<id>
make-assembly
</id>
<id>
ConnectionPoolDemo
</id>
<configuration>
<finalName>
ConnectionPoolDemo
</finalName>
<archive>
<manifest>
<mainClass>
com.taosdata.example.ConnectionPoolDemo
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
</execution>
<execution>
<id>
ProxoolDemo
</id>
<configuration>
<finalName>
ProxoolDemo
</finalName>
<archive>
<manifest>
<mainClass>
com.taosdata.example.ProxoolDemo
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
...
tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ProxoolDemo.java
0 → 100644
浏览文件 @
7f2e888b
package
com.taosdata.example
;
import
org.logicalcobwebs.proxool.ProxoolException
;
import
org.logicalcobwebs.proxool.configuration.JAXPConfigurator
;
import
java.sql.*
;
public
class
ProxoolDemo
{
public
static
void
main
(
String
[]
args
)
{
String
xml
=
parseConfigurationXml
(
args
);
if
(
xml
==
null
)
{
printHelp
();
System
.
exit
(
0
);
}
try
{
JAXPConfigurator
.
configure
(
xml
,
false
);
Class
.
forName
(
"org.logicalcobwebs.proxool.ProxoolDriver"
);
Connection
connection
=
DriverManager
.
getConnection
(
"proxool.ds"
);
Statement
stmt
=
connection
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"show databases"
);
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
metaData
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
metaData
.
getColumnLabel
(
i
)
+
": "
+
rs
.
getString
(
i
));
}
System
.
out
.
println
();
}
stmt
.
close
();
}
catch
(
ClassNotFoundException
|
SQLException
|
ProxoolException
e
)
{
e
.
printStackTrace
();
}
}
private
static
String
parseConfigurationXml
(
String
[]
args
)
{
String
host
=
null
;
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
"--xml"
.
equalsIgnoreCase
(
args
[
i
])
&&
i
<
args
.
length
-
1
)
{
host
=
args
[++
i
];
}
}
return
host
;
}
private
static
void
printHelp
()
{
System
.
out
.
println
(
"Usage: java -jar ProxoolDemo.jar --xml [xml]"
);
}
}
tests/examples/JDBC/connectionPools/src/main/resources/proxool.xml
0 → 100644
浏览文件 @
7f2e888b
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
<proxool>
<alias>
ds
</alias>
<!--数据源的别名-->
<driver-url>
jdbc:TAOS-RS://127.0.0.1:6041/log
</driver-url>
<!--url连接串-->
<driver-class>
com.taosdata.jdbc.rs.RestfulDriver
</driver-class>
<!--驱动类-->
<driver-properties>
<property
name=
"user"
value=
"root"
/>
<property
name=
"password"
value=
"taosdata"
/>
</driver-properties>
<!--最大连接数(默认5个),超过了这个连接数,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定 -->
<maximum-connection-count>
100
</maximum-connection-count>
<!-- 定义连接池中的最大连接数 -->
<maximum-active-time>
100
</maximum-active-time>
<!--最少保持的空闲连接数(默认2个)-->
<prototype-count>
1
</prototype-count>
<!--最小连接数(默认2个)-->
<minimum-connection-count>
5
</minimum-connection-count>
<!--proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁 默认30秒-->
<house-keeping-sleep-time>
30000
</house-keeping-sleep-time>
<!--用于保持连接的测试语句 -->
<house-keeping-test-sql>
select server_status()
</house-keeping-test-sql>
</proxool>
</something-else-entirely>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录