Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0a8d42b1
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0a8d42b1
编写于
8月 21, 2020
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1174: jdbc without host ip
上级
397e5e15
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
387 addition
and
328 deletion
+387
-328
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
.../jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
+387
-328
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
浏览文件 @
0a8d42b1
...
...
@@ -14,6 +14,7 @@
*****************************************************************************/
package
com.taosdata.jdbc
;
import
java.io.*
;
import
java.sql.Array
;
import
java.sql.Blob
;
import
java.sql.CallableStatement
;
...
...
@@ -30,11 +31,11 @@ import java.sql.SQLXML;
import
java.sql.Savepoint
;
import
java.sql.Statement
;
import
java.sql.Struct
;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.*
;
import
java.util.concurrent.Executor
;
import
static
com
.
sun
.
deploy
.
cache
.
Cache
.
exists
;
public
class
TSDBConnection
implements
Connection
{
private
TSDBJNIConnector
connector
=
null
;
...
...
@@ -53,12 +54,67 @@ public class TSDBConnection implements Connection {
public
TSDBConnection
(
Properties
info
,
TSDBDatabaseMetaData
meta
)
throws
SQLException
{
this
.
dbMetaData
=
meta
;
//load taos.cfg start
File
cfgDir
=
loadConfigDir
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_CONFIG_DIR
));
File
cfgFile
=
cfgDir
.
listFiles
((
dir
,
name
)
->
"taos.cfg"
.
equalsIgnoreCase
(
name
))[
0
];
List
<
String
>
endpoints
=
loadConfigEndpoints
(
cfgFile
);
if
(!
endpoints
.
isEmpty
()){
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
endpoints
.
get
(
0
).
split
(
":"
)[
0
]);
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
endpoints
.
get
(
0
).
split
(
":"
)[
1
]);
}
//load taos.cfg end
connect
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
),
Integer
.
parseInt
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
"0"
)),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
));
}
private
List
<
String
>
loadConfigEndpoints
(
File
cfgFile
){
List
<
String
>
endpoints
=
new
ArrayList
<>();
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
cfgFile
)))
{
String
line
=
null
;
while
((
line
=
reader
.
readLine
())!=
null
){
if
(
line
.
trim
().
startsWith
(
"firstEp"
)
||
line
.
trim
().
startsWith
(
"secondEp"
)){
endpoints
.
add
(
line
.
substring
(
line
.
indexOf
(
'p'
)+
1
).
trim
());
}
if
(
endpoints
.
size
()>
1
)
break
;
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
endpoints
;
}
/**
* @param cfgDirPath
* @return return the config dir
* **/
private
File
loadConfigDir
(
String
cfgDirPath
)
{
if
(
cfgDirPath
==
null
)
return
loadDefaultConfigDir
();
File
cfgDir
=
new
File
(
cfgDirPath
);
if
(!
cfgDir
.
exists
())
return
loadDefaultConfigDir
();
return
cfgDir
;
}
/**
* @return search the default config dir, if the config dir is not exist will return null
* */
private
File
loadDefaultConfigDir
(){
File
cfgDir
;
File
cfgDir_linux
=
new
File
(
"/etc/taos"
);
cfgDir
=
cfgDir_linux
.
exists
()
?
cfgDir_linux
:
null
;
File
cfgDir_windows
=
new
File
(
"C:\\TDengine\\cfg"
);
cfgDir
=
(
cfgDir
==
null
&&
cfgDir_windows
.
exists
())
?
cfgDir_windows
:
cfgDir
;
return
cfgDir
;
}
private
void
connect
(
String
host
,
int
port
,
String
dbName
,
String
user
,
String
password
)
throws
SQLException
{
this
.
connector
=
new
TSDBJNIConnector
();
this
.
connector
.
connect
(
host
,
port
,
dbName
,
user
,
password
);
...
...
@@ -146,8 +202,7 @@ public class TSDBConnection implements Connection {
* DatabaseMetaData object.
*
* @return a DatabaseMetaData object for this connection
* @exception SQLException
* if a database access error occurs
* @throws SQLException if a database access error occurs
*/
public
DatabaseMetaData
getMetaData
()
throws
SQLException
{
return
this
.
dbMetaData
;
...
...
@@ -156,6 +211,7 @@ public class TSDBConnection implements Connection {
/**
* This readOnly option is not supported by TDengine. However, the method is intentionally left blank here to
* support HikariCP connection.
*
* @param readOnly
* @throws SQLException
*/
...
...
@@ -177,6 +233,7 @@ public class TSDBConnection implements Connection {
/**
* The transaction isolation level option is not supported by TDengine.
* This method is intentionally left empty to support HikariCP connection.
*
* @param level
* @throws SQLException
*/
...
...
@@ -185,6 +242,7 @@ public class TSDBConnection implements Connection {
/**
* The transaction isolation level option is not supported by TDengine.
*
* @return
* @throws SQLException
*/
...
...
@@ -237,6 +295,7 @@ public class TSDBConnection implements Connection {
/**
* the transaction is not supported by TDengine, so the opened ResultSet Objects will remain open
*
* @return
* @throws SQLException
*/
...
...
@@ -313,7 +372,7 @@ public class TSDBConnection implements Connection {
}
public
void
setClientInfo
(
Properties
properties
)
throws
SQLClientInfoException
{
for
(
Enumeration
<
Object
>
enumer
=
properties
.
keys
();
enumer
.
hasMoreElements
();
)
{
for
(
Enumeration
<
Object
>
enumer
=
properties
.
keys
();
enumer
.
hasMoreElements
();
)
{
String
name
=
(
String
)
enumer
.
nextElement
();
clientInfoProps
.
put
(
name
,
properties
.
getProperty
(
name
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录