Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
9d773e12
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d773e12
编写于
2月 20, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
55735e8d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
264 addition
and
117 deletion
+264
-117
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java
...c/src/main/java/com/taosdata/jdbc/AbstractConnection.java
+90
-6
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
.../jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
+8
-43
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java
...c/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java
+166
-68
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractConnection.java
浏览文件 @
9d773e12
...
...
@@ -137,10 +137,57 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
}
@Override
public
abstract
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
;
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
switch
(
resultSetType
)
{
case
ResultSet
.
TYPE_FORWARD_ONLY
:
break
;
case
ResultSet
.
TYPE_SCROLL_INSENSITIVE
:
case
ResultSet
.
TYPE_SCROLL_SENSITIVE
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
switch
(
resultSetConcurrency
)
{
case
ResultSet
.
CONCUR_READ_ONLY
:
break
;
case
ResultSet
.
CONCUR_UPDATABLE
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
return
createStatement
();
}
@Override
public
abstract
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
;
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
switch
(
resultSetType
)
{
case
ResultSet
.
TYPE_FORWARD_ONLY
:
break
;
case
ResultSet
.
TYPE_SCROLL_INSENSITIVE
:
case
ResultSet
.
TYPE_SCROLL_SENSITIVE
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
switch
(
resultSetConcurrency
)
{
case
ResultSet
.
CONCUR_READ_ONLY
:
break
;
case
ResultSet
.
CONCUR_UPDATABLE
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
return
prepareStatement
(
sql
);
}
@Override
public
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
...
...
@@ -170,6 +217,15 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
public
void
setHoldability
(
int
holdability
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
switch
(
holdability
)
{
case
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
:
break
;
case
ResultSet
.
CLOSE_CURSORS_AT_COMMIT
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
//do nothing
}
...
...
@@ -214,10 +270,38 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
}
@Override
public
abstract
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
;
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
switch
(
resultSetHoldability
)
{
case
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
:
break
;
case
ResultSet
.
CLOSE_CURSORS_AT_COMMIT
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
return
createStatement
(
resultSetType
,
resultSetConcurrency
);
}
@Override
public
abstract
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
;
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
switch
(
resultSetHoldability
)
{
case
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
:
break
;
case
ResultSet
.
CLOSE_CURSORS_AT_COMMIT
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
default
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
return
prepareStatement
(
sql
,
resultSetType
,
resultSetConcurrency
);
}
@Override
public
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
...
...
@@ -231,14 +315,14 @@ public abstract class AbstractConnection extends WrapperImpl implements Connecti
public
PreparedStatement
prepareStatement
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
switch
(
autoGeneratedKeys
)
{
case
Statement
.
RETURN_GENERATED_KEYS
:
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
case
Statement
.
NO_GENERATED_KEYS
:
break
;
}
return
prepareStatement
(
sql
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
);
return
prepareStatement
(
sql
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
浏览文件 @
9d773e12
...
...
@@ -23,6 +23,14 @@ public class TSDBConnection extends AbstractConnection {
private
TSDBDatabaseMetaData
databaseMetaData
;
private
boolean
batchFetch
;
public
Boolean
getBatchFetch
()
{
return
this
.
batchFetch
;
}
public
void
setBatchFetch
(
Boolean
batchFetch
)
{
this
.
batchFetch
=
batchFetch
;
}
public
TSDBConnection
(
Properties
info
,
TSDBDatabaseMetaData
meta
)
throws
SQLException
{
this
.
databaseMetaData
=
meta
;
connect
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
),
...
...
@@ -104,47 +112,4 @@ public class TSDBConnection extends AbstractConnection {
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
// This method is implemented in the current way to support Spark
if
(
resultSetType
!=
ResultSet
.
TYPE_FORWARD_ONLY
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
if
(
resultSetConcurrency
!=
ResultSet
.
CONCUR_READ_ONLY
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
return
this
.
prepareStatement
(
sql
);
}
public
Boolean
getBatchFetch
()
{
return
this
.
batchFetch
;
}
public
void
setBatchFetch
(
Boolean
batchFetch
)
{
this
.
batchFetch
=
batchFetch
;
}
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
}
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_CONNECTION_CLOSED
);
}
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
// @Override
// public boolean isValid(int timeout) throws SQLException {
// return !this.isClosed();
// }
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java
浏览文件 @
9d773e12
...
...
@@ -5,6 +5,7 @@ import org.junit.Assert;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
javax.management.OperationsException
;
import
java.sql.*
;
import
java.util.Properties
;
...
...
@@ -15,174 +16,265 @@ public class TSDBConnectionTest {
@Test
public
void
getConnection
()
{
// already test in beforeClass method
}
@Test
public
void
createStatement
()
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
ResultSet
rs
=
stmt
.
executeQuery
(
"select server_status()"
);
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
subscribe
()
{
try
{
TSDBConnection
unwrap
=
conn
.
unwrap
(
TSDBConnection
.
class
);
TSDBSubscribe
subscribe
=
unwrap
.
subscribe
(
"topic1"
,
"select server_status()"
,
false
);
TSDBResultSet
rs
=
subscribe
.
consume
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
}
catch
(
SQLException
|
OperationsException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
prepareStatement
()
{
public
void
prepareStatement
()
throws
SQLException
{
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
"select server_status()"
);
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
}
@Test
public
void
prepareCall
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
prepareCall
()
throws
SQLException
{
conn
.
prepareCall
(
"select server_status()"
);
}
@Test
public
void
nativeSQL
()
{
public
void
nativeSQL
()
throws
SQLException
{
String
nativeSQL
=
conn
.
nativeSQL
(
"select * from log.log"
);
Assert
.
assertEquals
(
"select * from log.log"
,
nativeSQL
);
}
@Test
public
void
setAutoCommit
()
{
public
void
setAutoCommit
()
throws
SQLException
{
conn
.
setAutoCommit
(
true
);
conn
.
setAutoCommit
(
false
);
}
@Test
public
void
getAutoCommit
()
{
public
void
getAutoCommit
()
throws
SQLException
{
Assert
.
assertTrue
(
conn
.
getAutoCommit
());
}
@Test
public
void
commit
()
{
public
void
commit
()
throws
SQLException
{
conn
.
commit
();
}
@Test
public
void
rollback
()
{
public
void
rollback
()
throws
SQLException
{
conn
.
rollback
();
}
@Test
public
void
close
()
{
// connection will close in afterClass method
}
@Test
public
void
isClosed
()
{
public
void
isClosed
()
throws
SQLException
{
Assert
.
assertFalse
(
conn
.
isClosed
());
}
@Test
public
void
getMetaData
()
{
public
void
getMetaData
()
throws
SQLException
{
DatabaseMetaData
meta
=
conn
.
getMetaData
();
Assert
.
assertNotNull
(
meta
);
Assert
.
assertEquals
(
"com.taosdata.jdbc.TSDBDriver"
,
meta
.
getDriverName
());
}
@Test
public
void
setReadOnly
()
{
public
void
setReadOnly
()
throws
SQLException
{
conn
.
setReadOnly
(
true
);
}
@Test
public
void
isReadOnly
()
{
public
void
isReadOnly
()
throws
SQLException
{
Assert
.
assertTrue
(
conn
.
isReadOnly
());
}
@Test
public
void
setCatalog
()
{
public
void
setCatalog
()
throws
SQLException
{
conn
.
setCatalog
(
"test"
);
Assert
.
assertEquals
(
"test"
,
conn
.
getCatalog
());
}
@Test
public
void
getCatalog
()
{
public
void
getCatalog
()
throws
SQLException
{
Assert
.
assertEquals
(
"log"
,
conn
.
getCatalog
());
}
@Test
public
void
setTransactionIsolation
()
{
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
setTransactionIsolation
()
throws
SQLException
{
conn
.
setTransactionIsolation
(
Connection
.
TRANSACTION_NONE
);
Assert
.
assertEquals
(
Connection
.
TRANSACTION_NONE
,
conn
.
getTransactionIsolation
());
@Test
public
void
getTransactionIsolation
()
{
conn
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
);
}
@Test
public
void
getWarnings
()
{
public
void
getTransactionIsolation
()
throws
SQLException
{
Assert
.
assertEquals
(
Connection
.
TRANSACTION_NONE
,
conn
.
getTransactionIsolation
());
}
@Test
public
void
clearWarnings
()
{
public
void
getWarnings
()
throws
SQLException
{
Assert
.
assertNull
(
conn
.
getWarnings
());
}
@Test
public
void
testCreateStatement
()
{
public
void
clearWarnings
()
throws
SQLException
{
conn
.
clearWarnings
();
}
@Test
public
void
testPrepareStatement
()
{
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testCreateStatement
()
throws
SQLException
{
Statement
stmt
=
conn
.
createStatement
(
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select server_status()"
);
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
@Test
public
void
getBatchFetch
()
{
conn
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
);
}
@Test
public
void
setBatchFetch
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareStatement
()
throws
SQLException
{
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
"select server_status()"
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
);
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
conn
.
prepareStatement
(
"select server_status"
,
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
);
}
@Test
public
void
testPrepareCall
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareCall
()
throws
SQLException
{
conn
.
prepareCall
(
""
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
@Test
public
void
getTypeMap
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
getTypeMap
()
throws
SQLException
{
conn
.
getTypeMap
();
}
@Test
public
void
setTypeMap
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
setTypeMap
()
throws
SQLException
{
conn
.
setTypeMap
(
null
);
}
@Test
public
void
setHoldability
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
setHoldability
()
throws
SQLException
{
conn
.
setHoldability
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
Assert
.
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
conn
.
setHoldability
(
ResultSet
.
CLOSE_CURSORS_AT_COMMIT
);
}
@Test
public
void
getHoldability
()
{
public
void
getHoldability
()
throws
SQLException
{
Assert
.
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
}
@Test
public
void
setSavepoint
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
setSavepoint
()
throws
SQLException
{
conn
.
setSavepoint
();
}
@Test
public
void
testSetSavepoint
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testSetSavepoint
()
throws
SQLException
{
conn
.
setSavepoint
(
null
);
}
@Test
public
void
testRollback
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testRollback
()
throws
SQLException
{
conn
.
rollback
(
null
);
}
@Test
public
void
releaseSavepoint
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
releaseSavepoint
()
throws
SQLException
{
conn
.
releaseSavepoint
(
null
);
}
@Test
public
void
testCreateStatement1
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testCreateStatement1
()
throws
SQLException
{
Statement
stmt
=
conn
.
createStatement
(
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select server_status()"
);
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
conn
.
createStatement
(
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
@Test
public
void
testPrepareStatement1
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareStatement1
()
throws
SQLException
{
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
"select server_status()"
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
conn
.
prepareStatement
(
"select server_status"
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
@Test
public
void
testPrepareCall1
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareCall1
()
throws
SQLException
{
conn
.
prepareCall
(
""
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
@Test
public
void
testPrepareStatement2
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareStatement2
()
throws
SQLException
{
Assert
.
assertNotNull
(
""
,
Statement
.
NO_GENERATED_KEYS
);
conn
.
prepareStatement
(
""
,
Statement
.
RETURN_GENERATED_KEYS
);
}
@Test
public
void
testPrepareStatement3
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareStatement3
()
throws
SQLException
{
conn
.
prepareStatement
(
""
,
new
int
[]{});
}
@Test
public
void
testPrepareStatement4
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
testPrepareStatement4
()
throws
SQLException
{
conn
.
prepareStatement
(
""
,
new
String
[]{});
}
@Test
public
void
createClob
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
createClob
()
throws
SQLException
{
conn
.
createClob
();
}
@Test
public
void
createBlob
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
createBlob
()
throws
SQLException
{
conn
.
createBlob
();
}
@Test
public
void
createNClob
()
{
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
createNClob
()
throws
SQLException
{
conn
.
createNClob
();
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
...
...
@@ -190,10 +282,11 @@ public class TSDBConnectionTest {
conn
.
createSQLXML
();
}
@Test
@Test
(
expected
=
SQLException
.
class
)
public
void
isValid
()
throws
SQLException
{
Assert
.
assertTrue
(
conn
.
isValid
(
5
));
conn
.
isValid
(
0
);
Assert
.
assertTrue
(
conn
.
isValid
(
10
));
Assert
.
assertTrue
(
conn
.
isValid
(
0
));
conn
.
isValid
(-
1
);
}
@Test
...
...
@@ -299,7 +392,12 @@ public class TSDBConnectionTest {
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":6030/?user=root&password=taosdata"
,
properties
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":6030/log?user=root&password=taosdata"
,
properties
);
// create test database for test cases
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"create database if not exists test"
);
}
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录