Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7303c5d0
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看板
提交
7303c5d0
编写于
1月 13, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
b2afe151
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
429 addition
and
192 deletion
+429
-192
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
...main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
+2
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
...src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
+39
-36
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
...ctor/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
...in/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
+0
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
...src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
...test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
+306
-152
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java
...taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java
+79
-0
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java
浏览文件 @
7303c5d0
...
...
@@ -497,12 +497,12 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData {
public
ResultSet
getProcedures
(
String
catalog
,
String
schemaPattern
,
String
procedureNamePattern
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
)
;
return
null
;
}
public
ResultSet
getProcedureColumns
(
String
catalog
,
String
schemaPattern
,
String
procedureNamePattern
,
String
columnNamePattern
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
)
;
return
null
;
}
public
abstract
ResultSet
getTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
)
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
浏览文件 @
7303c5d0
...
...
@@ -20,13 +20,11 @@ import java.util.List;
public
class
TSDBDatabaseMetaData
implements
java
.
sql
.
DatabaseMetaData
{
private
String
dbProductName
=
null
;
private
String
url
=
null
;
private
String
userName
=
null
;
private
Connection
conn
=
null
;
private
String
url
;
private
String
userName
;
private
Connection
conn
;
public
TSDBDatabaseMetaData
(
String
dbProductName
,
String
url
,
String
userName
)
{
this
.
dbProductName
=
dbProductName
;
public
TSDBDatabaseMetaData
(
String
url
,
String
userName
)
{
this
.
url
=
url
;
this
.
userName
=
userName
;
}
...
...
@@ -116,7 +114,9 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
return
false
;
}
public
boolean
supportsMixedCaseIdentifiers
()
throws
SQLException
{
//像database、table这些对象的标识符,在存储时是否采用大小写混合的模式
return
false
;
}
...
...
@@ -125,7 +125,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
boolean
storesLowerCaseIdentifiers
()
throws
SQLException
{
return
fals
e
;
return
tru
e
;
}
public
boolean
storesMixedCaseIdentifiers
()
throws
SQLException
{
...
...
@@ -133,6 +133,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
boolean
supportsMixedCaseQuotedIdentifiers
()
throws
SQLException
{
//像database、table这些对象的标识符,在存储时是否采用大小写混合、并带引号的模式
return
false
;
}
...
...
@@ -193,10 +194,12 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
boolean
nullPlusNonNullIsNull
()
throws
SQLException
{
// null + non-null != null
return
false
;
}
public
boolean
supportsConvert
()
throws
SQLException
{
// 是否支持转换函数convert
return
false
;
}
...
...
@@ -221,7 +224,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
boolean
supportsGroupBy
()
throws
SQLException
{
return
fals
e
;
return
tru
e
;
}
public
boolean
supportsGroupByUnrelated
()
throws
SQLException
{
...
...
@@ -493,7 +496,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
int
getDefaultTransactionIsolation
()
throws
SQLException
{
return
0
;
return
Connection
.
TRANSACTION_NONE
;
}
public
boolean
supportsTransactions
()
throws
SQLException
{
...
...
@@ -501,6 +504,8 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
boolean
supportsTransactionIsolationLevel
(
int
level
)
throws
SQLException
{
if
(
level
==
Connection
.
TRANSACTION_NONE
)
return
true
;
return
false
;
}
...
...
@@ -522,28 +527,27 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
public
ResultSet
getProcedures
(
String
catalog
,
String
schemaPattern
,
String
procedureNamePattern
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
)
;
return
null
;
}
public
ResultSet
getProcedureColumns
(
String
catalog
,
String
schemaPattern
,
String
procedureNamePattern
,
String
columnNamePattern
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
)
;
return
null
;
}
public
ResultSet
getTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
)
throws
SQLException
{
Statement
stmt
=
null
;
if
(
null
!=
conn
&&
!
conn
.
isClosed
())
{
stmt
=
conn
.
createStatement
();
if
(
catalog
==
null
||
catalog
.
length
()
<
1
)
{
catalog
=
conn
.
getCatalog
();
}
public
ResultSet
getTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
,
String
[]
types
)
throws
SQLException
{
if
(
conn
==
null
||
conn
.
isClosed
())
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
try
(
Statement
stmt
=
conn
.
createStatement
())
{
if
(
catalog
==
null
||
catalog
.
isEmpty
())
return
null
;
stmt
.
executeUpdate
(
"use "
+
catalog
);
ResultSet
resultSet0
=
stmt
.
executeQuery
(
"show tables"
);
GetTablesResultSet
getTablesResultSet
=
new
GetTablesResultSet
(
resultSet0
,
catalog
,
schemaPattern
,
tableNamePattern
,
types
);
return
getTablesResultSet
;
}
else
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
}
...
...
@@ -552,14 +556,12 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
ResultSet
getCatalogs
()
throws
SQLException
{
if
(
conn
==
null
||
conn
.
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
if
(
conn
!=
null
&&
!
conn
.
isClosed
())
{
Statement
stmt
=
conn
.
createStatement
();
ResultSet
resultSet0
=
stmt
.
executeQuery
(
"show databases"
);
CatalogResultSet
resultSet
=
new
CatalogResultSet
(
resultSet0
);
return
resultSet
;
}
else
{
return
getEmptyResultSet
();
try
(
Statement
stmt
=
conn
.
createStatement
())
{
ResultSet
rs
=
stmt
.
executeQuery
(
"show databases"
);
return
new
CatalogResultSet
(
rs
);
}
}
...
...
@@ -567,7 +569,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
// set up ColumnMetaDataList
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<
ColumnMetaData
>(
1
);
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<>(
1
);
ColumnMetaData
colMetaData
=
new
ColumnMetaData
();
colMetaData
.
setColIndex
(
0
);
colMetaData
.
setColName
(
"TABLE_TYPE"
);
...
...
@@ -576,7 +578,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
columnMetaDataList
.
add
(
colMetaData
);
// set up rowDataList
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<
TSDBResultSetRowData
>(
2
);
List
<
TSDBResultSetRowData
>
rowDataList
=
new
ArrayList
<>(
2
);
TSDBResultSetRowData
rowData
=
new
TSDBResultSetRowData
();
rowData
.
setString
(
0
,
"TABLE"
);
rowDataList
.
add
(
rowData
);
...
...
@@ -596,11 +598,10 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
Statement
stmt
=
null
;
if
(
null
!=
conn
&&
!
conn
.
isClosed
())
{
stmt
=
conn
.
createStatement
();
if
(
catalog
==
null
||
catalog
.
length
()
<
1
)
{
catalog
=
conn
.
getCatalog
();
}
stmt
.
executeUpdate
(
"use "
+
catalog
);
if
(
catalog
==
null
||
catalog
.
isEmpty
())
return
null
;
stmt
.
executeUpdate
(
"use "
+
catalog
);
DatabaseMetaDataResultSet
resultSet
=
new
DatabaseMetaDataResultSet
();
// set up ColumnMetaDataList
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<>(
24
);
...
...
@@ -856,7 +857,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
Connection
getConnection
()
throws
SQLException
{
return
null
;
return
this
.
conn
;
}
public
boolean
supportsSavepoints
()
throws
SQLException
{
...
...
@@ -889,11 +890,13 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
public
boolean
supportsResultSetHoldability
(
int
holdability
)
throws
SQLException
{
if
(
holdability
==
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
)
return
true
;
return
false
;
}
public
int
getResultSetHoldability
()
throws
SQLException
{
return
0
;
return
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
;
}
public
int
getDatabaseMajorVersion
()
throws
SQLException
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
7303c5d0
...
...
@@ -214,7 +214,7 @@ public class TSDBDriver extends AbstractTaosDriver {
urlProps
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
url
);
}
this
.
dbMetaData
=
new
TSDBDatabaseMetaData
(
dbProductName
,
urlForMeta
,
urlProps
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
));
this
.
dbMetaData
=
new
TSDBDatabaseMetaData
(
urlForMeta
,
urlProps
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
));
return
urlProps
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
浏览文件 @
7303c5d0
...
...
@@ -8,7 +8,6 @@ import java.util.List;
public
class
RestfulDatabaseMetaData
extends
AbstractDatabaseMetaData
{
private
final
String
url
;
private
final
String
userName
;
private
final
Connection
connection
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
浏览文件 @
7303c5d0
...
...
@@ -168,6 +168,7 @@ public class DatabaseMetaDataTest {
try
{
databaseMetaData
.
getProcedures
(
""
,
""
,
""
);
}
catch
(
Exception
e
)
{
}
try
{
databaseMetaData
.
getProcedureColumns
(
""
,
""
,
""
,
""
);
...
...
@@ -176,6 +177,7 @@ public class DatabaseMetaDataTest {
try
{
databaseMetaData
.
getTables
(
""
,
""
,
""
,
new
String
[]{
""
});
}
catch
(
Exception
e
)
{
}
databaseMetaData
.
getSchemas
();
databaseMetaData
.
getCatalogs
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java
浏览文件 @
7303c5d0
此差异已折叠。
点击以展开。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiThreadsWithSameStatmentTest.java
0 → 100644
浏览文件 @
7303c5d0
package
com.taosdata.jdbc.cases
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.IntStream
;
public
class
MultiThreadsWithSameStatmentTest
{
private
Connection
conn
;
private
Statement
stmt
;
@Before
public
void
before
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:6030/?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists jdbctest"
);
stmt
.
executeUpdate
(
"create table jdbctest.weather (ts timestamp, f1 int)"
);
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
test
()
{
Thread
t1
=
new
Thread
(()
->
{
try
{
ResultSet
resultSet
=
stmt
.
executeQuery
(
"select * from log."
);
sleep
(
5000
);
while
(
resultSet
.
next
())
{
ResultSetMetaData
metaData
=
resultSet
.
getMetaData
();
for
(
int
i
=
1
;
i
<=
metaData
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
metaData
.
getColumnLabel
(
i
)
+
": "
+
resultSet
.
getString
(
i
));
}
System
.
out
.
println
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
});
Thread
t2
=
new
Thread
(()
->
{
try
{
stmt
.
executeUpdate
(
"insert into jdbctest.weather values(now,1)"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
});
t1
.
start
();
sleep
(
1000
);
t2
.
start
();
}
private
void
sleep
(
long
mills
)
{
try
{
TimeUnit
.
MILLISECONDS
.
sleep
(
mills
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
@After
public
void
after
()
{
try
{
if
(
stmt
!=
null
)
stmt
.
close
();
if
(
conn
!=
null
)
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录