Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2865a5be
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看板
未验证
提交
2865a5be
编写于
3月 23, 2022
作者:
H
huolibo
提交者:
GitHub
3月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-14219]<fix>: change getTables for tableNamePattern (#10926)
上级
4a4d1431
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
7 deletion
+35
-7
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
...main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
+28
-7
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/StringUtils.java
...bc/src/main/java/com/taosdata/jdbc/utils/StringUtils.java
+7
-0
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
浏览文件 @
2865a5be
package
com.taosdata.jdbc
;
package
com.taosdata.jdbc
;
import
com.taosdata.jdbc.utils.StringUtils
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
public
abstract
class
AbstractDatabaseMetaData
extends
WrapperImpl
implements
DatabaseMetaData
{
public
abstract
class
AbstractDatabaseMetaData
extends
WrapperImpl
implements
DatabaseMetaData
{
...
@@ -550,9 +553,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -550,9 +553,9 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
}
}
protected
ResultSet
getTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
,
Connection
connection
)
throws
SQLException
{
protected
ResultSet
getTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
,
Connection
connection
)
throws
SQLException
{
if
(
catalog
==
null
||
catalog
.
isEmpty
(
))
if
(
StringUtils
.
isEmpty
(
catalog
))
return
null
;
catalog
=
this
.
getConnection
().
getCatalog
()
;
if
(!
isAvailableCatalog
(
connection
,
catalog
))
if
(!
StringUtils
.
isEmpty
(
catalog
)
&&
!
isAvailableCatalog
(
connection
,
catalog
))
return
new
EmptyResultSet
();
return
new
EmptyResultSet
();
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
...
@@ -561,8 +564,27 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -561,8 +564,27 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
// set row data
// set row data
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>();
try
(
Statement
stmt
=
connection
.
createStatement
())
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
stmt
.
execute
(
"use "
+
catalog
);
List
<
String
>
dbs
=
new
ArrayList
<>();
try
(
ResultSet
tables
=
stmt
.
executeQuery
(
"show tables"
))
{
if
(!
StringUtils
.
isEmpty
(
catalog
))
{
dbs
.
add
(
catalog
);
}
else
{
ResultSet
dbRs
=
stmt
.
executeQuery
(
"show databases"
);
while
(
dbRs
.
next
())
{
dbs
.
add
(
dbRs
.
getString
(
"name"
));
}
}
if
(
dbs
.
isEmpty
())
{
return
new
EmptyResultSet
();
}
for
(
String
db
:
dbs
)
{
stmt
.
execute
(
"use "
+
db
);
String
sql
=
"show tables "
;
String
Ssql
=
"show stables "
;
if
(!
StringUtils
.
isEmpty
(
tableNamePattern
))
{
sql
=
sql
+
"like '"
+
tableNamePattern
+
"'"
;
Ssql
=
Ssql
+
"like '"
+
tableNamePattern
+
"'"
;
}
ResultSet
tables
=
stmt
.
executeQuery
(
sql
);
while
(
tables
.
next
())
{
while
(
tables
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
...
@@ -572,8 +594,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
...
@@ -572,8 +594,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
rowData
.
setStringValue
(
5
,
""
);
//REMARKS
rowData
.
setStringValue
(
5
,
""
);
//REMARKS
rowDataList
.
add
(
rowData
);
rowDataList
.
add
(
rowData
);
}
}
}
ResultSet
stables
=
stmt
.
executeQuery
(
Ssql
);
try
(
ResultSet
stables
=
stmt
.
executeQuery
(
"show stables"
))
{
while
(
stables
.
next
())
{
while
(
stables
.
next
())
{
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
(
10
);
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
rowData
.
setStringValue
(
1
,
catalog
);
//TABLE_CAT
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/StringUtils.java
0 → 100644
浏览文件 @
2865a5be
package
com.taosdata.jdbc.utils
;
public
class
StringUtils
{
public
static
boolean
isEmpty
(
final
CharSequence
cs
)
{
return
cs
==
null
||
cs
.
length
()
==
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录