Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d8617b71
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
d8617b71
编写于
8月 31, 2022
作者:
D
dingbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: cloud java
上级
ea778b65
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
81 deletion
+10
-81
docs/examples/java/src/test/java/com/taos/test/TestAll.java
docs/examples/java/src/test/java/com/taos/test/TestAll.java
+10
-81
未找到文件。
docs/examples/java/src/test/java/com/taos/test/TestAll.java
浏览文件 @
d8617b71
package
com.taos.test
;
package
com.taos.test
;
import
com.taos.example.
*
;
import
com.taos.example.
CloudTutorial
;
import
org.junit.FixMethodOrder
;
import
com.taos.example.ConnectCloudExample
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.
*
;
import
java.sql.
SQLException
;
@FixMethodOrder
public
class
TestAll
{
public
class
TestAll
{
private
String
[]
args
=
new
String
[]{};
public
void
dropDB
(
String
dbName
)
throws
SQLException
{
String
jdbcUrl
=
"jdbc:TAOS://localhost:6030?user=root&password=taosdata"
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
jdbcUrl
))
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists "
+
dbName
);
}
}
}
public
void
insertData
()
throws
SQLException
{
String
jdbcUrl
=
"jdbc:TAOS://localhost:6030?user=root&password=taosdata"
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
jdbcUrl
))
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
String
sql
=
"INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES('2018-10-03 14:38:05.000',10.30000,219,0.31000)\n"
+
" power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES('2018-10-03 15:38:15.000',12.60000,218,0.33000)\n"
+
" power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES('2018-10-03 15:38:16.800',12.30000,221,0.31000)\n"
+
" power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES('2018-10-03 15:38:16.650',10.30000,218,0.25000)\n"
+
" power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES('2018-10-03 15:38:05.500',11.80000,221,0.28000)\n"
+
" power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES('2018-10-03 15:38:16.600',13.40000,223,0.29000)\n"
+
" power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:05.000',10.80000,223,0.29000)\n"
+
" power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:06.000',10.80000,223,0.29000)\n"
+
" power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:07.000',10.80000,223,0.29000)\n"
+
" power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:08.500',11.50000,221,0.35000)"
;
stmt
.
execute
(
sql
);
}
}
}
@Test
public
void
testJNIConnect
()
throws
SQLException
{
JNIConnectExample
.
main
(
args
);
}
@Test
@Test
public
void
test
RestConnect
()
throws
SQLException
{
public
void
test
ConnectCloudExample
()
throws
SQLException
{
RESTConnectExample
.
main
(
args
);
ConnectCloudExample
.
main
(
new
String
[]{}
);
}
}
@Test
// @Test
public
void
testRestInsert
()
throws
SQLException
{
// public void testCloudTutorial() throws SQLException {
dropDB
(
"power"
);
// CloudTutorial.main(new String[]{});
RestInsertExample
.
main
(
args
);
// }
RestQueryExample
.
main
(
args
);
}
@Test
public
void
testStmtInsert
()
throws
SQLException
{
dropDB
(
"power"
);
StmtInsertExample
.
main
(
args
);
}
@Test
public
void
testSubscribe
()
{
Thread
thread
=
new
Thread
(()
->
{
try
{
Thread
.
sleep
(
1000
);
insertData
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
});
thread
.
start
();
SubscribeDemo
.
main
(
args
);
}
@Test
public
void
testSchemaless
()
throws
SQLException
{
LineProtocolExample
.
main
(
args
);
TelnetLineProtocolExample
.
main
(
args
);
// for json protocol, tags may be double type. but for telnet protocol tag must be nchar type.
// To avoid type mismatch, we delete database test.
dropDB
(
"test"
);
JSONProtocolExample
.
main
(
args
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录