Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
82a64d85
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看板
未验证
提交
82a64d85
编写于
12月 17, 2021
作者:
JupiterChen
提交者:
GitHub
12月 17, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'taosdata:develop' into develop
上级
89b5dc7b
0e0a4c09
变更
40
显示空白变更内容
内联
并排
Showing
40 changed file
with
469 addition
and
245 deletion
+469
-245
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
+63
-17
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+1
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java
...bc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java
+2
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java
...src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java
+0
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java
...c/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java
.../jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java
+0
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
...src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
+94
-97
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java
...est/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java
+9
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
...est/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
+1
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java
...bc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
...ava/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
+34
-44
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java
...om/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java
...aosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java
...a/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java
+21
-5
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java
.../com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java
+7
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java
.../taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java
+19
-10
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java
...osdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java
+13
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java
...a/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java
+17
-6
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java
...m/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java
+13
-6
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java
.../com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java
.../taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java
...ava/com/taosdata/jdbc/cases/NullValueInResultSetTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java
...aosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java
+6
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java
.../taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java
+6
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java
...t/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java
...va/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java
+9
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java
...va/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java
+15
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java
...ava/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java
...test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java
+11
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/CharsetTest.java
...rc/test/java/com/taosdata/jdbc/confprops/CharsetTest.java
+15
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java
...c/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java
+3
-5
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimestampFormatTest.java
...java/com/taosdata/jdbc/confprops/TimestampFormatTest.java
+24
-10
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java
...test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java
+5
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
...test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java
...va/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java
+9
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java
...va/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java
+5
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
...va/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
+6
-1
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+3
-0
src/util/src/tnettest.c
src/util/src/tnettest.c
+5
-5
tests/pytest/tools/taosdemoTestTblAlt.py
tests/pytest/tools/taosdemoTestTblAlt.py
+3
-2
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
浏览文件 @
82a64d85
...
@@ -14,13 +14,43 @@ import java.math.BigDecimal;
...
@@ -14,13 +14,43 @@ import java.math.BigDecimal;
import
java.sql.*
;
import
java.sql.*
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.ZoneOffset
;
import
java.time.ZoneOffset
;
import
java.time.ZonedDateTime
;
import
java.time.chrono.IsoChronology
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatterBuilder
;
import
java.time.format.DateTimeParseException
;
import
java.time.format.DateTimeParseException
;
import
java.time.format.ResolverStyle
;
import
java.time.temporal.ChronoField
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.List
;
public
class
RestfulResultSet
extends
AbstractResultSet
implements
ResultSet
{
public
class
RestfulResultSet
extends
AbstractResultSet
implements
ResultSet
{
public
static
DateTimeFormatter
rfc3339Parser
=
null
;
{
rfc3339Parser
=
new
DateTimeFormatterBuilder
()
.
parseCaseInsensitive
()
.
appendValue
(
ChronoField
.
YEAR
,
4
)
.
appendLiteral
(
'-'
)
.
appendValue
(
ChronoField
.
MONTH_OF_YEAR
,
2
)
.
appendLiteral
(
'-'
)
.
appendValue
(
ChronoField
.
DAY_OF_MONTH
,
2
)
.
appendLiteral
(
'T'
)
.
appendValue
(
ChronoField
.
HOUR_OF_DAY
,
2
)
.
appendLiteral
(
':'
)
.
appendValue
(
ChronoField
.
MINUTE_OF_HOUR
,
2
)
.
appendLiteral
(
':'
)
.
appendValue
(
ChronoField
.
SECOND_OF_MINUTE
,
2
)
.
optionalStart
()
.
appendFraction
(
ChronoField
.
NANO_OF_SECOND
,
2
,
9
,
true
)
.
optionalEnd
()
.
appendOffset
(
"+HH:MM"
,
"Z"
).
toFormatter
()
.
withResolverStyle
(
ResolverStyle
.
STRICT
)
.
withChronology
(
IsoChronology
.
INSTANCE
);
}
private
final
Statement
statement
;
private
final
Statement
statement
;
// data
// data
private
final
List
<
List
<
Object
>>
resultSet
=
new
ArrayList
<>();
private
final
List
<
List
<
Object
>>
resultSet
=
new
ArrayList
<>();
...
@@ -187,14 +217,29 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
...
@@ -187,14 +217,29 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
}
}
case
UTC:
{
case
UTC:
{
String
value
=
row
.
getString
(
colIndex
);
String
value
=
row
.
getString
(
colIndex
);
if
(
value
.
lastIndexOf
(
":"
)
>
19
)
{
ZonedDateTime
parse
=
ZonedDateTime
.
parse
(
value
,
rfc3339Parser
);
long
nanoAdjustment
;
if
(
value
.
length
()
>
32
)
{
// ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x:00
this
.
timestampPrecision
=
TimestampPrecision
.
NS
;
}
else
if
(
value
.
length
()
>
29
)
{
// ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x:00
this
.
timestampPrecision
=
TimestampPrecision
.
US
;
}
else
{
// ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x:00
this
.
timestampPrecision
=
TimestampPrecision
.
MS
;
}
return
Timestamp
.
from
(
parse
.
toInstant
());
}
else
{
long
epochSec
=
Timestamp
.
valueOf
(
value
.
substring
(
0
,
19
).
replace
(
"T"
,
" "
)).
getTime
()
/
1000
;
long
epochSec
=
Timestamp
.
valueOf
(
value
.
substring
(
0
,
19
).
replace
(
"T"
,
" "
)).
getTime
()
/
1000
;
int
fractionalSec
=
Integer
.
parseInt
(
value
.
substring
(
20
,
value
.
length
()
-
5
));
int
fractionalSec
=
Integer
.
parseInt
(
value
.
substring
(
20
,
value
.
length
()
-
5
));
long
nanoAdjustment
;
long
nanoAdjustment
;
if
(
value
.
length
()
>
31
)
{
if
(
value
.
length
()
>
32
)
{
// ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x00
// ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x00
nanoAdjustment
=
fractionalSec
;
nanoAdjustment
=
fractionalSec
;
this
.
timestampPrecision
=
TimestampPrecision
.
NS
;
this
.
timestampPrecision
=
TimestampPrecision
.
NS
;
}
else
if
(
value
.
length
()
>
28
)
{
}
else
if
(
value
.
length
()
>
29
)
{
// ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00
// ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00
nanoAdjustment
=
fractionalSec
*
1000L
;
nanoAdjustment
=
fractionalSec
*
1000L
;
this
.
timestampPrecision
=
TimestampPrecision
.
US
;
this
.
timestampPrecision
=
TimestampPrecision
.
US
;
...
@@ -207,6 +252,7 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
...
@@ -207,6 +252,7 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
Instant
instant
=
Instant
.
ofEpochSecond
(
epochSec
,
nanoAdjustment
).
atOffset
(
zoneOffset
).
toInstant
();
Instant
instant
=
Instant
.
ofEpochSecond
(
epochSec
,
nanoAdjustment
).
atOffset
(
zoneOffset
).
toInstant
();
return
Timestamp
.
from
(
instant
);
return
Timestamp
.
from
(
instant
);
}
}
}
case
STRING:
case
STRING:
default
:
{
default
:
{
String
value
=
row
.
getString
(
colIndex
);
String
value
=
row
.
getString
(
colIndex
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
82a64d85
...
@@ -72,6 +72,7 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -72,6 +72,7 @@ public class RestfulStatement extends AbstractStatement {
}
}
this
.
database
=
sql
.
trim
().
replace
(
"use"
,
""
).
trim
();
this
.
database
=
sql
.
trim
().
replace
(
"use"
,
""
).
trim
();
this
.
conn
.
setCatalog
(
this
.
database
);
this
.
conn
.
setCatalog
(
this
.
database
);
this
.
conn
.
setClientInfo
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
,
this
.
database
);
result
=
false
;
result
=
false
;
}
else
if
(
SqlSyntaxValidator
.
isDatabaseUnspecifiedQuery
(
sql
))
{
}
else
if
(
SqlSyntaxValidator
.
isDatabaseUnspecifiedQuery
(
sql
))
{
executeOneQuery
(
sql
);
executeOneQuery
(
sql
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java
浏览文件 @
82a64d85
...
@@ -128,8 +128,8 @@ public class ParameterBindTest {
...
@@ -128,8 +128,8 @@ public class ParameterBindTest {
@After
@After
public
void
after
()
{
public
void
after
()
{
try
{
try
{
//
Statement stmt = conn.createStatement();
Statement
stmt
=
conn
.
createStatement
();
//
stmt.execute("drop database if exists test_pd");
stmt
.
execute
(
"drop database if exists test_pd"
);
if
(
conn
!=
null
)
if
(
conn
!=
null
)
conn
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java
浏览文件 @
82a64d85
...
@@ -187,7 +187,6 @@ public class SchemalessInsertTest {
...
@@ -187,7 +187,6 @@ public class SchemalessInsertTest {
public
void
after
()
{
public
void
after
()
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
close
();
conn
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java
浏览文件 @
82a64d85
...
@@ -380,8 +380,12 @@ public class TSDBConnectionTest {
...
@@ -380,8 +380,12 @@ public class TSDBConnectionTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists test"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc
;
package
com.taosdata.jdbc
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
浏览文件 @
82a64d85
...
@@ -7,6 +7,7 @@ import org.junit.Test;
...
@@ -7,6 +7,7 @@ import org.junit.Test;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.RuntimeMXBean
;
import
java.lang.management.RuntimeMXBean
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.SQLWarning
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.Properties
;
...
@@ -19,8 +20,7 @@ public class TSDBJNIConnectorTest {
...
@@ -19,8 +20,7 @@ public class TSDBJNIConnectorTest {
private
static
TSDBResultSetRowData
rowData
;
private
static
TSDBResultSetRowData
rowData
;
@Test
@Test
public
void
test
()
{
public
void
test
()
throws
SQLException
{
try
{
try
{
try
{
//change sleepSeconds when debugging with attach to process to find PID
//change sleepSeconds when debugging with attach to process to find PID
int
sleepSeconds
=
-
1
;
int
sleepSeconds
=
-
1
;
...
@@ -100,13 +100,12 @@ public class TSDBJNIConnectorTest {
...
@@ -100,13 +100,12 @@ public class TSDBJNIConnectorTest {
int
columnSize
=
columnMetaDataList
.
size
();
int
columnSize
=
columnMetaDataList
.
size
();
// print metadata
// print metadata
for
(
int
i
=
0
;
i
<
columnSize
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnSize
;
i
++)
{
System
.
out
.
println
(
columnMetaDataList
.
get
(
i
));
//
System.out.println(columnMetaDataList.get(i));
}
}
rowData
=
new
TSDBResultSetRowData
(
columnSize
);
rowData
=
new
TSDBResultSetRowData
(
columnSize
);
// iterate resultSet
// iterate resultSet
for
(
int
i
=
0
;
next
(
connector
,
pSql
);
i
++)
{
for
(
int
i
=
0
;
next
(
connector
,
pSql
);
i
++)
{
assertEquals
(
1
,
connector
.
getResultTimePrecision
(
pSql
));
assertEquals
(
1
,
connector
.
getResultTimePrecision
(
pSql
));
System
.
out
.
println
();
}
}
// close resultSet
// close resultSet
code
=
connector
.
freeResultSet
(
pSql
);
code
=
connector
.
freeResultSet
(
pSql
);
...
@@ -123,11 +122,9 @@ public class TSDBJNIConnectorTest {
...
@@ -123,11 +122,9 @@ public class TSDBJNIConnectorTest {
connector
.
insertLines
(
lines
,
SchemalessProtocolType
.
LINE
,
SchemalessTimestampType
.
NANO_SECONDS
);
connector
.
insertLines
(
lines
,
SchemalessProtocolType
.
LINE
,
SchemalessTimestampType
.
NANO_SECONDS
);
// close connection
// close connection
connector
.
executeQuery
(
"drop database if exists d"
);
connector
.
executeQuery
(
"drop database if exists d2"
);
connector
.
closeConnection
();
connector
.
closeConnection
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
private
static
boolean
next
(
TSDBJNIConnector
connector
,
long
pSql
)
throws
SQLException
{
private
static
boolean
next
(
TSDBJNIConnector
connector
,
long
pSql
)
throws
SQLException
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java
浏览文件 @
82a64d85
...
@@ -17,6 +17,7 @@ public class TSDBParameterMetaDataTest {
...
@@ -17,6 +17,7 @@ public class TSDBParameterMetaDataTest {
private
static
PreparedStatement
pstmt_select
;
private
static
PreparedStatement
pstmt_select
;
private
static
ParameterMetaData
parameterMetaData_insert
;
private
static
ParameterMetaData
parameterMetaData_insert
;
private
static
ParameterMetaData
parameterMetaData_select
;
private
static
ParameterMetaData
parameterMetaData_select
;
private
static
final
String
dbname
=
"test_pstmt"
;
@Test
@Test
public
void
getParameterCount
()
throws
SQLException
{
public
void
getParameterCount
()
throws
SQLException
{
...
@@ -152,9 +153,9 @@ public class TSDBParameterMetaDataTest {
...
@@ -152,9 +153,9 @@ public class TSDBParameterMetaDataTest {
try
{
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists
test_pstmt"
);
stmt
.
execute
(
"drop database if exists
"
+
dbname
);
stmt
.
execute
(
"create database if not exists
test_pstmt"
);
stmt
.
execute
(
"create database if not exists
"
+
dbname
);
stmt
.
execute
(
"use
test_pstmt"
);
stmt
.
execute
(
"use
"
+
dbname
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"
);
stmt
.
execute
(
"create table t1 using weather tags('beijing')"
);
stmt
.
execute
(
"create table t1 using weather tags('beijing')"
);
}
}
...
@@ -190,8 +191,12 @@ public class TSDBParameterMetaDataTest {
...
@@ -190,8 +191,12 @@ public class TSDBParameterMetaDataTest {
pstmt_insert
.
close
();
pstmt_insert
.
close
();
if
(
pstmt_select
!=
null
)
if
(
pstmt_select
!=
null
)
pstmt_select
.
close
();
pstmt_select
.
close
();
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
浏览文件 @
82a64d85
...
@@ -1233,6 +1233,7 @@ public class TSDBPreparedStatementTest {
...
@@ -1233,6 +1233,7 @@ public class TSDBPreparedStatementTest {
try
{
try
{
Statement
statement
=
conn
.
createStatement
();
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
execute
(
"drop database if exists dbtest"
);
statement
.
close
();
statement
.
close
();
if
(
conn
!=
null
)
if
(
conn
!=
null
)
conn
.
close
();
conn
.
close
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java
浏览文件 @
82a64d85
...
@@ -668,8 +668,12 @@ public class TSDBResultSetTest {
...
@@ -668,8 +668,12 @@ public class TSDBResultSetTest {
rs
.
close
();
rs
.
close
();
if
(
stmt
!=
null
)
if
(
stmt
!=
null
)
stmt
.
close
();
stmt
.
close
();
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists restful_test"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
org.junit.Assert
;
import
org.junit.*
;
import
org.junit.BeforeClass
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
org.junit.runners.MethodSorters
;
import
org.junit.runners.MethodSorters
;
import
java.sql.*
;
import
java.sql.*
;
...
@@ -16,23 +13,24 @@ public class InsertDbwithoutUseDbTest {
...
@@ -16,23 +13,24 @@ public class InsertDbwithoutUseDbTest {
private
static
final
String
host
=
"127.0.0.1"
;
private
static
final
String
host
=
"127.0.0.1"
;
private
static
Properties
properties
;
private
static
Properties
properties
;
private
static
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
static
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
static
final
String
dbname
=
"inWithoutDb"
;
@Test
@Test
public
void
case001
()
throws
SQLException
{
public
void
case001
()
throws
SQLException
{
// prepare schema
// prepare schema
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists inWithoutDb"
);
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
execute
(
"create database if not exists inWithoutDb"
);
stmt
.
execute
(
"create database if not exists "
+
dbname
);
stmt
.
execute
(
"create table inWithoutDb
.weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"create table "
+
dbname
+
"
.weather(ts timestamp, f1 int)"
);
}
conn
.
close
();
conn
.
close
();
// execute insert
// execute insert
url
=
"jdbc:TAOS://127.0.0.1:6030/
inWithoutDb
?user=root&password=taosdata"
;
url
=
"jdbc:TAOS://127.0.0.1:6030/
"
+
dbname
+
"
?user=root&password=taosdata"
;
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
=
conn
.
createStatement
();
int
affectedRow
=
stmt
.
executeUpdate
(
"insert into weather(ts, f1) values(now,"
+
random
.
nextInt
(
100
)
+
")"
);
int
affectedRow
=
stmt
.
executeUpdate
(
"insert into weather(ts, f1) values(now,"
+
random
.
nextInt
(
100
)
+
")"
);
Assert
.
assertEquals
(
1
,
affectedRow
);
Assert
.
assertEquals
(
1
,
affectedRow
);
boolean
flag
=
stmt
.
execute
(
"insert into weather(ts, f1) values(now + 10s,"
+
random
.
nextInt
(
100
)
+
")"
);
boolean
flag
=
stmt
.
execute
(
"insert into weather(ts, f1) values(now + 10s,"
+
random
.
nextInt
(
100
)
+
")"
);
...
@@ -41,11 +39,6 @@ public class InsertDbwithoutUseDbTest {
...
@@ -41,11 +39,6 @@ public class InsertDbwithoutUseDbTest {
rs
.
next
();
rs
.
next
();
int
count
=
rs
.
getInt
(
"count(*)"
);
int
count
=
rs
.
getInt
(
"count(*)"
);
Assert
.
assertEquals
(
2
,
count
);
Assert
.
assertEquals
(
2
,
count
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
conn
.
close
();
conn
.
close
();
}
}
...
@@ -54,16 +47,14 @@ public class InsertDbwithoutUseDbTest {
...
@@ -54,16 +47,14 @@ public class InsertDbwithoutUseDbTest {
// prepare the schema
// prepare the schema
final
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/inWithoutDb?user=root&password=taosdata"
;
final
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/inWithoutDb?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists inWithoutDb"
);
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
execute
(
"create database if not exists inWithoutDb"
);
stmt
.
execute
(
"create database if not exists "
+
dbname
);
stmt
.
execute
(
"create table inWithoutDb.weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"create table "
+
dbname
+
".weather(ts timestamp, f1 int)"
);
}
stmt
.
close
();
conn
.
close
();
// execute
// execute
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
stmt
=
conn
.
createStatement
();
try
(
Statement
stmt
=
conn
.
createStatement
())
{
int
affectedRow
=
stmt
.
executeUpdate
(
"insert into weather(ts, f1) values(now,"
+
random
.
nextInt
(
100
)
+
")"
);
int
affectedRow
=
stmt
.
executeUpdate
(
"insert into weather(ts, f1) values(now,"
+
random
.
nextInt
(
100
)
+
")"
);
Assert
.
assertEquals
(
1
,
affectedRow
);
Assert
.
assertEquals
(
1
,
affectedRow
);
boolean
flag
=
stmt
.
execute
(
"insert into weather(ts, f1) values(now + 10s,"
+
random
.
nextInt
(
100
)
+
")"
);
boolean
flag
=
stmt
.
execute
(
"insert into weather(ts, f1) values(now + 10s,"
+
random
.
nextInt
(
100
)
+
")"
);
...
@@ -72,10 +63,9 @@ public class InsertDbwithoutUseDbTest {
...
@@ -72,10 +63,9 @@ public class InsertDbwithoutUseDbTest {
rs
.
next
();
rs
.
next
();
int
count
=
rs
.
getInt
(
"count(*)"
);
int
count
=
rs
.
getInt
(
"count(*)"
);
Assert
.
assertEquals
(
2
,
count
);
Assert
.
assertEquals
(
2
,
count
);
stmt
.
execute
(
"drop database if exists "
+
dbname
);
}
catch
(
SQLException
e
)
{
stmt
.
close
();
e
.
printStackTrace
();
conn
.
close
();
}
}
}
@BeforeClass
@BeforeClass
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java
浏览文件 @
82a64d85
...
@@ -427,8 +427,12 @@ public class InsertSpecialCharacterJniTest {
...
@@ -427,8 +427,12 @@ public class InsertSpecialCharacterJniTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbName
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java
浏览文件 @
82a64d85
...
@@ -391,8 +391,12 @@ public class InsertSpecialCharacterRestfulTest {
...
@@ -391,8 +391,12 @@ public class InsertSpecialCharacterRestfulTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbName
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
org.junit.AfterClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
public
class
JDBCTypeAndTypeCompareTest
{
public
class
JDBCTypeAndTypeCompareTest
{
private
static
Connection
conn
;
private
static
final
String
dbname
=
"test"
;
@Test
@Test
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://192.168.17.156
:6030/"
,
"root"
,
"taosdata"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://127.0.0.1
:6030/"
,
"root"
,
"taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists
test"
);
stmt
.
execute
(
"drop database if exists
"
+
dbname
);
stmt
.
execute
(
"create database if not exists
test"
);
stmt
.
execute
(
"create database if not exists
"
+
dbname
);
stmt
.
execute
(
"use
test"
);
stmt
.
execute
(
"use
"
+
dbname
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10) )"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10) )"
);
stmt
.
execute
(
"insert into weather values(now, 1, 2, 3.0, 4.0, 5, 6, true, 'test','test')"
);
stmt
.
execute
(
"insert into weather values(now, 1, 2, 3.0, 4.0, 5, 6, true, 'test','test')"
);
...
@@ -29,6 +32,19 @@ public class JDBCTypeAndTypeCompareTest {
...
@@ -29,6 +32,19 @@ public class JDBCTypeAndTypeCompareTest {
}
}
stmt
.
close
();
stmt
.
close
();
}
@AfterClass
public
static
void
afterClass
()
{
try
{
if
(
null
!=
conn
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java
浏览文件 @
82a64d85
...
@@ -47,7 +47,7 @@ public class MicroSecondPrecisionJNITest {
...
@@ -47,7 +47,7 @@ public class MicroSecondPrecisionJNITest {
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
ts
=
rs
.
getLong
(
1
);
ts
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
timestamp
1
,
ts
);
Assert
.
assertEquals
(
timestamp
2
,
ts
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -79,8 +79,13 @@ public class MicroSecondPrecisionJNITest {
...
@@ -79,8 +79,13 @@ public class MicroSecondPrecisionJNITest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
{
public
static
void
afterClass
()
{
try
{
try
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database "
+
ms_timestamp_db
);
statement
.
execute
(
"drop database "
+
us_timestamp_db
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java
浏览文件 @
82a64d85
...
@@ -47,7 +47,7 @@ public class MicroSecondPrecisionRestfulTest {
...
@@ -47,7 +47,7 @@ public class MicroSecondPrecisionRestfulTest {
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
ts
=
rs
.
getLong
(
1
);
ts
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
timestamp
1
,
ts
);
Assert
.
assertEquals
(
timestamp
2
,
ts
);
}
}
}
}
...
@@ -77,7 +77,7 @@ public class MicroSecondPrecisionRestfulTest {
...
@@ -77,7 +77,7 @@ public class MicroSecondPrecisionRestfulTest {
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
ts
=
rs
.
getLong
(
1
);
ts
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
timestamp
1
,
ts
);
Assert
.
assertEquals
(
timestamp
2
,
ts
);
}
}
}
}
...
@@ -107,7 +107,7 @@ public class MicroSecondPrecisionRestfulTest {
...
@@ -107,7 +107,7 @@ public class MicroSecondPrecisionRestfulTest {
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
Assert
.
assertEquals
(
timestamp2
%
1000_000
l
*
1000
,
nanos
);
ts
=
rs
.
getLong
(
1
);
ts
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
timestamp
1
,
ts
);
Assert
.
assertEquals
(
timestamp
2
,
ts
);
}
}
}
}
...
@@ -142,12 +142,21 @@ public class MicroSecondPrecisionRestfulTest {
...
@@ -142,12 +142,21 @@ public class MicroSecondPrecisionRestfulTest {
}
}
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
{
if
(
conn1
!=
null
)
try
{
if
(
conn1
!=
null
)
{
Statement
statement
=
conn1
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
ms_timestamp_db
);
statement
.
execute
(
"drop database if exists "
+
us_timestamp_db
);
statement
.
close
();
conn1
.
close
();
conn1
.
close
();
}
if
(
conn2
!=
null
)
if
(
conn2
!=
null
)
conn2
.
close
();
conn2
.
close
();
if
(
conn3
!=
null
)
if
(
conn3
!=
null
)
conn3
.
close
();
conn3
.
close
();
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -90,4 +91,16 @@ public class MultiConnectionWithDifferentDbTest {
...
@@ -90,4 +91,16 @@ public class MultiConnectionWithDifferentDbTest {
}
}
}
}
@After
public
void
after
()
{
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
;
try
(
Connection
connection
=
DriverManager
.
getConnection
(
url
);
Statement
statement
=
connection
.
createStatement
())
{
statement
.
execute
(
"drop database if exists "
+
db1
);
statement
.
execute
(
"drop database if exists "
+
db2
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
org.junit.Assert
;
import
org.junit.*
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
import
java.time.Instant
;
import
java.time.Instant
;
...
@@ -83,9 +80,9 @@ public class NanoSecondTimestampJNITest {
...
@@ -83,9 +80,9 @@ public class NanoSecondTimestampJNITest {
// then
// then
long
actual
=
rs
.
getLong
(
1
);
long
actual
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
m
s
,
actual
);
Assert
.
assertEquals
(
n
s
,
actual
);
actual
=
rs
.
getLong
(
"ts"
);
actual
=
rs
.
getLong
(
"ts"
);
Assert
.
assertEquals
(
m
s
,
actual
);
Assert
.
assertEquals
(
n
s
,
actual
);
}
}
@Test
@Test
...
@@ -160,4 +157,18 @@ public class NanoSecondTimestampJNITest {
...
@@ -160,4 +157,18 @@ public class NanoSecondTimestampJNITest {
}
}
}
}
@AfterClass
public
static
void
afterClass
(){
try
{
if
(
null
!=
conn
){
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
){
e
.
printStackTrace
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
org.junit.Assert
;
import
org.junit.*
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
import
java.time.Instant
;
import
java.time.Instant
;
...
@@ -83,9 +80,9 @@ public class NanoSecondTimestampRestfulTest {
...
@@ -83,9 +80,9 @@ public class NanoSecondTimestampRestfulTest {
// then
// then
long
actual
=
rs
.
getLong
(
1
);
long
actual
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
m
s
,
actual
);
Assert
.
assertEquals
(
n
s
,
actual
);
actual
=
rs
.
getLong
(
"ts"
);
actual
=
rs
.
getLong
(
"ts"
);
Assert
.
assertEquals
(
m
s
,
actual
);
Assert
.
assertEquals
(
n
s
,
actual
);
}
}
@Test
@Test
...
@@ -160,4 +157,14 @@ public class NanoSecondTimestampRestfulTest {
...
@@ -160,4 +157,14 @@ public class NanoSecondTimestampRestfulTest {
}
}
}
}
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
){
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists "
+
dbname
);
}
conn
.
close
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java
浏览文件 @
82a64d85
...
@@ -45,7 +45,11 @@ public class NullValueInResultSetJNITest {
...
@@ -45,7 +45,11 @@ public class NullValueInResultSetJNITest {
@After
@After
public
void
after
()
throws
SQLException
{
public
void
after
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists test_null"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java
浏览文件 @
82a64d85
...
@@ -47,7 +47,11 @@ public class NullValueInResultSetRestfulTest {
...
@@ -47,7 +47,11 @@ public class NullValueInResultSetRestfulTest {
@After
@After
public
void
after
()
throws
SQLException
{
public
void
after
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists test_null"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java
浏览文件 @
82a64d85
...
@@ -85,7 +85,11 @@ public class NullValueInResultSetTest {
...
@@ -85,7 +85,11 @@ public class NullValueInResultSetTest {
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn_restful
!=
null
)
if
(
conn_restful
!=
null
)
conn_restful
.
close
();
conn_restful
.
close
();
if
(
conn_jni
!=
null
)
if
(
conn_jni
!=
null
)
{
Statement
statement
=
conn_jni
.
createStatement
();
statement
.
execute
(
"drop database if exists test_null"
);
statement
.
close
();
conn_jni
.
close
();
conn_jni
.
close
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java
浏览文件 @
82a64d85
...
@@ -62,8 +62,12 @@ public class TimestampPrecisionInNanoInJniTest {
...
@@ -62,8 +62,12 @@ public class TimestampPrecisionInNanoInJniTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
{
public
static
void
afterClass
()
{
try
{
try
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
ns_timestamp_db
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -83,7 +87,7 @@ public class TimestampPrecisionInNanoInJniTest {
...
@@ -83,7 +87,7 @@ public class TimestampPrecisionInNanoInJniTest {
int
nanos
=
rs
.
getTimestamp
(
1
).
getNanos
();
int
nanos
=
rs
.
getTimestamp
(
1
).
getNanos
();
Assert
.
assertEquals
(
ts
%
1000_000_000
l
,
nanos
);
Assert
.
assertEquals
(
ts
%
1000_000_000
l
,
nanos
);
long
test_ts
=
rs
.
getLong
(
1
);
long
test_ts
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
ts
/
1000_000
l
,
test_ts
);
Assert
.
assertEquals
(
ts
,
test_ts
);
}
}
@Test
@Test
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java
浏览文件 @
82a64d85
...
@@ -62,8 +62,12 @@ public class TimestampPrecisonInNanoRestTest {
...
@@ -62,8 +62,12 @@ public class TimestampPrecisonInNanoRestTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
{
public
static
void
afterClass
()
{
try
{
try
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
ns_timestamp_db
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -83,7 +87,7 @@ public class TimestampPrecisonInNanoRestTest {
...
@@ -83,7 +87,7 @@ public class TimestampPrecisonInNanoRestTest {
int
nanos
=
rs
.
getTimestamp
(
1
).
getNanos
();
int
nanos
=
rs
.
getTimestamp
(
1
).
getNanos
();
Assert
.
assertEquals
(
ts
%
1000_000_000
l
,
nanos
);
Assert
.
assertEquals
(
ts
%
1000_000_000
l
,
nanos
);
long
test_ts
=
rs
.
getLong
(
1
);
long
test_ts
=
rs
.
getLong
(
1
);
Assert
.
assertEquals
(
ts
/
1000_000
l
,
test_ts
);
Assert
.
assertEquals
(
ts
,
test_ts
);
}
}
@Test
@Test
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java
浏览文件 @
82a64d85
...
@@ -156,8 +156,12 @@ public class UnsignedNumberJniTest {
...
@@ -156,8 +156,12 @@ public class UnsignedNumberJniTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists unsign_jni"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java
浏览文件 @
82a64d85
...
@@ -14,6 +14,7 @@ public class UnsignedNumberRestfulTest {
...
@@ -14,6 +14,7 @@ public class UnsignedNumberRestfulTest {
private
static
final
String
host
=
"127.0.0.1"
;
private
static
final
String
host
=
"127.0.0.1"
;
private
static
Connection
conn
;
private
static
Connection
conn
;
private
static
long
ts
;
private
static
long
ts
;
private
static
final
String
dbname
=
"unsign_restful"
;
@Test
@Test
public
void
testCase001
()
throws
SQLException
{
public
void
testCase001
()
throws
SQLException
{
...
@@ -148,9 +149,9 @@ public class UnsignedNumberRestfulTest {
...
@@ -148,9 +149,9 @@ public class UnsignedNumberRestfulTest {
final
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
;
final
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
;
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
Statement
stmt
=
conn
.
createStatement
();
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists
unsign_restful"
);
stmt
.
execute
(
"drop database if exists
"
+
dbname
);
stmt
.
execute
(
"create database if not exists
unsign_restful"
);
stmt
.
execute
(
"create database if not exists
"
+
dbname
);
stmt
.
execute
(
"use
unsign_restful"
);
stmt
.
execute
(
"use
"
+
dbname
);
stmt
.
execute
(
"create table us_table(ts timestamp, f1 tinyint unsigned, f2 smallint unsigned, f3 int unsigned, f4 bigint unsigned)"
);
stmt
.
execute
(
"create table us_table(ts timestamp, f1 tinyint unsigned, f2 smallint unsigned, f3 int unsigned, f4 bigint unsigned)"
);
stmt
.
executeUpdate
(
"insert into us_table(ts,f1,f2,f3,f4) values("
+
ts
+
", 127, 32767,2147483647, 9223372036854775807)"
);
stmt
.
executeUpdate
(
"insert into us_table(ts,f1,f2,f3,f4) values("
+
ts
+
", 127, 32767,2147483647, 9223372036854775807)"
);
stmt
.
close
();
stmt
.
close
();
...
@@ -162,8 +163,12 @@ public class UnsignedNumberRestfulTest {
...
@@ -162,8 +163,12 @@ public class UnsignedNumberRestfulTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
{
public
static
void
afterClass
()
{
try
{
try
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
org.junit.AfterClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
...
@@ -8,7 +9,7 @@ import static org.junit.Assert.assertEquals;
...
@@ -8,7 +9,7 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
UseNowInsertTimestampTest
{
public
class
UseNowInsertTimestampTest
{
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
private
static
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
@Test
@Test
public
void
millisec
()
throws
SQLException
{
public
void
millisec
()
throws
SQLException
{
...
@@ -55,13 +56,14 @@ public class UseNowInsertTimestampTest {
...
@@ -55,13 +56,14 @@ public class UseNowInsertTimestampTest {
@Test
@Test
public
void
nanosec
()
throws
SQLException
{
public
void
nanosec
()
throws
SQLException
{
long
now_time
=
System
.
currentTimeMillis
()
*
1000_000L
+
System
.
nanoTime
()
%
1000_000L
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
))
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
))
{
Statement
stmt
=
conn
.
createStatement
();
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"create database if not exists test precision 'ns'"
);
stmt
.
execute
(
"create database if not exists test precision 'ns'"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"insert into weather values(
now
, 1)"
);
stmt
.
execute
(
"insert into weather values(
"
+
now_time
+
"
, 1)"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
rs
.
next
();
rs
.
next
();
...
@@ -74,4 +76,15 @@ public class UseNowInsertTimestampTest {
...
@@ -74,4 +76,15 @@ public class UseNowInsertTimestampTest {
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"drop database if exists test"
);
}
}
}
}
@AfterClass
public
static
void
afterClass
()
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
);
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists test"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java
浏览文件 @
82a64d85
...
@@ -45,7 +45,11 @@ public class BadLocaleSettingTest {
...
@@ -45,7 +45,11 @@ public class BadLocaleSettingTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database "
+
dbName
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java
浏览文件 @
82a64d85
...
@@ -79,4 +79,15 @@ public class BatchFetchTest {
...
@@ -79,4 +79,15 @@ public class BatchFetchTest {
}
}
return
builder
.
toString
();
return
builder
.
toString
();
}
}
@AfterClass
public
static
void
afterClass
(){
String
url
=
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
);
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists test"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/CharsetTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.confprops
;
package
com.taosdata.jdbc.confprops
;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBDriver
;
import
org.junit.AfterClass
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -37,4 +38,18 @@ public class CharsetTest {
...
@@ -37,4 +38,18 @@ public class CharsetTest {
}
}
}
}
@AfterClass
public
static
void
afterClass
(){
String
url
=
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
;
Properties
props
=
new
Properties
();
props
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
,
props
);
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists test"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java
浏览文件 @
82a64d85
...
@@ -29,7 +29,7 @@ public class TimeZoneTest {
...
@@ -29,7 +29,7 @@ public class TimeZoneTest {
}
}
@Test
@Test
public
void
taosTimeZone
()
{
public
void
taosTimeZone
()
throws
SQLException
{
// given
// given
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
props
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
props
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
@@ -39,7 +39,7 @@ public class TimeZoneTest {
...
@@ -39,7 +39,7 @@ public class TimeZoneTest {
Statement
stmt
=
connection
.
createStatement
();
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists timezone_test"
);
stmt
.
execute
(
"drop database if exists timezone_test"
);
stmt
.
execute
(
"create database if not exists timezone_test keep 36500
0
"
);
stmt
.
execute
(
"create database if not exists timezone_test keep 36500"
);
stmt
.
execute
(
"use timezone_test"
);
stmt
.
execute
(
"use timezone_test"
);
stmt
.
execute
(
"create table weather(ts timestamp, temperature float)"
);
stmt
.
execute
(
"create table weather(ts timestamp, temperature float)"
);
...
@@ -51,7 +51,7 @@ public class TimeZoneTest {
...
@@ -51,7 +51,7 @@ public class TimeZoneTest {
System
.
out
.
println
(
"ts: "
+
ts
.
getTime
()
+
","
+
ts
);
System
.
out
.
println
(
"ts: "
+
ts
.
getTime
()
+
","
+
ts
);
}
}
stmt
.
execute
(
"insert into timezone_test.weather(ts, temperature
, humidity) values('1970-01-02 00:00:00', 1.0, 2
.0)"
);
stmt
.
execute
(
"insert into timezone_test.weather(ts, temperature
) values('1970-01-02 00:00:00', 1
.0)"
);
rs
=
stmt
.
executeQuery
(
"select * from timezone_test.weather"
);
rs
=
stmt
.
executeQuery
(
"select * from timezone_test.weather"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
...
@@ -63,8 +63,6 @@ public class TimeZoneTest {
...
@@ -63,8 +63,6 @@ public class TimeZoneTest {
stmt
.
execute
(
"drop database if exists timezone_test"
);
stmt
.
execute
(
"drop database if exists timezone_test"
);
stmt
.
close
();
stmt
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimestampFormatTest.java
浏览文件 @
82a64d85
package
com.taosdata.jdbc.confprops
;
package
com.taosdata.jdbc.confprops
;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBDriver
;
import
org.junit.Assert
;
import
org.junit.*
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.util.Calendar
;
import
java.util.Properties
;
import
java.util.Properties
;
public
class
TimestampFormatTest
{
public
class
TimestampFormatTest
{
private
static
final
String
host
=
"127.0.0.1"
;
private
static
final
String
host
=
"127.0.0.1"
;
private
long
ts
=
Instant
.
now
().
toEpochMilli
();
private
long
ts
=
Instant
.
now
().
toEpochMilli
();
private
Connection
conn
;
@Test
@Test
public
void
string
()
throws
SQLException
{
public
void
string
()
throws
SQLException
{
...
@@ -154,13 +154,27 @@ public class TimestampFormatTest {
...
@@ -154,13 +154,27 @@ public class TimestampFormatTest {
@Before
@Before
public
void
before
()
throws
SQLException
{
public
void
before
()
throws
SQLException
{
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
;
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
;
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
);
conn
=
DriverManager
.
getConnection
(
url
);
Statement
stmt
=
conn
.
createStatement
())
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"create database if not exists test"
);
stmt
.
execute
(
"create database if not exists test"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"create table weather(ts timestamp, temperature nchar(10))"
);
stmt
.
execute
(
"create table weather(ts timestamp, temperature nchar(10))"
);
stmt
.
execute
(
"insert into weather values("
+
ts
+
", '北京')"
);
stmt
.
execute
(
"insert into weather values("
+
ts
+
", '北京')"
);
stmt
.
close
();
}
@After
public
void
after
()
{
try
{
if
(
null
!=
conn
)
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java
浏览文件 @
82a64d85
...
@@ -33,7 +33,6 @@ public class DatabaseSpecifiedTest {
...
@@ -33,7 +33,6 @@ public class DatabaseSpecifiedTest {
String
loc
=
rs
.
getString
(
"loc"
);
String
loc
=
rs
.
getString
(
"loc"
);
assertEquals
(
"beijing"
,
loc
);
assertEquals
(
"beijing"
,
loc
);
}
}
connection
.
close
();
}
}
@Before
@Before
...
@@ -59,8 +58,12 @@ public class DatabaseSpecifiedTest {
...
@@ -59,8 +58,12 @@ public class DatabaseSpecifiedTest {
@After
@After
public
void
after
()
{
public
void
after
()
{
try
{
try
{
if
(
connection
!=
null
)
if
(
connection
!=
null
)
{
Statement
statement
=
connection
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
connection
.
close
();
connection
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
浏览文件 @
82a64d85
...
@@ -383,8 +383,12 @@ public class RestfulConnectionTest {
...
@@ -383,8 +383,12 @@ public class RestfulConnectionTest {
@AfterClass
@AfterClass
public
static
void
afterClass
()
throws
SQLException
{
public
static
void
afterClass
()
throws
SQLException
{
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists test"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java
浏览文件 @
82a64d85
...
@@ -18,6 +18,7 @@ public class RestfulParameterMetaDataTest {
...
@@ -18,6 +18,7 @@ public class RestfulParameterMetaDataTest {
private
static
PreparedStatement
pstmt_select
;
private
static
PreparedStatement
pstmt_select
;
private
static
ParameterMetaData
parameterMetaData_insert
;
private
static
ParameterMetaData
parameterMetaData_insert
;
private
static
ParameterMetaData
parameterMetaData_select
;
private
static
ParameterMetaData
parameterMetaData_select
;
private
static
final
String
dbname
=
"test_pstmt"
;
@Test
@Test
public
void
getParameterCount
()
throws
SQLException
{
public
void
getParameterCount
()
throws
SQLException
{
...
@@ -148,9 +149,9 @@ public class RestfulParameterMetaDataTest {
...
@@ -148,9 +149,9 @@ public class RestfulParameterMetaDataTest {
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"drop database if exists
test_pstmt"
);
stmt
.
execute
(
"drop database if exists
"
+
dbname
);
stmt
.
execute
(
"create database if not exists
test_pstmt"
);
stmt
.
execute
(
"create database if not exists
"
+
dbname
);
stmt
.
execute
(
"use
test_pstmt"
);
stmt
.
execute
(
"use
"
+
dbname
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"
);
stmt
.
execute
(
"create table t1 using weather tags('beijing')"
);
stmt
.
execute
(
"create table t1 using weather tags('beijing')"
);
}
}
...
@@ -186,8 +187,12 @@ public class RestfulParameterMetaDataTest {
...
@@ -186,8 +187,12 @@ public class RestfulParameterMetaDataTest {
pstmt_insert
.
close
();
pstmt_insert
.
close
();
if
(
pstmt_select
!=
null
)
if
(
pstmt_select
!=
null
)
pstmt_select
.
close
();
pstmt_select
.
close
();
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java
浏览文件 @
82a64d85
...
@@ -400,8 +400,12 @@ public class RestfulPreparedStatementTest {
...
@@ -400,8 +400,12 @@ public class RestfulPreparedStatementTest {
pstmt_select
.
close
();
pstmt_select
.
close
();
if
(
pstmt_without_parameters
!=
null
)
if
(
pstmt_without_parameters
!=
null
)
pstmt_without_parameters
.
close
();
pstmt_without_parameters
.
close
();
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists test_pstmt"
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
浏览文件 @
82a64d85
...
@@ -15,6 +15,7 @@ public class RestfulResultSetMetaDataTest {
...
@@ -15,6 +15,7 @@ public class RestfulResultSetMetaDataTest {
private
static
Statement
stmt
;
private
static
Statement
stmt
;
private
static
ResultSet
rs
;
private
static
ResultSet
rs
;
private
static
ResultSetMetaData
meta
;
private
static
ResultSetMetaData
meta
;
private
static
final
String
dbname
=
"restful_test"
;
@Test
@Test
public
void
getColumnCount
()
throws
SQLException
{
public
void
getColumnCount
()
throws
SQLException
{
...
@@ -206,8 +207,12 @@ public class RestfulResultSetMetaDataTest {
...
@@ -206,8 +207,12 @@ public class RestfulResultSetMetaDataTest {
rs
.
close
();
rs
.
close
();
if
(
stmt
!=
null
)
if
(
stmt
!=
null
)
stmt
.
close
();
stmt
.
close
();
if
(
conn
!=
null
)
if
(
conn
!=
null
)
{
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"drop database if exists "
+
dbname
);
statement
.
close
();
conn
.
close
();
conn
.
close
();
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
82a64d85
...
@@ -1003,6 +1003,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
...
@@ -1003,6 +1003,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
newCfg
.
daysToKeep0
=
daysToKeep0
;
newCfg
.
daysToKeep0
=
daysToKeep0
;
}
}
#ifdef _STORAGE
if
(
daysToKeep1
>
0
&&
(
daysToKeep1
!=
pDb
->
cfg
.
daysToKeep1
||
newCfg
.
daysToKeep1
!=
pDb
->
cfg
.
daysToKeep1
))
{
if
(
daysToKeep1
>
0
&&
(
daysToKeep1
!=
pDb
->
cfg
.
daysToKeep1
||
newCfg
.
daysToKeep1
!=
pDb
->
cfg
.
daysToKeep1
))
{
mDebug
(
"db:%s, daysToKeep1:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
daysToKeep1
,
daysToKeep1
);
mDebug
(
"db:%s, daysToKeep1:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
daysToKeep1
,
daysToKeep1
);
newCfg
.
daysToKeep1
=
daysToKeep1
;
newCfg
.
daysToKeep1
=
daysToKeep1
;
...
@@ -1012,6 +1013,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
...
@@ -1012,6 +1013,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
mDebug
(
"db:%s, daysToKeep2:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
daysToKeep2
,
daysToKeep2
);
mDebug
(
"db:%s, daysToKeep2:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
daysToKeep2
,
daysToKeep2
);
newCfg
.
daysToKeep2
=
daysToKeep2
;
newCfg
.
daysToKeep2
=
daysToKeep2
;
}
}
#endif
if
(
minRows
>
0
&&
minRows
!=
pDb
->
cfg
.
minRowsPerFileBlock
)
{
if
(
minRows
>
0
&&
minRows
!=
pDb
->
cfg
.
minRowsPerFileBlock
)
{
mError
(
"db:%s, can't alter minRows option"
,
pDb
->
name
);
mError
(
"db:%s, can't alter minRows option"
,
pDb
->
name
);
...
@@ -1100,6 +1102,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
...
@@ -1100,6 +1102,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
// community version can only change daysToKeep
// community version can only change daysToKeep
// but enterprise version can change all daysToKeep options
// but enterprise version can change all daysToKeep options
#ifndef _STORAGE
#ifndef _STORAGE
newCfg
.
daysToKeep1
=
newCfg
.
daysToKeep0
;
newCfg
.
daysToKeep1
=
newCfg
.
daysToKeep0
;
newCfg
.
daysToKeep2
=
newCfg
.
daysToKeep0
;
newCfg
.
daysToKeep2
=
newCfg
.
daysToKeep0
;
...
...
src/util/src/tnettest.c
浏览文件 @
82a64d85
...
@@ -356,7 +356,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
...
@@ -356,7 +356,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
epSet
.
inUse
=
0
;
epSet
.
inUse
=
0
;
epSet
.
numOfEps
=
1
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
epSet
.
port
[
0
]
=
port
;
strcpy
(
epSet
.
fqdn
[
0
],
serverFqdn
);
tstrncpy
(
epSet
.
fqdn
[
0
],
serverFqdn
,
sizeof
(
epSet
.
fqdn
[
0
])
);
reqMsg
.
msgType
=
TSDB_MSG_TYPE_NETWORK_TEST
;
reqMsg
.
msgType
=
TSDB_MSG_TYPE_NETWORK_TEST
;
reqMsg
.
pCont
=
rpcMallocCont
(
pktLen
);
reqMsg
.
pCont
=
rpcMallocCont
(
pktLen
);
...
@@ -364,7 +364,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
...
@@ -364,7 +364,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
reqMsg
.
code
=
0
;
reqMsg
.
code
=
0
;
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
strcpy
(
reqMsg
.
pCont
,
"nettest"
);
tstrncpy
((
char
*
)
reqMsg
.
pCont
,
"nettest"
,
pktLen
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
...
@@ -606,7 +606,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
...
@@ -606,7 +606,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
epSet
.
inUse
=
0
;
epSet
.
inUse
=
0
;
epSet
.
numOfEps
=
1
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
epSet
.
port
[
0
]
=
port
;
strcpy
(
epSet
.
fqdn
[
0
],
host
);
tstrncpy
(
epSet
.
fqdn
[
0
],
host
,
sizeof
(
epSet
.
fqdn
[
0
])
);
reqMsg
.
msgType
=
TSDB_MSG_TYPE_NETWORK_TEST
;
reqMsg
.
msgType
=
TSDB_MSG_TYPE_NETWORK_TEST
;
reqMsg
.
pCont
=
rpcMallocCont
(
pkgLen
);
reqMsg
.
pCont
=
rpcMallocCont
(
pkgLen
);
...
@@ -614,7 +614,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
...
@@ -614,7 +614,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
reqMsg
.
code
=
0
;
reqMsg
.
code
=
0
;
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
strcpy
(
reqMsg
.
pCont
,
"nettest speed"
);
tstrncpy
((
char
*
)
reqMsg
.
pCont
,
"nettest speed"
,
pkgLen
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
...
...
tests/pytest/tools/taosdemoTestTblAlt.py
浏览文件 @
82a64d85
...
@@ -30,6 +30,7 @@ class TDTestCase:
...
@@ -30,6 +30,7 @@ class TDTestCase:
self
.
numberOfRecords
=
1000000
self
.
numberOfRecords
=
1000000
def
getBuildPath
(
self
):
def
getBuildPath
(
self
):
buildPath
=
""
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
if
(
"community"
in
selfPath
):
...
@@ -38,7 +39,7 @@ class TDTestCase:
...
@@ -38,7 +39,7 @@ class TDTestCase:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
if
(
"taosd"
in
files
and
"taosBenchmark"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
...
@@ -48,7 +49,7 @@ class TDTestCase:
...
@@ -48,7 +49,7 @@ class TDTestCase:
def
insertDataAndAlterTable
(
self
,
threadID
):
def
insertDataAndAlterTable
(
self
,
threadID
):
buildPath
=
self
.
getBuildPath
()
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
if
(
buildPath
==
""
):
tdLog
.
exit
(
"taosd not found!"
)
tdLog
.
exit
(
"taosd
or staosBenchmark
not found!"
)
else
:
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
binPath
=
buildPath
+
"/build/bin/"
binPath
=
buildPath
+
"/build/bin/"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录