Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a7c5785d
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看板
提交
a7c5785d
编写于
11月 29, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some problem in jdbc
上级
94af9fb1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
77 deletion
+11
-77
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java
...c/src/main/java/com/taosdata/jdbc/AbstractConnection.java
+0
-11
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
.../jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
+1
-15
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
...ctor/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
+4
-19
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+2
-28
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
...dbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+4
-4
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java
浏览文件 @
a7c5785d
...
@@ -107,16 +107,6 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
...
@@ -107,16 +107,6 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
public
void
setCatalog
(
String
catalog
)
throws
SQLException
{
public
void
setCatalog
(
String
catalog
)
throws
SQLException
{
if
(
isClosed
())
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
/*
try (Statement stmt = createStatement()) {
boolean execute = stmt.execute("use " + catalog);
if (execute)
this.catalog = catalog;
} catch (SQLException e) {
// do nothing
}
*/
this
.
catalog
=
catalog
;
this
.
catalog
=
catalog
;
}
}
...
@@ -416,7 +406,6 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
...
@@ -416,7 +406,6 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
}
catch
(
InterruptedException
|
ExecutionException
ignored
)
{
}
catch
(
InterruptedException
|
ExecutionException
ignored
)
{
}
catch
(
TimeoutException
e
)
{
}
catch
(
TimeoutException
e
)
{
future
.
cancel
(
true
);
future
.
cancel
(
true
);
status
=
false
;
}
finally
{
}
finally
{
executor
.
shutdownNow
();
executor
.
shutdownNow
();
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
浏览文件 @
a7c5785d
/***************************************************************************
* 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
;
package
com.taosdata.jdbc
;
import
java.sql.*
;
import
java.sql.*
;
...
@@ -66,7 +52,7 @@ public class TSDBConnection extends AbstractConnection {
...
@@ -66,7 +52,7 @@ public class TSDBConnection extends AbstractConnection {
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
}
}
long
id
=
this
.
connector
.
subscribe
(
topic
,
sql
,
restart
,
0
);
long
id
=
this
.
connector
.
subscribe
(
topic
,
sql
,
restart
);
if
(
id
==
0
)
{
if
(
id
==
0
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_SUBSCRIBE_FAILED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_SUBSCRIBE_FAILED
);
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
a7c5785d
/***************************************************************************
* 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
;
package
com.taosdata.jdbc
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.*
;
import
java.util.Properties
;
import
java.util.StringTokenizer
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
/**
/**
...
@@ -139,7 +124,7 @@ public class TSDBDriver extends AbstractDriver {
...
@@ -139,7 +124,7 @@ public class TSDBDriver extends AbstractDriver {
}
catch
(
SQLException
sqlEx
)
{
}
catch
(
SQLException
sqlEx
)
{
throw
sqlEx
;
throw
sqlEx
;
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
throw
new
SQLException
(
"SQLException:"
+
ex
.
toString
()
,
ex
);
throw
new
SQLException
(
"SQLException:"
+
ex
,
ex
);
}
}
}
}
...
@@ -152,7 +137,7 @@ public class TSDBDriver extends AbstractDriver {
...
@@ -152,7 +137,7 @@ public class TSDBDriver extends AbstractDriver {
public
boolean
acceptsURL
(
String
url
)
throws
SQLException
{
public
boolean
acceptsURL
(
String
url
)
throws
SQLException
{
if
(
url
==
null
)
if
(
url
==
null
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_URL_NOT_SET
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_URL_NOT_SET
);
return
url
.
length
()
>
0
&&
url
.
trim
().
length
()
>
0
&&
(
url
.
startsWith
(
URL_PREFIX
)
||
url
.
startsWith
(
URL_PREFIX1
));
return
url
.
trim
().
length
()
>
0
&&
(
url
.
startsWith
(
URL_PREFIX
)
||
url
.
startsWith
(
URL_PREFIX1
));
}
}
public
DriverPropertyInfo
[]
getPropertyInfo
(
String
url
,
Properties
info
)
throws
SQLException
{
public
DriverPropertyInfo
[]
getPropertyInfo
(
String
url
,
Properties
info
)
throws
SQLException
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
a7c5785d
/**
* *************************************************************************
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* <p>
* 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.
* <p>
* 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.
* <p>
* 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
;
package
com.taosdata.jdbc
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -261,8 +245,8 @@ public class TSDBJNIConnector {
...
@@ -261,8 +245,8 @@ public class TSDBJNIConnector {
/**
/**
* Create a subscription
* Create a subscription
*/
*/
long
subscribe
(
String
topic
,
String
sql
,
boolean
restart
,
int
period
)
{
long
subscribe
(
String
topic
,
String
sql
,
boolean
restart
)
{
return
subscribeImp
(
this
.
taos
,
restart
,
topic
,
sql
,
period
);
return
subscribeImp
(
this
.
taos
,
restart
,
topic
,
sql
,
0
);
}
}
private
native
long
subscribeImp
(
long
connection
,
boolean
restart
,
String
topic
,
String
sql
,
int
period
);
private
native
long
subscribeImp
(
long
connection
,
boolean
restart
,
String
topic
,
String
sql
,
int
period
);
...
@@ -285,16 +269,6 @@ public class TSDBJNIConnector {
...
@@ -285,16 +269,6 @@ public class TSDBJNIConnector {
private
native
void
unsubscribeImp
(
long
subscription
,
boolean
isKeep
);
private
native
void
unsubscribeImp
(
long
subscription
,
boolean
isKeep
);
/**
* Validate if a <I>create table</I> SQL statement is correct without actually creating that table
*/
public
boolean
validateCreateTableSql
(
String
sql
)
{
int
res
=
validateCreateTableSqlImp
(
taos
,
sql
.
getBytes
());
return
res
==
0
;
}
private
native
int
validateCreateTableSqlImp
(
long
connection
,
byte
[]
sqlBytes
);
public
long
prepareStmt
(
String
sql
)
throws
SQLException
{
public
long
prepareStmt
(
String
sql
)
throws
SQLException
{
long
stmt
=
prepareStmtImp
(
sql
.
getBytes
(),
this
.
taos
);
long
stmt
=
prepareStmtImp
(
sql
.
getBytes
(),
this
.
taos
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
浏览文件 @
a7c5785d
...
@@ -39,7 +39,7 @@ public class RestfulDriver extends AbstractDriver {
...
@@ -39,7 +39,7 @@ public class RestfulDriver extends AbstractDriver {
String
port
=
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
"6041"
);
String
port
=
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
"6041"
);
String
database
=
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
)
?
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
)
:
null
;
String
database
=
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
)
?
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
)
:
null
;
String
loginUrl
=
"http://"
+
host
+
":"
+
port
+
"/rest/login/"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
)
+
"/"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
)
+
""
;
String
loginUrl
;
try
{
try
{
if
(!
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_USER
))
if
(!
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_USER
))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
);
...
@@ -53,8 +53,8 @@ public class RestfulDriver extends AbstractDriver {
...
@@ -53,8 +53,8 @@ public class RestfulDriver extends AbstractDriver {
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
,
"unsupported UTF-8 concoding, user: "
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
)
+
", password: "
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
));
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
,
"unsupported UTF-8 concoding, user: "
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
)
+
", password: "
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
));
}
}
int
poolSize
=
Integer
.
valueOf
(
props
.
getProperty
(
"httpPoolSize"
,
HttpClientPoolUtil
.
DEFAULT_MAX_PER_ROUTE
));
int
poolSize
=
Integer
.
parseInt
(
props
.
getProperty
(
"httpPoolSize"
,
HttpClientPoolUtil
.
DEFAULT_MAX_PER_ROUTE
));
boolean
keepAlive
=
Boolean
.
valueOf
(
props
.
getProperty
(
"httpKeepAlive"
,
HttpClientPoolUtil
.
DEFAULT_HTTP_KEEP_ALIVE
));
boolean
keepAlive
=
Boolean
.
parseBoolean
(
props
.
getProperty
(
"httpKeepAlive"
,
HttpClientPoolUtil
.
DEFAULT_HTTP_KEEP_ALIVE
));
HttpClientPoolUtil
.
init
(
poolSize
,
keepAlive
);
HttpClientPoolUtil
.
init
(
poolSize
,
keepAlive
);
String
result
=
HttpClientPoolUtil
.
execute
(
loginUrl
);
String
result
=
HttpClientPoolUtil
.
execute
(
loginUrl
);
...
@@ -79,7 +79,7 @@ public class RestfulDriver extends AbstractDriver {
...
@@ -79,7 +79,7 @@ public class RestfulDriver extends AbstractDriver {
public
boolean
acceptsURL
(
String
url
)
throws
SQLException
{
public
boolean
acceptsURL
(
String
url
)
throws
SQLException
{
if
(
url
==
null
)
if
(
url
==
null
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_URL_NOT_SET
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_URL_NOT_SET
);
return
url
.
length
()
>
0
&&
url
.
trim
().
length
()
>
0
&&
url
.
startsWith
(
URL_PREFIX
);
return
url
.
trim
().
length
()
>
0
&&
url
.
startsWith
(
URL_PREFIX
);
}
}
@Override
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录