Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9167cf93
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9167cf93
编写于
1月 21, 2021
作者:
H
huili
提交者:
GitHub
1月 21, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4966 from taosdata/hotfix/TD-2794
Hotfix/td 2794
上级
4799515a
e58c3209
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
90 addition
and
161 deletion
+90
-161
cmake/install.inc
cmake/install.inc
+1
-1
src/connector/jdbc/CMakeLists.txt
src/connector/jdbc/CMakeLists.txt
+1
-1
src/connector/jdbc/deploy-pom.xml
src/connector/jdbc/deploy-pom.xml
+1
-1
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
...dbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
+0
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java
.../src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java
+0
-51
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
...src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
+2
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java
...rc/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java
+0
-75
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java
...rc/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java
+0
-19
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
...dbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+2
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java
...in/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java
+3
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
...test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
+1
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
...rc/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
+66
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
...src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
+6
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
...c/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
+2
-2
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
.../java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
+1
-0
tests/examples/JDBC/taosdemo/pom.xml
tests/examples/JDBC/taosdemo/pom.xml
+3
-3
未找到文件。
cmake/install.inc
浏览文件 @
9167cf93
...
...
@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF
(
TD_MVN_INSTALLED
)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
-
jdbcdriver
-
2.0.1
6
-
dist
.
jar
DESTINATION
connector
/
jdbc
)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
-
jdbcdriver
-
2.0.1
7
-
dist
.
jar
DESTINATION
connector
/
jdbc
)
ENDIF
()
ELSEIF
(
TD_DARWIN
)
SET
(
TD_MAKE_INSTALL_SH
"${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh"
)
...
...
src/connector/jdbc/CMakeLists.txt
浏览文件 @
9167cf93
...
...
@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
JDBC_CMD_NAME
}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f
${
CMAKE_CURRENT_SOURCE_DIR
}
/pom.xml
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/target/taos-jdbcdriver-2.0.1
6
-dist.jar
${
LIBRARY_OUTPUT_PATH
}
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/target/taos-jdbcdriver-2.0.1
7
-dist.jar
${
LIBRARY_OUTPUT_PATH
}
COMMAND mvn -Dmaven.test.skip=true clean -f
${
CMAKE_CURRENT_SOURCE_DIR
}
/pom.xml
COMMENT
"build jdbc driver"
)
ADD_CUSTOM_TARGET
(
${
JDBC_TARGET_NAME
}
ALL WORKING_DIRECTORY
${
EXECUTABLE_OUTPUT_PATH
}
DEPENDS
${
JDBC_CMD_NAME
}
)
...
...
src/connector/jdbc/deploy-pom.xml
浏览文件 @
9167cf93
...
...
@@ -5,7 +5,7 @@
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
6
</version>
<version>
2.0.1
7
</version>
<packaging>
jar
</packaging>
<name>
JDBCDriver
</name>
...
...
src/connector/jdbc/pom.xml
浏览文件 @
9167cf93
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
6
</version>
<version>
2.0.1
7
</version>
<packaging>
jar
</packaging>
<name>
JDBCDriver
</name>
<url>
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
</url>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java
浏览文件 @
9167cf93
...
...
@@ -24,7 +24,6 @@ import java.sql.SQLException;
*/
public
class
CatalogResultSet
extends
TSDBResultSetWrapper
{
public
CatalogResultSet
(
ResultSet
resultSet
)
{
super
.
setOriginalResultSet
(
resultSet
);
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java
已删除
100644 → 0
浏览文件 @
4799515a
/***************************************************************************
* 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
;
/*
* 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
GetColumnsResultSet
extends
TSDBResultSetWrapper
{
private
String
catalog
;
private
String
schemaPattern
;
private
String
tableNamePattern
;
private
String
columnNamePattern
;
public
GetColumnsResultSet
(
ResultSet
resultSet
,
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
columnNamePattern
)
{
super
.
setOriginalResultSet
(
resultSet
);
this
.
catalog
=
catalog
;
this
.
schemaPattern
=
schemaPattern
;
this
.
tableNamePattern
=
tableNamePattern
;
this
.
columnNamePattern
=
columnNamePattern
;
}
@Override
public
String
getString
(
int
columnIndex
)
{
switch
(
columnIndex
)
{
case
1
:
return
catalog
;
case
2
:
return
null
;
case
3
:
return
tableNamePattern
;
default
:
return
null
;
}
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
浏览文件 @
9167cf93
...
...
@@ -620,6 +620,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
ResultSet
tables
=
stmt
.
executeQuery
(
"show tables"
);
while
(
tables
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
rowData
.
setString
(
0
,
dbname
);
rowData
.
setString
(
2
,
tables
.
getString
(
"table_name"
));
rowData
.
setString
(
3
,
"TABLE"
);
rowData
.
setString
(
4
,
""
);
...
...
@@ -629,6 +630,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
ResultSet
stables
=
stmt
.
executeQuery
(
"show stables"
);
while
(
stables
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
rowData
.
setString
(
0
,
dbname
);
rowData
.
setString
(
2
,
stables
.
getString
(
"name"
));
rowData
.
setString
(
3
,
"TABLE"
);
rowData
.
setString
(
4
,
"STABLE"
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java
已删除
100644 → 0
浏览文件 @
4799515a
/***************************************************************************
* 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.ParameterMetaData
;
import
java.sql.SQLException
;
public
class
TSDBParameterMetaData
implements
ParameterMetaData
{
@Override
public
int
getParameterCount
()
throws
SQLException
{
return
0
;
}
@Override
public
int
isNullable
(
int
param
)
throws
SQLException
{
return
0
;
}
@Override
public
boolean
isSigned
(
int
param
)
throws
SQLException
{
return
false
;
}
@Override
public
int
getPrecision
(
int
param
)
throws
SQLException
{
return
0
;
}
@Override
public
int
getScale
(
int
param
)
throws
SQLException
{
return
0
;
}
@Override
public
int
getParameterType
(
int
param
)
throws
SQLException
{
return
0
;
}
@Override
public
String
getParameterTypeName
(
int
param
)
throws
SQLException
{
return
null
;
}
@Override
public
String
getParameterClassName
(
int
param
)
throws
SQLException
{
return
null
;
}
@Override
public
int
getParameterMode
(
int
param
)
throws
SQLException
{
return
0
;
}
@Override
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
return
null
;
}
@Override
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
return
false
;
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java
已删除
100644 → 0
浏览文件 @
4799515a
/***************************************************************************
* 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
;
public
interface
TSDBSubscribeCallBack
{
void
invoke
(
TSDBResultSet
resultSet
);
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
浏览文件 @
9167cf93
...
...
@@ -44,6 +44,8 @@ public class RestfulDriver extends AbstractTaosDriver {
String
result
=
HttpClientPoolUtil
.
execute
(
loginUrl
);
JSONObject
jsonResult
=
JSON
.
parseObject
(
result
);
String
status
=
jsonResult
.
getString
(
"status"
);
String
token
=
jsonResult
.
getString
(
"desc"
);
HttpClientPoolUtil
.
token
=
token
;
if
(!
status
.
equals
(
"succ"
))
{
throw
new
SQLException
(
jsonResult
.
getString
(
"desc"
));
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java
浏览文件 @
9167cf93
...
...
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
public
class
HttpClientPoolUtil
{
public
static
PoolingHttpClientConnectionManager
cm
=
null
;
public
static
CloseableHttpClient
httpClient
=
null
;
public
static
String
token
=
"cm9vdDp0YW9zZGF0YQ=="
;
/**
* 默认content 类型
*/
...
...
@@ -61,9 +62,7 @@ public class HttpClientPoolUtil {
try
{
return
Long
.
parseLong
(
value
)
*
1000
;
}
catch
(
Exception
e
)
{
new
Exception
(
"format KeepAlive timeout exception, exception:"
+
e
.
toString
())
.
printStackTrace
();
new
Exception
(
"format KeepAlive timeout exception, exception:"
+
e
.
toString
()).
printStackTrace
();
}
}
}
...
...
@@ -96,7 +95,7 @@ public class HttpClientPoolUtil {
initPools
();
}
method
=
(
HttpEntityEnclosingRequestBase
)
getRequest
(
uri
,
HttpPost
.
METHOD_NAME
,
DEFAULT_CONTENT_TYPE
,
0
);
method
.
setHeader
(
"Authorization"
,
"
Basic cm9vdDp0YW9zZGF0YQ=="
);
method
.
setHeader
(
"Authorization"
,
"
Taosd "
+
token
);
method
.
setHeader
(
"Content-Type"
,
"text/plain"
);
method
.
setEntity
(
new
StringEntity
(
data
,
Charset
.
forName
(
"UTF-8"
)));
HttpContext
context
=
HttpClientContext
.
create
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
浏览文件 @
9167cf93
...
...
@@ -642,6 +642,7 @@ public class TSDBDatabaseMetaDataTest {
ResultSet
tables
=
metaData
.
getTables
(
"log"
,
""
,
null
,
null
);
ResultSetMetaData
metaData
=
tables
.
getMetaData
();
while
(
tables
.
next
())
{
System
.
out
.
print
(
metaData
.
getColumnLabel
(
1
)
+
":"
+
tables
.
getString
(
1
)
+
"\t"
);
System
.
out
.
print
(
metaData
.
getColumnLabel
(
3
)
+
":"
+
tables
.
getString
(
3
)
+
"\t"
);
System
.
out
.
print
(
metaData
.
getColumnLabel
(
4
)
+
":"
+
tables
.
getString
(
4
)
+
"\t"
);
System
.
out
.
print
(
metaData
.
getColumnLabel
(
5
)
+
":"
+
tables
.
getString
(
5
)
+
"\n"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java
0 → 100644
浏览文件 @
9167cf93
package
com.taosdata.jdbc.rs
;
import
org.junit.Before
;
import
org.junit.Test
;
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
user
=
"root"
;
private
static
final
String
password
=
"123456"
;
private
Connection
conn
;
@Test
public
void
test
()
{
// change password
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass '"
+
password
+
"'"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
// use new to login and execute query
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password="
+
password
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"show databases"
);
ResultSet
rs
=
stmt
.
getResultSet
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
":"
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
// change password back
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password="
+
password
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass 'taosdata'"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Before
public
void
before
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
浏览文件 @
9167cf93
...
...
@@ -6,6 +6,7 @@ import org.junit.Test;
import
java.sql.*
;
public
class
RestfulDriverTest
{
private
static
final
String
host
=
"master"
;
@Test
public
void
connect
()
{
...
...
@@ -15,9 +16,9 @@ public class RestfulDriverTest {
@Test
public
void
acceptsURL
()
throws
SQLException
{
Driver
driver
=
new
RestfulDriver
();
boolean
isAccept
=
driver
.
acceptsURL
(
"jdbc:TAOS-RS://
master
:6041"
);
boolean
isAccept
=
driver
.
acceptsURL
(
"jdbc:TAOS-RS://
"
+
host
+
"
:6041"
);
Assert
.
assertTrue
(
isAccept
);
isAccept
=
driver
.
acceptsURL
(
"jdbc:TAOS://
master
:6041"
);
isAccept
=
driver
.
acceptsURL
(
"jdbc:TAOS://
"
+
host
+
"
:6041"
);
Assert
.
assertFalse
(
isAccept
);
}
...
...
@@ -26,6 +27,9 @@ public class RestfulDriverTest {
Driver
driver
=
new
RestfulDriver
();
final
String
url
=
""
;
DriverPropertyInfo
[]
propertyInfo
=
driver
.
getPropertyInfo
(
url
,
null
);
for
(
DriverPropertyInfo
prop
:
propertyInfo
)
{
System
.
out
.
println
(
prop
);
}
}
@Test
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
浏览文件 @
9167cf93
package
com.taosdata.jdbc.rs
;
import
org.junit.*
;
import
org.junit.runners.MethodSorters
;
...
...
@@ -10,12 +9,13 @@ import java.util.Random;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
RestfulJDBCTest
{
private
static
final
String
host
=
"master"
;
private
Connection
connection
;
@Before
public
void
before
()
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://
master
:6041/restful_test?user=root&password=taosdata"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://
"
+
host
+
"
:6041/restful_test?user=root&password=taosdata"
);
}
@After
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
浏览文件 @
9167cf93
...
...
@@ -21,4 +21,5 @@ public class SqlSyntaxValidatorTest {
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isUseSql
(
"drop database test"
));
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isUseSql
(
"drop database if exist test"
));
}
}
\ No newline at end of file
tests/examples/JDBC/taosdemo/pom.xml
浏览文件 @
9167cf93
...
...
@@ -67,9 +67,9 @@
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
6
</version>
<!--
<scope>system</scope>-->
<!--
<systemPath>${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar</systemPath>-->
<version>
2.0.1
7
</version>
<!--
<scope>system</scope>-->
<!--
<systemPath>${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar</systemPath>-->
</dependency>
<!-- fastjson -->
<dependency>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录