Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
b064e90e
I
Iotdb
项目概览
apache
/
Iotdb
10 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
b064e90e
编写于
4月 30, 2020
作者:
X
Xiangdong Huang
提交者:
GitHub
4月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-531] fix that JDBC URL does not support domain issue (#1118)
* fix iotdb-531, jdbc url does not support domain issue
上级
d68f616a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
24 deletion
+14
-24
jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
+12
-22
jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
+2
-2
未找到文件。
jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
浏览文件 @
b064e90e
...
...
@@ -37,6 +37,8 @@ import org.apache.iotdb.tsfile.utils.BytesUtils;
*/
public
class
Utils
{
static
final
Pattern
URL_PATTERN
=
Pattern
.
compile
(
"([^:]+):([0-9]{1,5})/?"
);
/**
* Parse JDBC connection URL The only supported format of the URL is:
* jdbc:iotdb://localhost:6667/.
...
...
@@ -48,31 +50,19 @@ public class Utils {
return
params
;
}
boolean
isUrlLegal
=
false
;
Pattern
pattern
=
Pattern
.
compile
(
"^"
+
"(((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}"
// Domain name
+
"|"
+
"localhost"
// localhost
+
"|"
+
"(([0-9]{1,3}\\.){3})[0-9]{1,3})"
// Ip
+
":"
+
"[0-9]{1,5}"
// Port
+
"/?$"
);
String
subURL
=
url
.
substring
(
Config
.
IOTDB_URL_PREFIX
.
length
());
Matcher
matcher
=
pattern
.
matcher
(
subURL
);
if
(
matcher
.
matches
())
{
isUrlLegal
=
true
;
}
String
[]
DomainAndPort
;
if
(
subURL
.
contains
(
"/"
))
{
DomainAndPort
=
subURL
.
substring
(
0
,
subURL
.
length
()-
1
).
split
(
":"
);
}
else
{
DomainAndPort
=
subURL
.
split
(
":"
);
Matcher
matcher
=
null
;
if
(
url
.
startsWith
(
Config
.
IOTDB_URL_PREFIX
))
{
String
subURL
=
url
.
substring
(
Config
.
IOTDB_URL_PREFIX
.
length
());
matcher
=
URL_PATTERN
.
matcher
(
subURL
);
if
(
matcher
.
matches
())
{
isUrlLegal
=
true
;
}
}
params
.
setHost
(
DomainAndPort
[
0
]);
params
.
setPort
(
Integer
.
parseInt
(
DomainAndPort
[
1
]));
if
(!
isUrlLegal
)
{
throw
new
IoTDBURLException
(
"Error url format, url should be jdbc:iotdb://
domain|ip:port/ or jdbc:iotdb://domain|ip
:port"
);
throw
new
IoTDBURLException
(
"Error url format, url should be jdbc:iotdb://
anything:port/ or jdbc:iotdb://anything
:port"
);
}
params
.
setHost
(
matcher
.
group
(
1
));
params
.
setPort
(
Integer
.
parseInt
(
matcher
.
group
(
2
)));
if
(
info
.
containsKey
(
Config
.
AUTH_USER
))
{
params
.
setUsername
(
info
.
getProperty
(
Config
.
AUTH_USER
));
...
...
jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
浏览文件 @
b064e90e
...
...
@@ -99,7 +99,7 @@ public class UtilsTest {
assertEquals
(
params
.
getPort
(),
port
);
}
@Test
(
expected
=
NumberFormat
Exception
.
class
)
@Test
(
expected
=
IoTDBURL
Exception
.
class
)
public
void
testParseWrongDomain
()
throws
IoTDBURLException
{
String
userName
=
"test"
;
String
userPwd
=
"test"
;
...
...
@@ -113,7 +113,7 @@ public class UtilsTest {
properties
);
}
@Test
(
expected
=
IoTDBURLException
.
class
)
@Test
public
void
testParseWrongIP
()
throws
IoTDBURLException
{
String
userName
=
"test"
;
String
userPwd
=
"test"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录