Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2079533b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
2079533b
编写于
1月 22, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge from develop
上级
196b3cb9
a3bbff7a
变更
25
展开全部
隐藏空白更改
内联
并排
Showing
25 changed file
with
1111 addition
and
1838 deletion
+1111
-1838
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
+2
-2
packaging/tools/taosd-dump-cfg.gdb
packaging/tools/taosd-dump-cfg.gdb
+144
-0
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+8
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
...main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
+510
-47
src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
...dbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
+0
-67
src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
.../jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
+36
-36
src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetTablesResultSet.java
...c/src/main/java/com/taosdata/jdbc/GetTablesResultSet.java
+0
-53
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
...src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
+15
-1159
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
...in/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
+22
-146
src/connector/jdbc/src/test/java/TestPreparedStatement.java
src/connector/jdbc/src/test/java/TestPreparedStatement.java
+0
-36
src/connector/jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java
...jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java
+59
-64
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java
.../jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java
+16
-37
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java
...ctor/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java
+78
-58
src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java
...rc/test/java/com/taosdata/jdbc/PreparedStatementTest.java
+1
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java
...ctor/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java
+46
-34
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java
...ctor/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java
+50
-63
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
...test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
+40
-18
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
...rc/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
+1
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
...src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
...c/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
...ctor/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/TimeStampUtil.java
.../src/test/java/com/taosdata/jdbc/utils/TimeStampUtil.java
+67
-0
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+1
-1
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java
...emo/src/main/java/com/taosdata/example/SubscribeDemo.java
+10
-8
tests/script/sh/mv_old_data.sh
tests/script/sh/mv_old_data.sh
+2
-2
未找到文件。
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
浏览文件 @
2079533b
...
...
@@ -698,13 +698,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
```mysql
SELECT TWA(field_name) FROM tb_name WHERE clause;
```
功能说明:时间加权平均函数。统计表
/超级表
中某列在一段时间内的时间加权平均。
功能说明:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。
返回结果数据类型:双精度浮点数Double。
应用字段:不能应用在timestamp、binary、nchar、bool类型字段。
适用于:表
、超级表
。
适用于:表。
- **SUM**
```mysql
...
...
packaging/tools/taosd-dump-cfg.gdb
0 → 100644
浏览文件 @
2079533b
# Usage:
# sudo gdb -x ./taosd-dump-cfg.gdb
define attach_pidof
if $argc != 1
help attach_pidof
else
shell echo -e "\
set \$PID = "$(echo $(pidof $arg0) 0 | cut -d " " -f 1)"\n\
if \$PID > 0\n\
attach "$(pidof -s $arg0)"\n\
else\n\
print \"Process '"$arg0"' not found\"\n\
end" > /tmp/gdb.pidof
source /tmp/gdb.pidof
end
end
document attach_pidof
Attach to process by name
Usage: attach_pidof PROG_NAME
end
set $TAOS_CFG_VTYPE_INT8 = 0
set $TAOS_CFG_VTYPE_INT16 = 1
set $TAOS_CFG_VTYPE_INT32 = 2
set $TAOS_CFG_VTYPE_FLOAT = 3
set $TAOS_CFG_VTYPE_STRING = 4
set $TAOS_CFG_VTYPE_IPSTR = 5
set $TAOS_CFG_VTYPE_DIRECTORY = 6
set $TSDB_CFG_CTYPE_B_CONFIG = 1U
set $TSDB_CFG_CTYPE_B_SHOW = 2U
set $TSDB_CFG_CTYPE_B_LOG = 4U
set $TSDB_CFG_CTYPE_B_CLIENT = 8U
set $TSDB_CFG_CTYPE_B_OPTION = 16U
set $TSDB_CFG_CTYPE_B_NOT_PRINT = 32U
set $TSDB_CFG_PRINT_LEN = 53
define print_blank
if $argc == 1
set $blank_len = $arg0
while $blank_len > 0
printf "%s", " "
set $blank_len = $blank_len - 1
end
end
end
define dump_cfg
if $argc != 1
help dump_cfg
else
set $blen = $TSDB_CFG_PRINT_LEN - (int)strlen($arg0.option)
if $blen < 0
$blen = 0
end
#printf "%s: %d\n", "******blen: ", $blen
printf "%s: ", $arg0.option
print_blank $blen
if $arg0.valType == $TAOS_CFG_VTYPE_INT8
printf "%d\n", *((int8_t *) $arg0.ptr)
else
if $arg0.valType == $TAOS_CFG_VTYPE_INT16
printf "%d\n", *((int16_t *) $arg0.ptr)
else
if $arg0.valType == $TAOS_CFG_VTYPE_INT32
printf "%d\n", *((int32_t *) $arg0.ptr)
else
if $arg0.valType == $TAOS_CFG_VTYPE_FLOAT
printf "%f\n", *((float *) $arg0.ptr)
else
printf "%s\n", $arg0.ptr
end
end
end
end
end
end
document dump_cfg
Dump a cfg entry
Usage: dump_cfg cfg
end
set pagination off
attach_pidof taosd
set $idx=0
#print tsGlobalConfigNum
#set $end=$1
set $end=tsGlobalConfigNum
p "*=*=*=*=*=*=*=*=*= taos global config:"
#while ($idx .lt. $end)
while ($idx < $end)
# print tsGlobalConfig[$idx].option
set $cfg = tsGlobalConfig[$idx]
set $tsce = tscEmbedded
# p "1"
if ($tsce == 0)
if !($cfg.cfgType & $TSDB_CFG_CTYPE_B_CLIENT)
end
else
if $cfg.cfgType & $TSDB_CFG_CTYPE_B_NOT_PRINT
else
if !($cfg.cfgType & $TSDB_CFG_CTYPE_B_SHOW)
else
dump_cfg $cfg
end
end
end
set $idx=$idx+1
end
set $idx=0
p "*=*=*=*=*=*=*=*=*= taos local config:"
while ($idx < $end)
set $cfg = tsGlobalConfig[$idx]
set $tsce = tscEmbedded
if ($tsce == 0)
if !($cfg.cfgType & $TSDB_CFG_CTYPE_B_CLIENT)
end
else
if $cfg.cfgType & $TSDB_CFG_CTYPE_B_NOT_PRINT
else
if ($cfg.cfgType & $TSDB_CFG_CTYPE_B_SHOW)
else
dump_cfg $cfg
end
end
end
set $idx=$idx+1
end
detach
quit
src/connector/jdbc/pom.xml
浏览文件 @
2079533b
...
...
@@ -74,6 +74,14 @@
<version>
1.2.58
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-dbcp2
</artifactId>
<version>
2.7.0
</version>
</dependency>
</dependencies>
<build>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
浏览文件 @
2079533b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
已删除
100644 → 0
浏览文件 @
196b3cb9
/***************************************************************************
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
package
com.taosdata.jdbc
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
/*
* TDengine only supports a subset of the standard SQL, thus this implemetation of the
* standard JDBC API contains more or less some adjustments customized for certain
* compatibility needs.
*/
public
class
CatalogResultSet
extends
TSDBResultSetWrapper
{
public
CatalogResultSet
(
ResultSet
resultSet
)
{
super
.
setOriginalResultSet
(
resultSet
);
}
@Override
public
String
getString
(
int
columnIndex
)
throws
SQLException
{
if
(
columnIndex
<=
1
)
{
return
super
.
getString
(
columnIndex
);
}
else
{
return
null
;
}
}
@Override
public
boolean
getBoolean
(
int
columnIndex
)
throws
SQLException
{
if
(
columnIndex
<=
1
)
{
return
super
.
getBoolean
(
columnIndex
);
}
else
{
return
false
;
}
}
@Override
public
byte
[]
getBytes
(
int
columnIndex
)
throws
SQLException
{
if
(
columnIndex
<=
1
)
{
return
super
.
getBytes
(
columnIndex
);
}
else
{
return
null
;
}
}
@Override
public
Object
getObject
(
int
columnIndex
)
throws
SQLException
{
if
(
columnIndex
<=
1
)
{
return
super
.
getObject
(
columnIndex
);
}
else
{
return
null
;
}
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
浏览文件 @
2079533b
...
...
@@ -16,40 +16,40 @@ package com.taosdata.jdbc;
public
class
ColumnMetaData
{
private
int
colType
=
0
;
private
String
colName
=
null
;
private
int
colSize
=
-
1
;
private
int
colIndex
=
0
;
public
int
getColSize
()
{
return
colSize
;
}
public
void
setColSize
(
int
colSize
)
{
this
.
colSize
=
colSize
;
}
public
int
getColType
()
{
return
colType
;
}
public
void
setColType
(
int
colType
)
{
this
.
colType
=
colType
;
}
public
String
getColName
()
{
return
colName
;
}
public
void
setColName
(
String
colName
)
{
this
.
colName
=
colName
;
}
public
int
getColIndex
()
{
return
colIndex
;
}
public
void
setColIndex
(
int
colIndex
)
{
this
.
colIndex
=
colIndex
;
}
private
int
colType
=
0
;
private
String
colName
=
null
;
private
int
colSize
=
-
1
;
private
int
colIndex
=
0
;
public
int
getColSize
()
{
return
colSize
;
}
public
void
setColSize
(
int
colSize
)
{
this
.
colSize
=
colSize
;
}
public
int
getColType
()
{
return
colType
;
}
public
void
setColType
(
int
colType
)
{
this
.
colType
=
colType
;
}
public
String
getColName
()
{
return
colName
;
}
public
void
setColName
(
String
colName
)
{
this
.
colName
=
colName
;
}
public
int
getColIndex
()
{
return
colIndex
;
}
public
void
setColIndex
(
int
colIndex
)
{
this
.
colIndex
=
colIndex
;
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetTablesResultSet.java
已删除
100644 → 0
浏览文件 @
196b3cb9
/***************************************************************************
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
package
com.taosdata.jdbc
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
/*
* TDengine only supports a subset of the standard SQL, thus this implemetation of the
* standard JDBC API contains more or less some adjustments customized for certain
* compatibility needs.
*/
public
class
GetTablesResultSet
extends
TSDBResultSetWrapper
{
private
String
catalog
;
private
String
schemaPattern
;
private
String
tableNamePattern
;
private
String
[]
types
;
public
GetTablesResultSet
(
ResultSet
resultSet
,
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
)
{
super
.
setOriginalResultSet
(
resultSet
);
this
.
catalog
=
catalog
;
this
.
schemaPattern
=
schemaPattern
;
this
.
tableNamePattern
=
tableNamePattern
;
this
.
types
=
types
;
}
@Override
public
String
getString
(
int
columnIndex
)
throws
SQLException
{
String
ret
=
null
;
switch
(
columnIndex
)
{
case
3
:
return
super
.
getString
(
1
);
case
4
:
return
"table"
;
default
:
return
null
;
}
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
浏览文件 @
2079533b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
浏览文件 @
2079533b
...
...
@@ -29,177 +29,53 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData {
}
@Override
public
String
get
SchemaTerm
()
throws
SQLException
{
return
null
;
public
String
get
DriverName
()
throws
SQLException
{
return
RestfulDriver
.
class
.
getName
()
;
}
@Override
public
String
getProcedureTerm
()
throws
SQLException
{
return
null
;
}
@Override
public
String
getCatalogTerm
()
throws
SQLException
{
return
null
;
}
@Override
public
boolean
isCatalogAtStart
()
throws
SQLException
{
return
false
;
}
@Override
public
ResultSet
getTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
)
throws
SQLException
{
Statement
stmt
=
null
;
if
(
null
!=
connection
&&
!
connection
.
isClosed
())
{
stmt
=
connection
.
createStatement
();
if
(
catalog
==
null
||
catalog
.
length
()
<
1
)
{
catalog
=
connection
.
getCatalog
();
}
stmt
.
executeUpdate
(
"use "
+
catalog
);
ResultSet
resultSet0
=
stmt
.
executeQuery
(
"show tables"
);
GetTablesResultSet
getTablesResultSet
=
new
GetTablesResultSet
(
resultSet0
,
catalog
,
schemaPattern
,
tableNamePattern
,
types
);
return
getTablesResultSet
;
}
else
{
if
(
connection
==
null
||
connection
.
isClosed
())
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
return
super
.
getTables
(
catalog
,
schemaPattern
,
tableNamePattern
,
types
,
connection
);
}
@Override
public
ResultSet
getCatalogs
()
throws
SQLException
{
if
(
connection
!=
null
&&
!
connection
.
isClosed
())
{
Statement
stmt
=
connection
.
createStatement
();
ResultSet
resultSet0
=
stmt
.
executeQuery
(
"show databases"
);
CatalogResultSet
resultSet
=
new
CatalogResultSet
(
resultSet0
);
return
resultSet
;
}
else
{
return
new
EmptyResultSet
();
}
if
(
connection
==
null
||
connection
.
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
return
super
.
getCatalogs
(
connection
);
}
@Override
public
ResultSet
getColumns
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
columnNamePattern
)
throws
SQLException
{
Statement
stmt
=
null
;
if
(
null
!=
connection
&&
!
connection
.
isClosed
())
{
stmt
=
connection
.
createStatement
();
if
(
catalog
==
null
||
catalog
.
length
()
<
1
)
{
catalog
=
connection
.
getCatalog
();
}
stmt
.
execute
(
"use "
+
catalog
);
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
// set up ColumnMetaDataList
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<>(
24
);
columnMetaDataList
.
add
(
null
);
columnMetaDataList
.
add
(
null
);
// add TABLE_NAME
ColumnMetaData
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
3
);
colMetaData
.
setColName
(
"TABLE_NAME"
);
colMetaData
.
setColSize
(
193
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
);
columnMetaDataList
.
add
(
colMetaData
);
// add COLUMN_NAME
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
4
);
colMetaData
.
setColName
(
"COLUMN_NAME"
);
colMetaData
.
setColSize
(
65
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
);
columnMetaDataList
.
add
(
colMetaData
);
// add DATA_TYPE
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
5
);
colMetaData
.
setColName
(
"DATA_TYPE"
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_INT
);
columnMetaDataList
.
add
(
colMetaData
);
// add TYPE_NAME
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
6
);
colMetaData
.
setColName
(
"TYPE_NAME"
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_BINARY
);
columnMetaDataList
.
add
(
colMetaData
);
// add COLUMN_SIZE
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
7
);
colMetaData
.
setColName
(
"COLUMN_SIZE"
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_INT
);
columnMetaDataList
.
add
(
colMetaData
);
// add BUFFER_LENGTH ,not used
columnMetaDataList
.
add
(
null
);
// add DECIMAL_DIGITS
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
9
);
colMetaData
.
setColName
(
"DECIMAL_DIGITS"
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_INT
);
columnMetaDataList
.
add
(
colMetaData
);
// add NUM_PREC_RADIX
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
10
);
colMetaData
.
setColName
(
"NUM_PREC_RADIX"
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_INT
);
columnMetaDataList
.
add
(
colMetaData
);
// add NULLABLE
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
11
);
colMetaData
.
setColName
(
"NULLABLE"
);
colMetaData
.
setColType
(
TSDBConstants
.
TSDB_DATA_TYPE_INT
);
columnMetaDataList
.
add
(
colMetaData
);
resultSet
.
setColumnMetaDataList
(
columnMetaDataList
);
// set up rowDataList
ResultSet
resultSet0
=
stmt
.
executeQuery
(
"describe "
+
tableNamePattern
);
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
int
index
=
0
;
while
(
resultSet0
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
24
);
// set TABLE_NAME
rowData
.
setString
(
2
,
tableNamePattern
);
// set COLUMN_NAME
rowData
.
setString
(
3
,
resultSet0
.
getString
(
1
));
// set DATA_TYPE
String
typeName
=
resultSet0
.
getString
(
2
);
rowData
.
setInt
(
4
,
getDataType
(
typeName
));
// set TYPE_NAME
rowData
.
setString
(
5
,
typeName
);
// set COLUMN_SIZE
int
length
=
resultSet0
.
getInt
(
3
);
rowData
.
setInt
(
6
,
getColumnSize
(
typeName
,
length
));
// set DECIMAL_DIGITS
rowData
.
setInt
(
8
,
getDecimalDigits
(
typeName
));
// set NUM_PREC_RADIX
rowData
.
setInt
(
9
,
10
);
// set NULLABLE
rowData
.
setInt
(
10
,
getNullable
(
index
,
typeName
));
rowDataList
.
add
(
rowData
);
index
++;
}
resultSet
.
setRowDataList
(
rowDataList
);
return
resultSet
;
}
else
{
public
ResultSet
getTableTypes
()
throws
SQLException
{
if
(
connection
==
null
||
connection
.
isClosed
())
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
return
super
.
getTableTypes
();
}
@Override
public
long
getMaxLogicalLobSize
()
throws
SQLException
{
return
0
;
public
ResultSet
getColumns
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
columnNamePattern
)
throws
SQLException
{
if
(
connection
==
null
||
connection
.
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
return
super
.
getColumns
(
catalog
,
schemaPattern
,
tableNamePattern
,
columnNamePattern
,
connection
);
}
@Override
public
boolean
supportsRefCursors
()
throws
SQLException
{
return
false
;
public
ResultSet
getPrimaryKeys
(
String
catalog
,
String
schema
,
String
table
)
throws
SQLException
{
if
(
connection
==
null
||
connection
.
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
return
super
.
getPrimaryKeys
(
catalog
,
schema
,
table
,
connection
);
}
@Override
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
return
null
;
public
ResultSet
getSuperTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
)
throws
SQLException
{
if
(
connection
==
null
||
connection
.
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
return
super
.
getSuperTables
(
catalog
,
schemaPattern
,
tableNamePattern
,
connection
);
}
@Override
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
return
false
;
}
}
src/connector/jdbc/src/test/java/TestPreparedStatement.java
已删除
100644 → 0
浏览文件 @
196b3cb9
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBPreparedStatement
;
import
java.sql.*
;
import
java.util.Properties
;
public
class
TestPreparedStatement
{
public
static
void
main
(
String
[]
args
)
throws
SQLException
{
Connection
connection
=
null
;
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
"localhost"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:0/"
,
properties
);
String
rawSql
=
"select * from test.log0601"
;
// String[] params = new String[]{"ts", "c1"};
PreparedStatement
pstmt
=
(
TSDBPreparedStatement
)
connection
.
prepareStatement
(
rawSql
);
ResultSet
resSet
=
pstmt
.
executeQuery
();
while
(
resSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
resSet
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
"%d: %s \n"
,
i
,
resSet
.
getString
(
i
));
}
}
resSet
.
close
();
pstmt
.
close
();
connection
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
if
(
null
!=
connection
)
{
connection
.
close
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java
浏览文件 @
2079533b
...
...
@@ -13,17 +13,17 @@ import java.util.concurrent.TimeUnit;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
BatchInsertTest
extends
BaseTest
{
static
Connection
connection
=
null
;
static
Statement
statement
=
null
;
static
String
dbName
=
"test"
;
static
String
stbName
=
"meters"
;
static
String
host
=
"localhost
"
;
static
int
numOfTables
=
30
;
final
static
int
numOfRecordsPerTable
=
1000
;
static
long
ts
=
1496732686000
l
;
final
static
String
tablePrefix
=
"t"
;
public
class
BatchInsertTest
{
private
Connection
connection
;
private
static
String
dbName
=
"test"
;
private
static
String
stbName
=
"meters"
;
private
static
String
host
=
"127.0.0.1
"
;
private
static
int
numOfTables
=
30
;
private
static
int
numOfRecordsPerTable
=
1000
;
private
static
long
ts
=
1496732686000
l
;
private
static
String
tablePrefix
=
"t"
;
@Before
public
void
createDatabase
()
throws
SQLException
{
...
...
@@ -32,65 +32,58 @@ public class BatchInsertTest extends BaseTest {
}
catch
(
ClassNotFoundException
e
)
{
return
;
}
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"drop database if exists "
+
dbName
);
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"use "
+
dbName
);
String
createTableSql
=
"create table "
+
stbName
+
"(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))"
;
statement
.
executeUpdate
(
createTableSql
);
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists "
+
dbName
);
stmt
.
execute
(
"create database if not exists "
+
dbName
);
stmt
.
execute
(
"use "
+
dbName
);
String
createTableSql
=
"create table "
+
stbName
+
"(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))"
;
stmt
.
execute
(
createTableSql
);
for
(
int
i
=
0
;
i
<
numOfTables
;
i
++)
{
for
(
int
i
=
0
;
i
<
numOfTables
;
i
++)
{
String
loc
=
i
%
2
==
0
?
"beijing"
:
"shanghai"
;
String
createSubTalbesSql
=
"create table "
+
tablePrefix
+
i
+
" using "
+
stbName
+
" tags("
+
i
+
", '"
+
loc
+
"')"
;
st
atement
.
executeUpdate
(
createSubTalbesSql
);
String
createSubTalbesSql
=
"create table "
+
tablePrefix
+
i
+
" using "
+
stbName
+
" tags("
+
i
+
", '"
+
loc
+
"')"
;
st
mt
.
execute
(
createSubTalbesSql
);
}
stmt
.
close
();
}
@Test
public
void
testBatchInsert
()
throws
SQLException
{
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
numOfTables
);
for
(
int
i
=
0
;
i
<
numOfTables
;
i
++)
{
final
int
index
=
i
;
executorService
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
long
startTime
=
System
.
currentTimeMillis
();
Statement
statement
=
connection
.
createStatement
();
// get statement
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"INSERT INTO "
+
tablePrefix
+
index
+
" VALUES"
);
Random
rand
=
new
Random
();
for
(
int
j
=
1
;
j
<=
numOfRecordsPerTable
;
j
++)
{
sb
.
append
(
"("
+
(
ts
+
j
)
+
", "
);
sb
.
append
(
rand
.
nextInt
(
100
)
+
", "
);
sb
.
append
(
rand
.
nextInt
(
100
)
+
", "
);
sb
.
append
(
rand
.
nextInt
(
100
)
+
")"
);
}
statement
.
addBatch
(
sb
.
toString
());
statement
.
executeBatch
();
long
endTime
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"Thread "
+
index
+
" takes "
+
(
endTime
-
startTime
)
+
" microseconds"
);
connection
.
commit
();
statement
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
public
void
testBatchInsert
()
throws
SQLException
{
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
numOfTables
);
for
(
int
i
=
0
;
i
<
numOfTables
;
i
++)
{
final
int
index
=
i
;
executorService
.
execute
(()
->
{
try
{
long
startTime
=
System
.
currentTimeMillis
();
Statement
statement
=
connection
.
createStatement
();
// get statement
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"INSERT INTO "
+
tablePrefix
+
index
+
" VALUES"
);
Random
rand
=
new
Random
();
for
(
int
j
=
1
;
j
<=
numOfRecordsPerTable
;
j
++)
{
sb
.
append
(
"("
+
(
ts
+
j
)
+
", "
);
sb
.
append
(
rand
.
nextInt
(
100
)
+
", "
);
sb
.
append
(
rand
.
nextInt
(
100
)
+
", "
);
sb
.
append
(
rand
.
nextInt
(
100
)
+
")"
);
}
statement
.
addBatch
(
sb
.
toString
());
statement
.
executeBatch
();
long
endTime
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"Thread "
+
index
+
" takes "
+
(
endTime
-
startTime
)
+
" microseconds"
);
connection
.
commit
();
statement
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
});
}
executorService
.
shutdown
();
try
{
...
...
@@ -100,21 +93,23 @@ public class BatchInsertTest extends BaseTest {
}
Statement
statement
=
connection
.
createStatement
();
ResultSet
rs
=
statement
.
executeQuery
(
"select * from meters"
);
ResultSet
rs
=
statement
.
executeQuery
(
"select * from meters"
);
int
num
=
0
;
while
(
rs
.
next
())
{
num
++;
}
assertEquals
(
num
,
numOfTables
*
numOfRecordsPerTable
);
}
assertEquals
(
num
,
numOfTables
*
numOfRecordsPerTable
);
rs
.
close
();
}
@After
public
void
close
()
throws
Exception
{
statement
.
close
();
connection
.
close
();
Thread
.
sleep
(
10
);
public
void
close
()
{
try
{
if
(
connection
!=
null
)
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java
浏览文件 @
2079533b
package
com.taosdata.jdbc
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.sql.Connection
;
...
...
@@ -8,53 +9,31 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
ConnectionTest
extends
BaseTest
{
static
Connection
connection
=
null
;
static
Statement
statement
=
null
;
static
String
dbName
=
"test"
;
static
String
stbName
=
"st"
;
static
String
host
=
"localhost"
;
public
class
ConnectionTest
{
private
Connection
connection
;
private
Statement
statement
;
private
static
String
host
=
"127.0.0.1"
;
@Test
public
void
testConnection
()
throws
SQLException
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
}
catch
(
ClassNotFoundException
e
)
{
return
;
}
public
void
testConnection
()
{
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
assertTrue
(
null
!=
connection
);
statement
=
connection
.
createStatement
();
assertTrue
(
null
!=
statement
);
// try reconnect
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
try
{
statement
.
execute
(
"create database if not exists "
+
dbName
);
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
Assert
.
assertTrue
(
null
!=
connection
);
statement
=
connection
.
createStatement
();
Assert
.
assertTrue
(
null
!=
statement
);
statement
.
close
();
connection
.
close
();
}
catch
(
ClassNotFoundException
e
)
{
return
;
}
catch
(
SQLException
e
)
{
assert
false
:
"create database error: "
+
e
.
getMessage
();
}
try
{
if
(!
connection
.
isClosed
())
{
if
(!
statement
.
isClosed
())
{
statement
.
executeUpdate
(
"drop database "
+
dbName
);
statement
.
close
();
}
connection
.
close
();
Thread
.
sleep
(
10
);
}
}
catch
(
Exception
e
)
{
assert
false
:
"close connection error: "
+
e
.
getMessage
();
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java
浏览文件 @
2079533b
package
com.taosdata.jdbc
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.*
;
import
org.junit.runners.MethodSorters
;
import
java.sql.*
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
ImportTest
extends
BaseTest
{
Connection
connection
=
null
;
Statement
statement
=
null
;
String
dbName
=
"test"
;
String
tName
=
"t0"
;
String
host
=
"localhost"
;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
ImportTest
{
private
static
Connection
connection
;
static
String
dbName
=
"test"
;
static
String
tName
=
"t0"
;
static
String
host
=
"127.0.0.1"
;
private
static
long
ts
;
@Before
public
void
createDatabase
()
throws
SQLException
{
@Before
Class
public
static
void
before
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"create database if not exists "
+
dbName
);
stmt
.
execute
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
stmt
.
close
();
ts
=
System
.
currentTimeMillis
();
}
catch
(
ClassNotFoundException
e
)
{
return
;
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"drop database if exists "
+
dbName
);
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
}
@Test
public
void
insertData
()
throws
Exception
{
long
ts
=
1496732686000
l
;
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
ts
++
;
int
row
=
statement
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")"
);
System
.
out
.
println
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")\t"
+
row
);
assertEquals
(
1
,
row
);
public
void
case001_
insertData
()
throws
Exception
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
ts
++;
int
row
=
stmt
.
executeUpdate
(
"import into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")"
)
;
System
.
out
.
println
(
"import into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")\t"
+
row
);
assertEquals
(
1
,
row
);
}
}
}
@Test
public
void
selectData
()
throws
Exception
{
insertData
();
String
sql
=
"select * from test.t0"
;
ResultSet
resSet
=
statement
.
executeQuery
(
sql
);
public
void
case002_checkSum
()
{
Assert
.
assertEquals
(
50
,
select
());
}
while
(
resSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
resSet
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
i
+
": "
+
resSet
.
getString
(
i
)
+
"\t"
);
private
int
select
()
{
int
count
=
0
;
try
(
Statement
stmt
=
connection
.
createStatement
())
{
String
sql
=
"select * from "
+
dbName
+
"."
+
tName
;
ResultSet
rs
=
stmt
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
count
++;
}
rs
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
re
sSet
.
close
()
;
re
turn
count
;
}
@Test
public
void
importData
()
throws
Exception
{
public
void
case003_importData
()
{
// 避免时间重复
long
ts
=
1496732686000
l
;
StringBuilder
sqlBuilder
=
new
StringBuilder
(
"insert into "
).
append
(
dbName
).
append
(
"."
).
append
(
tName
).
append
(
" values "
);
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
int
a
=
i
/
5
;
long
t
=
ts
+
a
;
sqlBuilder
.
append
(
"("
).
append
(
t
).
append
(
","
).
append
((
100
+
i
)).
append
(
","
).
append
(
i
).
append
(
") "
);
try
(
Statement
stmt
=
connection
.
createStatement
())
{
StringBuilder
sqlBuilder
=
new
StringBuilder
(
"import into "
).
append
(
dbName
).
append
(
"."
).
append
(
tName
).
append
(
" values "
);
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
int
a
=
i
/
5
;
long
t
=
(++
ts
)
+
a
;
sqlBuilder
.
append
(
"("
).
append
(
t
).
append
(
","
).
append
((
100
+
i
)).
append
(
","
).
append
(
i
).
append
(
") "
);
}
System
.
out
.
println
(
sqlBuilder
.
toString
());
int
rows
=
stmt
.
executeUpdate
(
sqlBuilder
.
toString
());
assertEquals
(
50
,
rows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
sqlBuilder
.
toString
());
int
rows
=
statement
.
executeUpdate
(
sqlBuilder
.
toString
());
System
.
out
.
println
(
rows
);
assertEquals
(
10
,
rows
);
}
@After
public
void
close
()
throws
Exception
{
statement
.
executeUpdate
(
"drop database "
+
dbName
);
statement
.
close
();
connection
.
close
();
Thread
.
sleep
(
10
);
@Test
public
void
case004_checkSum
()
{
Assert
.
assertEquals
(
100
,
select
());
}
@AfterClass
public
static
void
close
()
{
try
{
if
(
connection
!=
null
)
{
Statement
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"drop database "
+
dbName
);
statement
.
close
();
connection
.
close
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java
浏览文件 @
2079533b
...
...
@@ -4,7 +4,6 @@ import org.junit.AfterClass;
import
org.junit.BeforeClass
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
org.junit.runners.MethodSorters
;
import
java.sql.*
;
import
java.util.Properties
;
...
...
@@ -12,7 +11,7 @@ import java.util.Properties;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
@FixMethodOrder
(
MethodSorters
.
DEFAULT
)
@FixMethodOrder
()
public
class
PreparedStatementTest
extends
BaseTest
{
static
Connection
connection
=
null
;
static
PreparedStatement
statement
=
null
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java
浏览文件 @
2079533b
...
...
@@ -9,61 +9,73 @@ import java.util.Properties;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
SelectTest
extends
BaseTest
{
Connection
connection
=
null
;
Statement
statement
=
null
;
public
class
SelectTest
{
Connection
connection
;
String
dbName
=
"test"
;
String
tName
=
"t0"
;
String
host
=
"
localhost
"
;
String
host
=
"
127.0.0.1
"
;
@Before
public
void
createDatabaseAndTable
()
throws
SQLException
{
public
void
createDatabaseAndTable
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists "
+
dbName
);
stmt
.
execute
(
"create database if not exists "
+
dbName
);
stmt
.
execute
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
stmt
.
close
();
}
catch
(
ClassNotFoundException
e
)
{
return
;
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"drop database if exists "
+
dbName
);
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
}
@Test
public
void
selectData
()
throws
SQLException
{
public
void
selectData
()
{
long
ts
=
1496732686000
l
;
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
ts
++;
int
row
=
statement
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")"
);
System
.
out
.
println
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")\t"
+
row
);
assertEquals
(
1
,
row
);
}
try
(
Statement
stmt
=
connection
.
createStatement
())
{
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
ts
++;
int
row
=
stmt
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")"
);
System
.
out
.
println
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", "
+
(
100
+
i
)
+
", "
+
i
+
")\t"
+
row
);
assertEquals
(
1
,
row
);
}
String
sql
=
"select * from "
+
dbName
+
"."
+
tName
;
ResultSet
resSet
=
statemen
t
.
executeQuery
(
sql
);
String
sql
=
"select * from "
+
dbName
+
"."
+
tName
;
ResultSet
resSet
=
stm
t
.
executeQuery
(
sql
);
int
num
=
0
;
while
(
resSet
.
next
())
{
num
++;
int
num
=
0
;
while
(
resSet
.
next
())
{
num
++;
}
resSet
.
close
();
assertEquals
(
num
,
50
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
resSet
.
close
();
assertEquals
(
num
,
50
);
}
@After
public
void
close
()
throws
Exception
{
statement
.
executeUpdate
(
"drop database "
+
dbName
);
statement
.
close
();
connection
.
close
();
Thread
.
sleep
(
10
);
public
void
close
()
{
try
{
if
(
connection
!=
null
)
{
Statement
stmt
=
connection
.
createStatement
();
stmt
.
executeUpdate
(
"drop database "
+
dbName
);
stmt
.
close
();
connection
.
close
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java
浏览文件 @
2079533b
...
...
@@ -12,69 +12,66 @@ import java.util.Properties;
import
static
org
.
junit
.
Assert
.
assertEquals
;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
StableTest
extends
BaseTest
{
static
Connection
connection
=
null
;
static
Statement
statement
=
null
;
static
String
dbName
=
"test"
;
static
String
stbName
=
"st"
;
static
String
host
=
"localhost
"
;
public
class
StableTest
{
private
static
Connection
connection
;
private
static
String
dbName
=
"test"
;
private
static
String
stbName
=
"st"
;
private
static
String
host
=
"127.0.0.1
"
;
@BeforeClass
public
static
void
createDatabase
()
throws
SQLException
{
public
static
void
createDatabase
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
Statement
statement
=
connection
.
createStatement
();
statement
.
execute
(
"create database if not exists "
+
dbName
);
statement
.
execute
(
"use "
+
dbName
);
statement
.
close
();
}
catch
(
ClassNotFoundException
e
)
{
return
;
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeQuery
(
"use "
+
dbName
);
}
// @Test
public
void
createStable
()
{
String
sql
=
"create table "
+
stbName
+
" (ts timestamp, v1 int, v2 int) tags (tg nchar(20)) "
;
try
{
statement
.
executeUpdate
(
sql
);
@Test
public
void
case001_createSuperTable
()
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
final
String
sql
=
"create table "
+
stbName
+
" (ts timestamp, v1 int, v2 int) tags (tg nchar(20)) "
;
stmt
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
assert
false
:
"error create stable"
+
e
.
getMessage
();
}
}
// @Test
public
void
createTable
()
{
String
sql
=
"create table t1 using "
+
stbName
+
" tags (\"beijing\")"
;
try
{
statement
.
executeUpdate
(
sql
);
@Test
public
void
case002_createTable
()
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
final
String
sql
=
"create table t1 using "
+
stbName
+
" tags (\"beijing\")"
;
stmt
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
assert
false
:
"error create table"
+
e
.
getMessage
();
}
}
@Test
public
void
describeSTable
()
{
createStable
();
String
sql
=
"describe "
+
stbName
;
public
void
case003_describeSTable
()
{
int
num
=
0
;
System
.
out
.
println
(
"describe stable"
);
try
{
ResultSet
r
es
=
statemen
t
.
executeQuery
(
sql
);
while
(
r
e
s
.
next
())
{
for
(
int
i
=
1
;
i
<=
r
e
s
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
print
f
(
"%d: %s\n"
,
i
,
re
s
.
getString
(
i
));
try
(
Statement
stmt
=
connection
.
createStatement
())
{
String
sql
=
"describe "
+
stbName
;
ResultSet
r
s
=
stm
t
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
rs
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
print
ln
(
i
+
":"
+
r
s
.
getString
(
i
));
}
num
++;
}
r
e
s
.
close
();
rs
.
close
();
assertEquals
(
4
,
num
);
}
catch
(
SQLException
e
)
{
assert
false
:
"error describe stable"
+
e
.
getMessage
();
...
...
@@ -82,41 +79,31 @@ public class StableTest extends BaseTest {
}
@Test
public
void
describeTable
()
{
createTable
();
String
sql
=
"describe t1"
;
public
void
case004_describeTable
()
{
int
num
=
0
;
System
.
out
.
println
(
"describe table"
);
try
{
ResultSet
res
=
statement
.
executeQuery
(
sql
);
while
(
res
.
next
())
{
for
(
int
i
=
1
;
i
<=
res
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
"%d: %s\n"
,
i
,
res
.
getString
(
i
));
try
(
Statement
stmt
=
connection
.
createStatement
())
{
ResultSet
rs
=
stmt
.
executeQuery
(
"describe t1"
);
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
rs
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
"%d: %s\n"
,
i
,
rs
.
getString
(
i
));
}
num
++;
}
r
e
s
.
close
();
rs
.
close
();
assertEquals
(
4
,
num
);
}
catch
(
SQLException
e
)
{
assert
false
:
"error describe stable"
+
e
.
getMessage
();
}
}
// @Test
public
void
validCreateSql
()
{
String
sql
=
"create table t2 using "
+
stbName
+
" tags (\"beijing\")"
;
boolean
valid
=
((
TSDBConnection
)
connection
).
getConnection
().
validateCreateTableSql
(
sql
);
assertEquals
(
true
,
valid
);
}
@AfterClass
public
static
void
close
()
throws
Exception
{
if
(!
statement
.
isClosed
())
{
statement
.
executeUpdate
(
"drop database "
+
dbName
);
statement
.
close
();
connection
.
close
();
Thread
.
sleep
(
10
);
public
static
void
close
()
{
try
{
if
(
connection
!=
null
)
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
浏览文件 @
2079533b
package
com.taosdata.jdbc
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.*
;
import
java.sql.*
;
import
java.util.Properties
;
public
class
TSDBDatabaseMetaDataTest
{
private
TSDBDatabaseMetaData
metaData
;
private
static
final
String
host
=
"localhost"
;
private
static
final
String
host
=
"127.0.0.1"
;
private
Connection
connection
;
@BeforeClass
public
void
before
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
,
properties
);
metaData
=
connection
.
getMetaData
().
unwrap
(
TSDBDatabaseMetaData
.
class
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Before
public
void
before
()
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
metaData
=
(
TSDBDatabaseMetaData
)
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
,
properties
).
getMetaData
();
@AfterClass
public
void
after
()
{
try
{
if
(
connection
!=
null
)
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
...
...
@@ -639,6 +655,7 @@ public class TSDBDatabaseMetaDataTest {
@Test
public
void
getTables
()
throws
SQLException
{
System
.
out
.
println
(
"****************************************************"
);
ResultSet
tables
=
metaData
.
getTables
(
"log"
,
""
,
null
,
null
);
ResultSetMetaData
metaData
=
tables
.
getMetaData
();
while
(
tables
.
next
())
{
...
...
@@ -658,6 +675,8 @@ public class TSDBDatabaseMetaDataTest {
@Test
public
void
getCatalogs
()
throws
SQLException
{
System
.
out
.
println
(
"****************************************************"
);
ResultSet
catalogs
=
metaData
.
getCatalogs
();
ResultSetMetaData
meta
=
catalogs
.
getMetaData
();
while
(
catalogs
.
next
())
{
...
...
@@ -670,6 +689,8 @@ public class TSDBDatabaseMetaDataTest {
@Test
public
void
getTableTypes
()
throws
SQLException
{
System
.
out
.
println
(
"****************************************************"
);
ResultSet
tableTypes
=
metaData
.
getTableTypes
();
while
(
tableTypes
.
next
())
{
System
.
out
.
println
(
tableTypes
.
getString
(
"TABLE_TYPE"
));
...
...
@@ -679,6 +700,8 @@ public class TSDBDatabaseMetaDataTest {
@Test
public
void
getColumns
()
throws
SQLException
{
System
.
out
.
println
(
"****************************************************"
);
ResultSet
columns
=
metaData
.
getColumns
(
"log"
,
""
,
"dn"
,
""
);
ResultSetMetaData
meta
=
columns
.
getMetaData
();
while
(
columns
.
next
())
{
...
...
@@ -717,6 +740,8 @@ public class TSDBDatabaseMetaDataTest {
@Test
public
void
getPrimaryKeys
()
throws
SQLException
{
System
.
out
.
println
(
"****************************************************"
);
ResultSet
rs
=
metaData
.
getPrimaryKeys
(
"log"
,
""
,
"dn1"
);
while
(
rs
.
next
())
{
System
.
out
.
println
(
"TABLE_NAME: "
+
rs
.
getString
(
"TABLE_NAME"
));
...
...
@@ -850,6 +875,8 @@ public class TSDBDatabaseMetaDataTest {
@Test
public
void
getSuperTables
()
throws
SQLException
{
System
.
out
.
println
(
"****************************************************"
);
ResultSet
rs
=
metaData
.
getSuperTables
(
"log"
,
""
,
"dn1"
);
while
(
rs
.
next
())
{
System
.
out
.
println
(
"TABLE_NAME: "
+
rs
.
getString
(
"TABLE_NAME"
));
...
...
@@ -914,11 +941,6 @@ public class TSDBDatabaseMetaDataTest {
Assert
.
assertNull
(
metaData
.
getRowIdLifetime
());
}
@Test
public
void
testGetSchemas
()
throws
SQLException
{
Assert
.
assertNull
(
metaData
.
getSchemas
());
}
@Test
public
void
supportsStoredFunctionsUsingCallSyntax
()
throws
SQLException
{
Assert
.
assertFalse
(
metaData
.
supportsStoredFunctionsUsingCallSyntax
());
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
浏览文件 @
2079533b
...
...
@@ -7,8 +7,7 @@ import java.sql.*;
public
class
AuthenticationTest
{
// private static final String host = "127.0.0.1";
private
static
final
String
host
=
"master"
;
private
static
final
String
host
=
"127.0.0.1"
;
private
static
final
String
user
=
"root"
;
private
static
final
String
password
=
"123456"
;
private
Connection
conn
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
浏览文件 @
2079533b
...
...
@@ -6,7 +6,7 @@ import org.junit.Test;
import
java.sql.*
;
public
class
RestfulDriverTest
{
private
static
final
String
host
=
"
master
"
;
private
static
final
String
host
=
"
127.0.0.1
"
;
@Test
public
void
connect
()
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
浏览文件 @
2079533b
...
...
@@ -9,7 +9,7 @@ import java.util.Random;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
RestfulJDBCTest
{
private
static
final
String
host
=
"
master
"
;
private
static
final
String
host
=
"
127.0.0.1
"
;
private
Connection
connection
;
@Before
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
浏览文件 @
2079533b
...
...
@@ -10,7 +10,7 @@ import java.sql.*;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
SQLTest
{
private
static
final
String
host
=
"
master
"
;
private
static
final
String
host
=
"
127.0.0.1
"
;
private
static
Connection
connection
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/TimeStampUtil.java
0 → 100644
浏览文件 @
2079533b
package
com.taosdata.jdbc.utils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
TimeStampUtil
{
private
static
final
String
datetimeFormat
=
"yyyy-MM-dd HH:mm:ss.SSS"
;
public
static
long
datetimeToLong
(
String
dateTime
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
datetimeFormat
);
try
{
return
sdf
.
parse
(
dateTime
).
getTime
();
}
catch
(
ParseException
e
)
{
throw
new
IllegalArgumentException
(
"invalid datetime string >>> "
+
dateTime
);
}
}
public
static
String
longToDatetime
(
long
time
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
datetimeFormat
);
return
sdf
.
format
(
new
Date
(
time
));
}
public
static
class
TimeTuple
{
public
Long
start
;
public
Long
end
;
public
Long
timeGap
;
TimeTuple
(
long
start
,
long
end
,
long
timeGap
)
{
this
.
start
=
start
;
this
.
end
=
end
;
this
.
timeGap
=
timeGap
;
}
}
public
static
TimeTuple
range
(
long
start
,
long
timeGap
,
long
size
)
{
long
now
=
System
.
currentTimeMillis
();
if
(
timeGap
<
1
)
timeGap
=
1
;
if
(
start
==
0
)
start
=
now
-
size
*
timeGap
;
// 如果size小于1异常
if
(
size
<
1
)
throw
new
IllegalArgumentException
(
"size less than 1."
);
// 如果timeGap为1,已经超长,需要前移start
if
(
start
+
size
>
now
)
{
start
=
now
-
size
;
return
new
TimeTuple
(
start
,
now
,
1
);
}
long
end
=
start
+
(
long
)
(
timeGap
*
size
);
if
(
end
>
now
)
{
//压缩timeGap
end
=
now
;
double
gap
=
(
end
-
start
)
/
(
size
*
1.0f
);
if
(
gap
<
1.0f
)
{
timeGap
=
1
;
start
=
end
-
size
;
}
else
{
timeGap
=
(
long
)
gap
;
end
=
start
+
(
long
)
(
timeGap
*
size
);
}
}
return
new
TimeTuple
(
start
,
end
,
timeGap
);
}
}
src/rpc/src/rpcUdp.c
浏览文件 @
2079533b
...
...
@@ -202,7 +202,7 @@ static void *taosRecvUdpData(void *param) {
tDebug
(
"%s UDP socket was closed, exiting(%s), dataLen:%d fd:%d"
,
pConn
->
label
,
strerror
(
errno
),
(
int32_t
)
dataLen
,
pConn
->
fd
);
//for windows usage, remote shutdown also returns - 1 in windows client
//
for windows usage, remote shutdown also returns - 1 in windows client
if
(
pConn
->
fd
==
-
1
)
{
break
;
}
else
{
...
...
src/connector/jdbc/src/test/java/TestTSDBSubscribe
.java
→
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo
.java
浏览文件 @
2079533b
package
com.taosdata.example
;
import
com.taosdata.jdbc.TSDBConnection
;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBResultSet
;
...
...
@@ -6,9 +8,9 @@ import com.taosdata.jdbc.TSDBSubscribe;
import
java.sql.DriverManager
;
import
java.util.Properties
;
public
class
TestTSDBSubscribe
{
public
class
SubscribeDemo
{
public
static
TSDBConnection
connectTDengine
(
String
host
,
String
database
)
throws
Exception
{
public
static
TSDBConnection
getConnection
(
String
host
,
String
database
)
throws
Exception
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
...
...
@@ -17,7 +19,7 @@ public class TestTSDBSubscribe {
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
String
cs
=
String
.
format
(
"jdbc:TAOS://%s:0/%s"
,
host
,
database
);
return
(
TSDBConnection
)
DriverManager
.
getConnection
(
cs
,
properties
);
return
(
TSDBConnection
)
DriverManager
.
getConnection
(
cs
,
properties
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
...
...
@@ -43,21 +45,21 @@ public class TestTSDBSubscribe {
}
}
if
(
database
.
isEmpty
()
||
topic
.
isEmpty
()
||
sql
.
isEmpty
())
{
System
.
err
.
println
(
usage
);
return
;
System
.
err
.
println
(
usage
);
return
;
}
TSDBConnection
connection
=
null
;
TSDBSubscribe
sub
=
null
;
try
{
connection
=
connectTDengine
(
host
,
database
);
connection
=
getConnection
(
host
,
database
);
sub
=
((
TSDBConnection
)
connection
).
subscribe
(
topic
,
sql
,
false
);
int
total
=
0
;
while
(
true
)
{
while
(
true
)
{
TSDBResultSet
rs
=
sub
.
consume
();
int
count
=
0
;
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
count
++;
}
total
+=
count
;
...
...
tests/script/sh/mv_old_data.sh
浏览文件 @
2079533b
...
...
@@ -32,9 +32,9 @@ NODE_DIR=$SIM_DIR/$NODE_NAME
rm
-rf
$SIM_DIR
/dnode1
rm
-rf
$SIM_DIR
/dnode2
rm
-rf
$SIM_DIR
/dnode3
rm
-rf
$SIM_DIR
/tsim
tar
zxf
$SCRIPT_DIR
/general/connection/sim.tar.gz
-C
$SIM_DIR
/../
cd
$SIM_DIR
/../sim
fqdn
=
`
hostname
`
grep
'${fqdn}'
-l
-r
./
*
| xargs
sed
-i
's/${fqdn}/${fqdn}/g'
grep
'test4'
-l
-r
./
*
| xargs
sed
-i
"s/test4/
${
fqdn
}
/g"
grep
'dataDir'
-l
-r
./
*
| xargs
sed
-i
"s#/root/TDengine#
${
TAOS_DIR
}
#g"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录