Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yiicenne
TDengine
提交
42d5896b
TDengine
项目概览
yiicenne
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
42d5896b
编写于
2月 07, 2021
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into xiaoping/add_test_case
上级
4dbf8e61
2f60909a
变更
46
展开全部
隐藏空白更改
内联
并排
Showing
46 changed file
with
3533 addition
and
3108 deletion
+3533
-3108
Jenkinsfile
Jenkinsfile
+27
-18
cmake/install.inc
cmake/install.inc
+1
-1
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+3
-1
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+3
-2
src/connector/jdbc/CMakeLists.txt
src/connector/jdbc/CMakeLists.txt
+1
-1
src/connector/jdbc/deploy-pom.xml
src/connector/jdbc/deploy-pom.xml
+1
-1
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+2
-3
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java
.../jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java
...bc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java
+1210
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
...bc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
+249
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java
...ain/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java
+68
-68
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java
+2
-1
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/TSDBError.java
...ector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
+35
-5
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
+46
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+41
-30
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java
...rc/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java
+35
-35
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
+81
-748
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java
...rc/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java
+6
-6
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetWrapper.java
...src/main/java/com/taosdata/jdbc/TSDBResultSetWrapper.java
+2
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+72
-255
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/WrapperImpl.java
...tor/jdbc/src/main/java/com/taosdata/jdbc/WrapperImpl.java
+21
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
...src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
+25
-25
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
...dbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+2
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
+16
-911
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+2
-233
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
+138
-691
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
+3
-6
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
+12
-15
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
...bc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
+234
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InvalidResultSetPointerTest.java
.../com/taosdata/jdbc/cases/InvalidResultSetPointerTest.java
+187
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
.../test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
+11
-5
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+4
-1
tests/examples/python/taosdemo/README.md
tests/examples/python/taosdemo/README.md
+38
-0
tests/examples/python/taosdemo/requirements.txt
tests/examples/python/taosdemo/requirements.txt
+28
-0
tests/examples/python/taosdemo/taosdemo.py
tests/examples/python/taosdemo/taosdemo.py
+797
-0
tests/pytest/concurrent_inquiry.sh
tests/pytest/concurrent_inquiry.sh
+82
-0
tests/pytest/pytest_2.sh
tests/pytest/pytest_2.sh
+1
-6
tests/pytest/pytest_3.sh
tests/pytest/pytest_3.sh
+1
-20
tests/pytest/pytest_4.sh
tests/pytest/pytest_4.sh
+26
-0
tests/script/jenkins/basic_4.txt
tests/script/jenkins/basic_4.txt
+0
-11
tests/script/jenkins/basic_5.txt
tests/script/jenkins/basic_5.txt
+8
-0
tests/script/jenkins/basic_6.txt
tests/script/jenkins/basic_6.txt
+5
-0
tests/test-all.sh
tests/test-all.sh
+3
-0
未找到文件。
Jenkinsfile
浏览文件 @
42d5896b
...
...
@@ -80,25 +80,28 @@ pipeline {
}
steps
{
sh
'''
cd ${WORKSPACE}
cp -r ${WORKSPACE} ${WORKSPACE}.tes
cd ${WORKSPACE}.tes
git checkout develop
git pull
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
'''
script
{
skipstage
=
sh
(
script:
"git --no-pager diff --name-only FETCH_HEAD develop|grep -v -E '.*md|//src//connector|Jenkinsfile|test-all.sh' || echo
1
"
,
returnStdout:
true
)
skipstage
=
sh
(
script:
"git --no-pager diff --name-only FETCH_HEAD develop|grep -v -E '.*md|//src//connector|Jenkinsfile|test-all.sh' || echo
0
"
,
returnStdout:
true
)
}
sh
'''
rm -rf ${WORKSPACE}.tes
'''
}
}
stage
(
'Parallel test stage'
)
{
//only build pr
when
{
changeRequest
()
expression
{
skipstage
!=
1
skipstage
!=
0
}
}
parallel
{
...
...
@@ -124,12 +127,12 @@ pipeline {
pre_test
()
timeout
(
time:
45
,
unit:
'MINUTES'
){
sh
'''
date
cd ${WKC}/tests
find pytest -name '*'sql|xargs rm -rf
./test-all.sh p2
date'''
sh
'''
date
cd ${WKC}/tests
find pytest -name '*'sql|xargs rm -rf
./test-all.sh p2
date'''
}
}
}
...
...
@@ -161,6 +164,7 @@ pipeline {
stage
(
'test_crash_gen_s3'
)
{
agent
{
label
"b2"
}
steps
{
pre_test
()
catchError
(
buildResult:
'SUCCESS'
,
stageResult:
'FAILURE'
)
{
...
...
@@ -172,17 +176,20 @@ pipeline {
catchError
(
buildResult:
'SUCCESS'
,
stageResult:
'FAILURE'
)
{
sh
'''
cd ${WKC}/tests/pytest
rm -rf /var/lib/taos/*
rm -rf /var/log/taos/*
./handle_crash_gen_val_log.sh
'''
}
}
timeout
(
time:
45
,
unit:
'MINUTES'
){
sh
'''
date
cd ${WKC}/tests
./test-all.sh b2fq
date
'''
}
sh
'''
date
cd ${WKC}/tests
./test-all.sh b2fq
date
'''
}
}
}
...
...
@@ -216,6 +223,8 @@ pipeline {
date
cd ${WKC}/tests
./test-all.sh b4fq
cd ${WKC}/tests
./test-all.sh p4
date'''
}
}
...
...
cmake/install.inc
浏览文件 @
42d5896b
...
...
@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF
(
TD_MVN_INSTALLED
)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
-
jdbcdriver
-
2.0.1
8
-
dist
.
jar
DESTINATION
connector
/
jdbc
)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
-
jdbcdriver
-
2.0.1
9
-
dist
.
jar
DESTINATION
connector
/
jdbc
)
ENDIF
()
ELSEIF
(
TD_DARWIN
)
SET
(
TD_MAKE_INSTALL_SH
"${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh"
)
...
...
src/client/src/tscProfile.c
浏览文件 @
42d5896b
...
...
@@ -233,6 +233,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
// We extract the lock to tscBuildHeartBeatMsg function.
int64_t
now
=
taosGetTimestampMs
();
SSqlObj
*
pSql
=
pObj
->
sqlList
;
while
(
pSql
)
{
/*
...
...
@@ -247,7 +248,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
tstrncpy
(
pQdesc
->
sql
,
pSql
->
sqlstr
,
sizeof
(
pQdesc
->
sql
));
pQdesc
->
stime
=
htobe64
(
pSql
->
stime
);
pQdesc
->
queryId
=
htonl
(
pSql
->
queryId
);
pQdesc
->
useconds
=
htobe64
(
pSql
->
res
.
useconds
);
//pQdesc->useconds = htobe64(pSql->res.useconds);
pQdesc
->
useconds
=
htobe64
(
now
-
pSql
->
stime
);
pQdesc
->
qHandle
=
htobe64
(
pSql
->
res
.
qhandle
);
pHeartbeat
->
numOfQueries
++
;
...
...
src/client/src/tscSystem.c
浏览文件 @
42d5896b
...
...
@@ -64,7 +64,7 @@ void tscReleaseRpc(void *param) {
return
;
}
pthread_mutex_lock
(
&
rpcObjMutex
);
taosCacheRelease
(
tscRpcCache
,
(
void
*
)
&
param
,
tru
e
);
taosCacheRelease
(
tscRpcCache
,
(
void
*
)
&
param
,
fals
e
);
pthread_mutex_unlock
(
&
rpcObjMutex
);
}
...
...
@@ -101,7 +101,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
tscError
(
"failed to init connection to TDengine"
);
return
-
1
;
}
pRpcObj
=
taosCachePut
(
tscRpcCache
,
rpcObj
.
key
,
strlen
(
rpcObj
.
key
),
&
rpcObj
,
sizeof
(
rpcObj
),
1000
*
10
);
pRpcObj
=
taosCachePut
(
tscRpcCache
,
rpcObj
.
key
,
strlen
(
rpcObj
.
key
),
&
rpcObj
,
sizeof
(
rpcObj
),
1000
*
5
);
if
(
pRpcObj
==
NULL
)
{
rpcClose
(
rpcObj
.
pDnodeConn
);
pthread_mutex_unlock
(
&
rpcObjMutex
);
...
...
@@ -154,6 +154,7 @@ void taos_init_imp(void) {
if
(
tscNumOfThreads
<
2
)
{
tscNumOfThreads
=
2
;
}
taosTmrThreads
=
tscNumOfThreads
;
tscQhandle
=
taosInitScheduler
(
queueSize
,
tscNumOfThreads
,
"tsc"
);
if
(
NULL
==
tscQhandle
)
{
...
...
src/connector/jdbc/CMakeLists.txt
浏览文件 @
42d5896b
...
...
@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
JDBC_CMD_NAME
}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f
${
CMAKE_CURRENT_SOURCE_DIR
}
/pom.xml
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/target/taos-jdbcdriver-2.0.1
8
-dist.jar
${
LIBRARY_OUTPUT_PATH
}
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/target/taos-jdbcdriver-2.0.1
9
-dist.jar
${
LIBRARY_OUTPUT_PATH
}
COMMAND mvn -Dmaven.test.skip=true clean -f
${
CMAKE_CURRENT_SOURCE_DIR
}
/pom.xml
COMMENT
"build jdbc driver"
)
ADD_CUSTOM_TARGET
(
${
JDBC_TARGET_NAME
}
ALL WORKING_DIRECTORY
${
EXECUTABLE_OUTPUT_PATH
}
DEPENDS
${
JDBC_CMD_NAME
}
)
...
...
src/connector/jdbc/deploy-pom.xml
浏览文件 @
42d5896b
...
...
@@ -5,7 +5,7 @@
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
8
</version>
<version>
2.0.1
9
</version>
<packaging>
jar
</packaging>
<name>
JDBCDriver
</name>
...
...
src/connector/jdbc/pom.xml
浏览文件 @
42d5896b
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
8
</version>
<version>
2.0.1
9
</version>
<packaging>
jar
</packaging>
<name>
JDBCDriver
</name>
<url>
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
</url>
...
...
@@ -81,8 +81,6 @@
<artifactId>
commons-dbcp2
</artifactId>
<version>
2.7.0
</version>
</dependency>
</dependencies>
<build>
...
...
@@ -132,6 +130,7 @@
<exclude>
**/AppMemoryLeakTest.java
</exclude>
<exclude>
**/TaosInfoMonitorTest.java
</exclude>
<exclude>
**/FailOverTest.java
</exclude>
<exclude>
**/InvalidResultSetPointerTest.java
</exclude>
</excludes>
<testFailureIgnore>
true
</testFailureIgnore>
</configuration>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/Abstract
Taos
Driver.java
→
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java
浏览文件 @
42d5896b
...
...
@@ -8,7 +8,7 @@ import java.util.List;
import
java.util.Properties
;
import
java.util.StringTokenizer
;
public
abstract
class
Abstract
Taos
Driver
implements
Driver
{
public
abstract
class
AbstractDriver
implements
Driver
{
private
static
final
String
TAOS_CFG_FILENAME
=
"taos.cfg"
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java
0 → 100644
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
0 → 100644
浏览文件 @
42d5896b
package
com.taosdata.jdbc
;
import
java.sql.*
;
public
abstract
class
AbstractStatement
extends
WrapperImpl
implements
Statement
{
private
volatile
boolean
closeOnCompletion
;
private
int
fetchSize
;
@Override
public
abstract
ResultSet
executeQuery
(
String
sql
)
throws
SQLException
;
@Override
public
abstract
int
executeUpdate
(
String
sql
)
throws
SQLException
;
@Override
public
abstract
void
close
()
throws
SQLException
;
@Override
public
int
getMaxFieldSize
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
TSDBConstants
.
maxFieldSize
;
}
@Override
public
void
setMaxFieldSize
(
int
max
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
max
<
0
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
// nothing to do
}
@Override
public
int
getMaxRows
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
0
;
}
@Override
public
void
setMaxRows
(
int
max
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
max
<
0
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
// nothing to do
}
@Override
public
void
setEscapeProcessing
(
boolean
enable
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
@Override
public
int
getQueryTimeout
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
0
;
}
@Override
public
void
setQueryTimeout
(
int
seconds
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
seconds
<
0
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
}
@Override
public
void
cancel
()
throws
SQLException
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
SQLWarning
getWarnings
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
null
;
}
@Override
public
void
clearWarnings
()
throws
SQLException
{
// nothing to do
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
@Override
public
void
setCursorName
(
String
name
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
abstract
boolean
execute
(
String
sql
)
throws
SQLException
;
@Override
public
abstract
ResultSet
getResultSet
()
throws
SQLException
;
@Override
public
abstract
int
getUpdateCount
()
throws
SQLException
;
@Override
public
boolean
getMoreResults
()
throws
SQLException
{
return
getMoreResults
(
CLOSE_CURRENT_RESULT
);
}
@Override
public
void
setFetchDirection
(
int
direction
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
//nothing to do
}
@Override
public
int
getFetchDirection
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
FETCH_FORWARD
;
}
@Override
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
rows
<
0
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
//nothing to do
this
.
fetchSize
=
rows
;
}
@Override
public
int
getFetchSize
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
fetchSize
;
}
@Override
public
int
getResultSetConcurrency
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
CONCUR_READ_ONLY
;
}
@Override
public
int
getResultSetType
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
TYPE_FORWARD_ONLY
;
}
@Override
public
abstract
void
addBatch
(
String
sql
)
throws
SQLException
;
@Override
public
abstract
void
clearBatch
()
throws
SQLException
;
@Override
public
abstract
int
[]
executeBatch
()
throws
SQLException
;
@Override
public
abstract
Connection
getConnection
()
throws
SQLException
;
@Override
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
false
;
}
@Override
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
@Override
public
int
getResultSetHoldability
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
;
}
@Override
public
abstract
boolean
isClosed
()
throws
SQLException
;
@Override
public
void
setPoolable
(
boolean
poolable
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
//nothing to do
}
@Override
public
boolean
isPoolable
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
false
;
}
@Override
public
void
closeOnCompletion
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
this
.
closeOnCompletion
=
true
;
}
@Override
public
boolean
isCloseOnCompletion
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
closeOnCompletion
;
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/DatabaseMetaDataResultSet.java
浏览文件 @
42d5896b
...
...
@@ -160,12 +160,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
Date
getDate
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Time
getTime
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -176,17 +176,17 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
InputStream
getAsciiStream
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
InputStream
getUnicodeStream
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
InputStream
getBinaryStream
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -256,22 +256,22 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
InputStream
getAsciiStream
(
String
columnLabel
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
InputStream
getUnicodeStream
(
String
columnLabel
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
InputStream
getBinaryStream
(
String
columnLabel
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
SQLWarning
getWarnings
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -281,7 +281,7 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
String
getCursorName
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -313,12 +313,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
Reader
getCharacterStream
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Reader
getCharacterStream
(
String
columnLabel
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -353,22 +353,22 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
void
beforeFirst
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
afterLast
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
boolean
first
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
boolean
last
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -383,17 +383,17 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
boolean
absolute
(
int
row
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
boolean
relative
(
int
rows
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
boolean
previous
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -443,227 +443,227 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
void
updateNull
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBoolean
(
int
columnIndex
,
boolean
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateByte
(
int
columnIndex
,
byte
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateShort
(
int
columnIndex
,
short
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateInt
(
int
columnIndex
,
int
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateLong
(
int
columnIndex
,
long
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateFloat
(
int
columnIndex
,
float
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateDouble
(
int
columnIndex
,
double
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBigDecimal
(
int
columnIndex
,
BigDecimal
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateString
(
int
columnIndex
,
String
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBytes
(
int
columnIndex
,
byte
[]
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateDate
(
int
columnIndex
,
Date
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateTime
(
int
columnIndex
,
Time
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateTimestamp
(
int
columnIndex
,
Timestamp
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateAsciiStream
(
int
columnIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBinaryStream
(
int
columnIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateCharacterStream
(
int
columnIndex
,
Reader
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateObject
(
int
columnIndex
,
Object
x
,
int
scaleOrLength
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateObject
(
int
columnIndex
,
Object
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateNull
(
String
columnLabel
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBoolean
(
String
columnLabel
,
boolean
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateByte
(
String
columnLabel
,
byte
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateShort
(
String
columnLabel
,
short
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateInt
(
String
columnLabel
,
int
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateLong
(
String
columnLabel
,
long
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateFloat
(
String
columnLabel
,
float
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateDouble
(
String
columnLabel
,
double
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBigDecimal
(
String
columnLabel
,
BigDecimal
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateString
(
String
columnLabel
,
String
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBytes
(
String
columnLabel
,
byte
[]
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateDate
(
String
columnLabel
,
Date
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateTime
(
String
columnLabel
,
Time
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateTimestamp
(
String
columnLabel
,
Timestamp
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateAsciiStream
(
String
columnLabel
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateBinaryStream
(
String
columnLabel
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateCharacterStream
(
String
columnLabel
,
Reader
reader
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateObject
(
String
columnLabel
,
Object
x
,
int
scaleOrLength
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateObject
(
String
columnLabel
,
Object
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
insertRow
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
updateRow
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
deleteRow
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
refreshRow
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
cancelRowUpdates
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
moveToInsertRow
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
moveToCurrentRow
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -673,12 +673,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
Object
getObject
(
int
columnIndex
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Ref
getRef
(
int
columnIndex
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -1043,12 +1043,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override
public
<
T
>
T
getObject
(
int
columnIndex
,
Class
<
T
>
type
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
<
T
>
T
getObject
(
String
columnLabel
,
Class
<
T
>
type
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java
浏览文件 @
42d5896b
...
...
@@ -20,7 +20,7 @@ import java.util.Map;
public
abstract
class
TSDBConstants
{
public
static
final
String
STATEMENT_CLOSED
=
"statement is closed"
;
public
static
final
String
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
=
"this operation is NOT supported currently!"
;
public
static
final
String
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
=
"this operation is NOT supported currently!"
;
public
static
final
String
INVALID_VARIABLES
=
"invalid variables"
;
public
static
final
String
RESULT_SET_IS_CLOSED
=
"resultSet is closed"
;
...
...
@@ -36,6 +36,7 @@ public abstract class TSDBConstants {
public
static
final
int
JNI_NUM_OF_FIELDS_0
=
-
4
;
public
static
final
int
JNI_SQL_NULL
=
-
5
;
public
static
final
int
JNI_FETCH_END
=
-
6
;
public
static
final
int
JNI_OUT_OF_MEMORY
=
-
7
;
public
static
final
int
TSDB_DATA_TYPE_NULL
=
0
;
public
static
final
int
TSDB_DATA_TYPE_BOOL
=
1
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
42d5896b
...
...
@@ -37,7 +37,7 @@ import java.util.logging.Logger;
* register it with the DriverManager. This means that a user can load and
* register a driver by doing Class.forName("foo.bah.Driver")
*/
public
class
TSDBDriver
extends
Abstract
Taos
Driver
{
public
class
TSDBDriver
extends
AbstractDriver
{
@Deprecated
private
static
final
String
URL_PREFIX1
=
"jdbc:TSDB://"
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
浏览文件 @
42d5896b
package
com.taosdata.jdbc
;
import
java.sql.SQLException
;
import
java.sql.SQLFeatureNotSupportedException
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -13,8 +14,23 @@ public class TSDBError {
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
,
"invalid variables"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
,
"statement is closed"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
,
"resultSet is closed"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_BATCH_IS_EMPTY
,
"Batch is empty!"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_INVALID_WITH_EXECUTEQUERY
,
"Can not issue data manipulation statements with executeQuery()"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_INVALID_WITH_EXECUTEUPDATE
,
"Can not issue SELECT via executeUpdate()"
);
/**************************************************/
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
,
"unknown error"
);
/**************************************************/
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_SUBSCRIBE_FAILED
,
"failed to create subscription"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_ENCODING
,
"Unsupported encoding"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_TDENGINE_ERROR
,
"internal error of database!"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
,
"JNI connection already closed!"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
,
"invalid JNI result set!"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_NUM_OF_FIELDS_0
,
"invalid num of fields!"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_SQL_NULL
,
"empty sql string!"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_FETCH_END
,
"fetch to the end of resultset"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_OUT_OF_MEMORY
,
"JNI alloc memory failed!"
);
}
public
static
String
wrapErrMsg
(
String
msg
)
{
...
...
@@ -22,10 +38,24 @@ public class TSDBError {
}
public
static
SQLException
createSQLException
(
int
errorNumber
)
{
// JDBC exception code is less than 0x2350
if
(
errorNumber
<=
0x2350
)
return
new
SQLException
(
TSDBErrorMap
.
get
(
errorNumber
));
// JNI exception code is
return
new
SQLException
(
wrapErrMsg
(
TSDBErrorMap
.
get
(
errorNumber
)));
return
createSQLException
(
errorNumber
,
null
);
}
public
static
SQLException
createSQLException
(
int
errorNumber
,
String
message
)
{
if
(
message
==
null
||
message
.
isEmpty
())
{
if
(
TSDBErrorNumbers
.
contains
(
errorNumber
))
message
=
TSDBErrorMap
.
get
(
errorNumber
);
else
message
=
TSDBErrorMap
.
get
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
);
}
if
(
errorNumber
==
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
)
return
new
SQLFeatureNotSupportedException
(
message
);
if
(
errorNumber
<
TSDBErrorNumbers
.
ERROR_UNKNOWN
)
// JDBC exception's error number is less than 0x2350
return
new
SQLException
(
"ERROR ("
+
Integer
.
toHexString
(
errorNumber
)
+
"): "
+
message
);
// JNI exception's error number is large than 0x2350
return
new
SQLException
(
"TDengine ERROR ("
+
Integer
.
toHexString
(
errorNumber
)
+
"): "
+
message
);
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
浏览文件 @
42d5896b
package
com.taosdata.jdbc
;
import
java.util.HashSet
;
public
class
TSDBErrorNumbers
{
public
static
final
int
ERROR_CONNECTION_CLOSED
=
0x2301
;
// connection already closed
...
...
@@ -7,9 +9,52 @@ public class TSDBErrorNumbers {
public
static
final
int
ERROR_INVALID_VARIABLE
=
0x2303
;
//invalid variables
public
static
final
int
ERROR_STATEMENT_CLOSED
=
0x2304
;
//statement already closed
public
static
final
int
ERROR_RESULTSET_CLOSED
=
0x2305
;
//resultSet is closed
public
static
final
int
ERROR_BATCH_IS_EMPTY
=
0x2306
;
//Batch is empty!
public
static
final
int
ERROR_INVALID_WITH_EXECUTEQUERY
=
0x2307
;
//Can not issue data manipulation statements with executeQuery()
public
static
final
int
ERROR_INVALID_WITH_EXECUTEUPDATE
=
0x2308
;
//Can not issue SELECT via executeUpdate()
public
static
final
int
ERROR_UNKNOWN
=
0x2350
;
//unknown error
public
static
final
int
ERROR_SUBSCRIBE_FAILED
=
0x2351
;
//failed to create subscription
public
static
final
int
ERROR_UNSUPPORTED_ENCODING
=
0x2352
;
//Unsupported encoding
public
static
final
int
ERROR_JNI_TDENGINE_ERROR
=
0x2353
;
public
static
final
int
ERROR_JNI_CONNECTION_NULL
=
0x2354
;
//invalid tdengine connection!
public
static
final
int
ERROR_JNI_RESULT_SET_NULL
=
0x2355
;
public
static
final
int
ERROR_JNI_NUM_OF_FIELDS_0
=
0x2356
;
public
static
final
int
ERROR_JNI_SQL_NULL
=
0x2357
;
public
static
final
int
ERROR_JNI_FETCH_END
=
0x2358
;
public
static
final
int
ERROR_JNI_OUT_OF_MEMORY
=
0x2359
;
private
static
final
HashSet
<
Integer
>
errorNumbers
;
public
static
final
int
ERROR_SUBSCRIBE_FAILED
=
0x2350
;
//failed to create subscription
static
{
errorNumbers
=
new
HashSet
();
errorNumbers
.
add
(
ERROR_CONNECTION_CLOSED
);
errorNumbers
.
add
(
ERROR_UNSUPPORTED_METHOD
);
errorNumbers
.
add
(
ERROR_INVALID_VARIABLE
);
errorNumbers
.
add
(
ERROR_STATEMENT_CLOSED
);
errorNumbers
.
add
(
ERROR_RESULTSET_CLOSED
);
errorNumbers
.
add
(
ERROR_INVALID_WITH_EXECUTEQUERY
);
errorNumbers
.
add
(
ERROR_INVALID_WITH_EXECUTEUPDATE
);
/*****************************************************/
errorNumbers
.
add
(
ERROR_SUBSCRIBE_FAILED
);
errorNumbers
.
add
(
ERROR_UNSUPPORTED_ENCODING
);
errorNumbers
.
add
(
ERROR_JNI_TDENGINE_ERROR
);
errorNumbers
.
add
(
ERROR_JNI_CONNECTION_NULL
);
errorNumbers
.
add
(
ERROR_JNI_RESULT_SET_NULL
);
errorNumbers
.
add
(
ERROR_JNI_NUM_OF_FIELDS_0
);
errorNumbers
.
add
(
ERROR_JNI_SQL_NULL
);
errorNumbers
.
add
(
ERROR_JNI_FETCH_END
);
errorNumbers
.
add
(
ERROR_JNI_OUT_OF_MEMORY
);
}
private
TSDBErrorNumbers
()
{
}
public
static
boolean
contains
(
int
errorNumber
)
{
return
errorNumbers
.
contains
(
errorNumber
);
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
42d5896b
...
...
@@ -38,7 +38,7 @@ public class TSDBJNIConnector {
/**
* Result set pointer for the current connection
*/
private
long
taosResultSetPointer
=
TSDBConstants
.
JNI_NULL_POINTER
;
//
private long taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
/**
* result set status in current connection
...
...
@@ -119,9 +119,9 @@ public class TSDBJNIConnector {
public
long
executeQuery
(
String
sql
)
throws
SQLException
{
// close previous result set if the user forgets to invoke the
// free method to close previous result set.
if
(!
this
.
isResultsetClosed
)
{
freeResultSet
(
taosResultSetPointer
);
}
//
if (!this.isResultsetClosed) {
//
freeResultSet(taosResultSetPointer);
//
}
Long
pSql
=
0
l
;
try
{
...
...
@@ -130,21 +130,32 @@ public class TSDBJNIConnector {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"Unsupported encoding"
));
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_ENCODING
);
}
if
(
pSql
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
}
if
(
pSql
==
TSDBConstants
.
JNI_SQL_NULL
)
{
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_SQL_NULL
);
}
if
(
pSql
==
TSDBConstants
.
JNI_OUT_OF_MEMORY
)
{
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_OUT_OF_MEMORY
);
}
int
code
=
this
.
getErrCode
(
pSql
);
if
(
code
!=
0
)
{
if
(
code
!=
TSDBConstants
.
JNI_SUCCESS
)
{
affectedRows
=
-
1
;
String
msg
=
this
.
getErrMsg
(
pSql
);
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
msg
),
""
,
code
);
throw
TSDBError
.
createSQLException
(
code
,
msg
);
}
// Try retrieving result set for the executed SQL using the current connection pointer.
taosResultSetPointer
=
this
.
getResultSetImp
(
this
.
taos
,
pSql
);
isResultsetClosed
=
(
taosResultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
);
pSql
=
this
.
getResultSetImp
(
this
.
taos
,
pSql
);
isResultsetClosed
=
(
pSql
==
TSDBConstants
.
JNI_NULL_POINTER
);
return
pSql
;
}
...
...
@@ -173,9 +184,9 @@ public class TSDBJNIConnector {
* Get resultset pointer
* Each connection should have a single open result set at a time
*/
public
long
getResultSet
()
{
return
taosResultSetPointer
;
}
//
public long getResultSet() {
//
return taosResultSetPointer;
//
}
private
native
long
getResultSetImp
(
long
connection
,
long
pSql
);
...
...
@@ -188,16 +199,16 @@ public class TSDBJNIConnector {
/**
* Free resultset operation from C to release resultset pointer by JNI
*/
public
int
freeResultSet
(
long
result
)
{
public
int
freeResultSet
(
long
pSql
)
{
int
res
=
TSDBConstants
.
JNI_SUCCESS
;
if
(
result
!=
taosResultSetPointer
&&
taosResultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
throw
new
RuntimeException
(
"Invalid result set pointer"
);
}
//
if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
//
throw new RuntimeException("Invalid result set pointer");
//
}
if
(
taosResultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
res
=
this
.
freeResultSetImp
(
this
.
taos
,
result
);
taosResultSetPointer
=
TSDBConstants
.
JNI_NULL_POINTER
;
}
//
if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
res
=
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
//
taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
//
}
isResultsetClosed
=
true
;
return
res
;
...
...
@@ -207,15 +218,15 @@ public class TSDBJNIConnector {
* Close the open result set which is associated to the current connection. If the result set is already
* closed, return 0 for success.
*/
public
int
freeResultSet
()
{
int
resCode
=
TSDBConstants
.
JNI_SUCCESS
;
if
(!
isResultsetClosed
)
{
resCode
=
this
.
freeResultSetImp
(
this
.
taos
,
this
.
taosResultSetPointer
);
taosResultSetPointer
=
TSDBConstants
.
JNI_NULL_POINTER
;
isResultsetClosed
=
true
;
}
return
resCode
;
}
//
public int freeResultSet() {
//
int resCode = TSDBConstants.JNI_SUCCESS;
//
if (!isResultsetClosed) {
//
resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer);
//
taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
//
isResultsetClosed = true;
//
}
//
return resCode;
//
}
private
native
int
freeResultSetImp
(
long
connection
,
long
result
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java
浏览文件 @
42d5896b
...
...
@@ -264,17 +264,17 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
@Override
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setUnicodeStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -284,7 +284,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
@Override
public
void
setObject
(
int
parameterIndex
,
Object
x
,
int
targetSqlType
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -321,156 +321,156 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
@Override
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
,
int
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setRef
(
int
parameterIndex
,
Ref
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setBlob
(
int
parameterIndex
,
Blob
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setClob
(
int
parameterIndex
,
Clob
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setArray
(
int
parameterIndex
,
Array
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
ResultSetMetaData
getMetaData
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setDate
(
int
parameterIndex
,
Date
x
,
Calendar
cal
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setTime
(
int
parameterIndex
,
Time
x
,
Calendar
cal
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
,
Calendar
cal
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNull
(
int
parameterIndex
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setURL
(
int
parameterIndex
,
URL
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
ParameterMetaData
getParameterMetaData
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setRowId
(
int
parameterIndex
,
RowId
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNString
(
int
parameterIndex
,
String
value
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNCharacterStream
(
int
parameterIndex
,
Reader
value
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNClob
(
int
parameterIndex
,
NClob
value
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setClob
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setBlob
(
int
parameterIndex
,
InputStream
inputStream
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNClob
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setSQLXML
(
int
parameterIndex
,
SQLXML
xmlObject
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setObject
(
int
parameterIndex
,
Object
x
,
int
targetSqlType
,
int
scaleOrLength
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNCharacterStream
(
int
parameterIndex
,
Reader
value
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setClob
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setBlob
(
int
parameterIndex
,
InputStream
inputStream
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
setNClob
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java
浏览文件 @
42d5896b
...
...
@@ -29,11 +29,11 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
}
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
int
getColumnCount
()
throws
SQLException
{
...
...
@@ -94,7 +94,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
}
public
String
getSchemaName
(
int
column
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
int
getPrecision
(
int
column
)
throws
SQLException
{
...
...
@@ -125,11 +125,11 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
}
public
String
getTableName
(
int
column
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
String
getCatalogName
(
int
column
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
int
getColumnType
(
int
column
)
throws
SQLException
{
...
...
@@ -173,7 +173,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
}
public
boolean
isDefinitelyWritable
(
int
column
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
String
getColumnClassName
(
int
column
)
throws
SQLException
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetWrapper.java
浏览文件 @
42d5896b
...
...
@@ -1153,11 +1153,11 @@ public class TSDBResultSetWrapper implements ResultSet {
}
public
<
T
>
T
getObject
(
int
columnIndex
,
Class
<
T
>
type
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
public
<
T
>
T
getObject
(
String
columnLabel
,
Class
<
T
>
type
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
42d5896b
...
...
@@ -14,34 +14,24 @@
*****************************************************************************/
package
com.taosdata.jdbc
;
import
com.taosdata.jdbc.utils.TaosInfo
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TSDBStatement
implements
Statement
{
private
TSDBJNIConnector
connector
;
public
class
TSDBStatement
extends
AbstractStatement
{
private
TSDBJNIConnector
connector
;
/**
* To store batched commands
*/
protected
List
<
String
>
batchedArgs
;
/**
* Timeout for a query
*/
protected
int
queryTimeout
=
0
;
private
Long
pSql
=
0
l
;
/**
* Status of current statement
*/
private
boolean
isClosed
=
true
;
private
int
affectedRows
=
0
;
private
boolean
isClosed
;
private
int
affectedRows
=
-
1
;
private
TSDBConnection
connection
;
private
TSDBResultSet
resultSet
;
public
void
setConnection
(
TSDBConnection
connection
)
{
this
.
connection
=
connection
;
...
...
@@ -50,220 +40,89 @@ public class TSDBStatement implements Statement {
TSDBStatement
(
TSDBConnection
connection
,
TSDBJNIConnector
connector
)
{
this
.
connection
=
connection
;
this
.
connector
=
connector
;
this
.
isClosed
=
false
;
}
@Override
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
try
{
return
iface
.
cast
(
this
);
}
catch
(
ClassCastException
cce
)
{
throw
new
SQLException
(
"Unable to unwrap to "
+
iface
.
toString
());
}
}
@Override
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
return
iface
.
isInstance
(
this
);
}
public
ResultSet
executeQuery
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
{
// check if closed
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
//TODO: 如果在executeQuery方法中执行insert语句,那么先执行了SQL,再通过pSql来检查是否为一个insert语句,但这个insert SQL已经执行成功了
//
TODO make sure it is not a upda
te query
pSql
=
this
.
connector
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connector
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
//
execu
te query
long
pSql
=
this
.
connector
.
executeQuery
(
sql
);
// if pSql is create/insert/update/delete/alter SQL
if
(
this
.
connector
.
isUpdateQuery
(
pSql
)
)
{
this
.
connector
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
// create/insert/update/delete/alter
if
(
resultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
this
.
connector
.
freeResultSet
(
pSql
);
return
null
;
}
if
(!
this
.
connector
.
isUpdateQuery
(
pSql
))
{
TSDBResultSet
res
=
new
TSDBResultSet
(
this
.
connector
,
resultSetPointer
);
res
.
setBatchFetch
(
this
.
connection
.
getBatchFetch
());
return
res
;
}
else
{
this
.
connector
.
freeResultSet
(
pSql
);
return
null
;
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_WITH_EXECUTEQUERY
);
}
TSDBResultSet
res
=
new
TSDBResultSet
(
this
,
this
.
connector
,
pSql
);
res
.
setBatchFetch
(
this
.
connection
.
getBatchFetch
());
return
res
;
}
public
int
executeUpdate
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
// TODO check if current query is update query
pSql
=
this
.
connector
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connector
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
long
pSql
=
this
.
connector
.
executeQuery
(
sql
);
// if pSql is create/insert/update/delete/alter SQL
if
(!
this
.
connector
.
isUpdateQuery
(
pSql
))
{
this
.
connector
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
)
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_WITH_EXECUTEUPDATE
);
}
this
.
affectedRows
=
this
.
connector
.
getAffectedRows
(
pSql
);
int
affectedRows
=
this
.
connector
.
getAffectedRows
(
pSql
);
this
.
connector
.
freeResultSet
(
pSql
);
return
this
.
affectedRows
;
}
public
String
getErrorMsg
(
long
pSql
)
{
return
this
.
connector
.
getErrMsg
(
pSql
);
return
affectedRows
;
}
public
void
close
()
throws
SQLException
{
if
(!
isClosed
)
{
if
(!
this
.
connector
.
isResultsetClosed
())
{
this
.
connector
.
freeResultSet
();
}
if
(
this
.
resultSet
!=
null
)
this
.
resultSet
.
close
();
isClosed
=
true
;
}
}
public
int
getMaxFieldSize
()
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
return
0
;
}
public
void
setMaxFieldSize
(
int
max
)
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
getMaxRows
()
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
// always set maxRows to zero, meaning unlimitted rows in a resultSet
return
0
;
}
public
void
setMaxRows
(
int
max
)
throws
SQLException
{
if
(
isClosed
())
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
}
// always set maxRows to zero, meaning unlimited rows in a resultSet
}
public
void
setEscapeProcessing
(
boolean
enable
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
getQueryTimeout
()
throws
SQLException
{
return
queryTimeout
;
}
public
void
setQueryTimeout
(
int
seconds
)
throws
SQLException
{
this
.
queryTimeout
=
seconds
;
}
public
void
cancel
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
SQLWarning
getWarnings
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
void
clearWarnings
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
void
setCursorName
(
String
name
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
execute
(
String
sql
)
throws
SQLException
{
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
boolean
res
=
true
;
pSql
=
this
.
connector
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connector
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
connector
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
else
if
(
resultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
// no result set is retrieved
// check if closed
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
// execute query
long
pSql
=
this
.
connector
.
executeQuery
(
sql
);
// if pSql is create/insert/update/delete/alter SQL
if
(
this
.
connector
.
isUpdateQuery
(
pSql
))
{
this
.
affectedRows
=
this
.
connector
.
getAffectedRows
(
pSql
);
this
.
connector
.
freeResultSet
(
pSql
);
re
s
=
false
;
re
turn
false
;
}
return
res
;
this
.
resultSet
=
new
TSDBResultSet
(
this
,
this
.
connector
,
pSql
);
this
.
resultSet
.
setBatchFetch
(
this
.
connection
.
getBatchFetch
());
return
true
;
}
public
ResultSet
getResultSet
()
throws
SQLException
{
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
long
resultSetPointer
=
connector
.
getResultSet
();
TSDBResultSet
resSet
=
null
;
if
(
resultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
resSet
=
new
TSDBResultSet
(
connector
,
resultSetPointer
);
}
return
resSet
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
// long resultSetPointer = connector.getResultSet();
// TSDBResultSet resSet = null;
// if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
// resSet = new TSDBResultSet(connector, resultSetPointer);
// }
return
this
.
resultSet
;
}
public
int
getUpdateCount
()
throws
SQLException
{
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
affectedRows
;
}
public
boolean
getMoreResults
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
void
setFetchDirection
(
int
direction
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
getFetchDirection
()
throws
SQLException
{
return
ResultSet
.
FETCH_FORWARD
;
// throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
/*
* used by spark
*/
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
}
/*
* used by spark
*/
public
int
getFetchSize
()
throws
SQLException
{
return
4096
;
}
public
int
getResultSetConcurrency
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
getResultSetType
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
==
null
)
{
batchedArgs
=
new
ArrayList
<>();
}
...
...
@@ -271,83 +130,41 @@ public class TSDBStatement implements Statement {
}
public
void
clearBatch
()
throws
SQLException
{
batchedArgs
.
clear
();
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
!=
null
)
batchedArgs
.
clear
();
}
public
int
[]
executeBatch
()
throws
SQLException
{
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
if
(
batchedArgs
==
null
)
{
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"Batch is empty!"
));
}
else
{
int
[]
res
=
new
int
[
batchedArgs
.
size
()];
for
(
int
i
=
0
;
i
<
batchedArgs
.
size
();
i
++)
{
res
[
i
]
=
executeUpdate
(
batchedArgs
.
get
(
i
));
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
==
null
||
batchedArgs
.
isEmpty
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_BATCH_IS_EMPTY
);
int
[]
res
=
new
int
[
batchedArgs
.
size
()];
for
(
int
i
=
0
;
i
<
batchedArgs
.
size
();
i
++)
{
boolean
isSelect
=
execute
(
batchedArgs
.
get
(
i
));
if
(
isSelect
)
{
res
[
i
]
=
SUCCESS_NO_INFO
;
}
else
{
res
[
i
]
=
getUpdateCount
();
}
return
res
;
}
return
res
;
}
public
Connection
getConnection
()
throws
SQLException
{
if
(
this
.
connector
!=
null
)
return
this
.
connection
;
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
int
getResultSetHoldability
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
this
.
connector
==
null
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
return
this
.
connection
;
}
public
boolean
isClosed
()
throws
SQLException
{
return
isClosed
;
}
public
void
setPoolable
(
boolean
poolable
)
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
isPoolable
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
void
closeOnCompletion
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
public
boolean
isCloseOnCompletion
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java
浏览文件 @
42d5896b
...
...
@@ -50,7 +50,7 @@ public class TSDBSubscribe {
}
else
if
(
resultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
return
null
;
}
else
{
return
new
TSDBResultSet
(
this
.
connecter
,
resultSetPointer
);
return
new
TSDBResultSet
(
null
,
this
.
connecter
,
resultSetPointer
);
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/WrapperImpl.java
0 → 100644
浏览文件 @
42d5896b
package
com.taosdata.jdbc
;
import
java.sql.SQLException
;
import
java.sql.Wrapper
;
public
class
WrapperImpl
implements
Wrapper
{
@Override
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
try
{
return
iface
.
cast
(
this
);
}
catch
(
ClassCastException
cce
)
{
throw
new
SQLException
(
"Unable to unwrap to "
+
iface
.
toString
());
}
}
@Override
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
return
iface
.
isInstance
(
this
);
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
浏览文件 @
42d5896b
...
...
@@ -47,7 +47,7 @@ public class RestfulConnection implements Connection {
if
(
isClosed
())
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
//TODO: prepareStatement
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -55,7 +55,7 @@ public class RestfulConnection implements Connection {
if
(
isClosed
())
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -72,7 +72,7 @@ public class RestfulConnection implements Connection {
if
(
isClosed
())
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
if
(!
autoCommit
)
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -162,7 +162,7 @@ public class RestfulConnection implements Connection {
case
Connection
.
TRANSACTION_READ_COMMITTED
:
case
Connection
.
TRANSACTION_REPEATABLE_READ
:
case
Connection
.
TRANSACTION_SERIALIZABLE
:
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
default
:
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
}
...
...
@@ -197,10 +197,10 @@ public class RestfulConnection implements Connection {
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
if
(
resultSetType
!=
ResultSet
.
TYPE_FORWARD_ONLY
)
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
if
(
resultSetConcurrency
!=
ResultSet
.
CONCUR_READ_ONLY
)
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
return
createStatement
();
}
...
...
@@ -221,7 +221,7 @@ public class RestfulConnection implements Connection {
if
(
resultSetType
!=
ResultSet
.
TYPE_FORWARD_ONLY
||
resultSetConcurrency
!=
ResultSet
.
CONCUR_READ_ONLY
)
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
INVALID_VARIABLES
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -252,7 +252,7 @@ public class RestfulConnection implements Connection {
if
(
isClosed
())
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
if
(
holdability
!=
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
)
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -269,7 +269,7 @@ public class RestfulConnection implements Connection {
if
(
getAutoCommit
())
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
//nothing to do
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -279,7 +279,7 @@ public class RestfulConnection implements Connection {
if
(
getAutoCommit
())
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
//nothing to do
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -289,68 +289,68 @@ public class RestfulConnection implements Connection {
if
(
getAutoCommit
())
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
//nothing to do
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
void
releaseSavepoint
(
Savepoint
savepoint
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
if
(
resultSetHoldability
!=
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
)
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
return
createStatement
(
resultSetType
,
resultSetConcurrency
);
}
@Override
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
if
(
resultSetHoldability
!=
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
)
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
return
prepareStatement
(
sql
,
resultSetType
,
resultSetConcurrency
);
}
@Override
public
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
PreparedStatement
prepareStatement
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
PreparedStatement
prepareStatement
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
PreparedStatement
prepareStatement
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Clob
createClob
()
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Blob
createBlob
()
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
NClob
createNClob
()
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
SQLXML
createSQLXML
()
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -399,12 +399,12 @@ public class RestfulConnection implements Connection {
@Override
public
Array
createArrayOf
(
String
typeName
,
Object
[]
elements
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
public
Struct
createStruct
(
String
typeName
,
Object
[]
attributes
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
@@ -442,7 +442,7 @@ public class RestfulConnection implements Connection {
public
void
setNetworkTimeout
(
Executor
executor
,
int
milliseconds
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
CONNECTION_IS_CLOSED
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
_METHOD_EXCEPTIONZ
_MSG
);
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT
ED_METHOD_EXCEPTION
_MSG
);
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
浏览文件 @
42d5896b
...
...
@@ -2,7 +2,7 @@ package com.taosdata.jdbc.rs;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.taosdata.jdbc.Abstract
Taos
Driver
;
import
com.taosdata.jdbc.AbstractDriver
;
import
com.taosdata.jdbc.TSDBConstants
;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.rs.util.HttpClientPoolUtil
;
...
...
@@ -11,7 +11,7 @@ import java.sql.*;
import
java.util.Properties
;
import
java.util.logging.Logger
;
public
class
RestfulDriver
extends
Abstract
Taos
Driver
{
public
class
RestfulDriver
extends
AbstractDriver
{
private
static
final
String
URL_PREFIX
=
"jdbc:TAOS-RS://"
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
42d5896b
...
...
@@ -2,6 +2,7 @@ package com.taosdata.jdbc.rs;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.taosdata.jdbc.AbstractStatement
;
import
com.taosdata.jdbc.TSDBConstants
;
import
com.taosdata.jdbc.rs.util.HttpClientPoolUtil
;
import
com.taosdata.jdbc.utils.SqlSyntaxValidator
;
...
...
@@ -12,7 +13,7 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
RestfulStatement
implements
Statement
{
public
class
RestfulStatement
extends
Abstract
Statement
{
private
boolean
closed
;
private
String
database
;
...
...
@@ -20,7 +21,6 @@ public class RestfulStatement implements Statement {
private
volatile
RestfulResultSet
resultSet
;
private
volatile
int
affectedRows
;
private
volatile
boolean
closeOnCompletion
;
public
RestfulStatement
(
RestfulConnection
conn
,
String
database
)
{
this
.
conn
=
conn
;
...
...
@@ -104,85 +104,6 @@ public class RestfulStatement implements Statement {
}
}
@Override
public
int
getMaxFieldSize
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
TSDBConstants
.
maxFieldSize
;
}
@Override
public
void
setMaxFieldSize
(
int
max
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
if
(
max
<
0
)
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
// nothing to do
}
@Override
public
int
getMaxRows
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
0
;
}
@Override
public
void
setMaxRows
(
int
max
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
if
(
max
<
0
)
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
// nothing to do
}
@Override
public
void
setEscapeProcessing
(
boolean
enable
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
}
@Override
public
int
getQueryTimeout
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
0
;
}
@Override
public
void
setQueryTimeout
(
int
seconds
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
if
(
seconds
<
0
)
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
}
@Override
public
void
cancel
()
throws
SQLException
{
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
SQLWarning
getWarnings
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
null
;
}
@Override
public
void
clearWarnings
()
throws
SQLException
{
// nothing to do
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
}
@Override
public
void
setCursorName
(
String
name
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
boolean
execute
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
...
...
@@ -271,53 +192,6 @@ public class RestfulStatement implements Statement {
return
this
.
affectedRows
;
}
@Override
public
boolean
getMoreResults
()
throws
SQLException
{
return
getMoreResults
(
CLOSE_CURRENT_RESULT
);
}
@Override
public
void
setFetchDirection
(
int
direction
)
throws
SQLException
{
if
(
direction
!=
ResultSet
.
FETCH_FORWARD
&&
direction
!=
ResultSet
.
FETCH_REVERSE
&&
direction
!=
ResultSet
.
FETCH_UNKNOWN
)
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
this
.
resultSet
.
setFetchDirection
(
direction
);
}
@Override
public
int
getFetchDirection
()
throws
SQLException
{
return
this
.
resultSet
.
getFetchDirection
();
}
@Override
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
if
(
rows
<
0
)
throw
new
SQLException
(
TSDBConstants
.
INVALID_VARIABLES
);
//nothing to do
}
@Override
public
int
getFetchSize
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
0
;
}
@Override
public
int
getResultSetConcurrency
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
resultSet
.
getConcurrency
();
}
@Override
public
int
getResultSetType
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
resultSet
.
getType
();
}
@Override
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
...
...
@@ -343,115 +217,10 @@ public class RestfulStatement implements Statement {
return
this
.
conn
;
}
@Override
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
if
(
resultSet
==
null
)
return
false
;
// switch (current) {
// case CLOSE_CURRENT_RESULT:
// resultSet.close();
// break;
// case KEEP_CURRENT_RESULT:
// break;
// case CLOSE_ALL_RESULTS:
// resultSet.close();
// break;
// default:
// throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// }
// return next;
return
false
;
}
@Override
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
throw
new
SQLFeatureNotSupportedException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
@Override
public
int
getResultSetHoldability
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
resultSet
.
getHoldability
();
}
@Override
public
boolean
isClosed
()
throws
SQLException
{
return
closed
;
}
@Override
public
void
setPoolable
(
boolean
poolable
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
//nothing to do
}
@Override
public
boolean
isPoolable
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
false
;
}
@Override
public
void
closeOnCompletion
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
this
.
closeOnCompletion
=
true
;
}
@Override
public
boolean
isCloseOnCompletion
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
closeOnCompletion
;
}
@Override
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
try
{
return
iface
.
cast
(
this
);
}
catch
(
ClassCastException
cce
)
{
throw
new
SQLException
(
"Unable to unwrap to "
+
iface
.
toString
());
}
}
@Override
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
return
iface
.
isInstance
(
this
);
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
浏览文件 @
42d5896b
...
...
@@ -8,9 +8,6 @@ import org.junit.Test;
import
java.sql.*
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
StatementTest
{
static
Connection
connection
=
null
;
static
Statement
statement
=
null
;
...
...
@@ -58,12 +55,12 @@ public class StatementTest {
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
"(ts timestamp, k1 int)"
);
statement
.
executeUpdate
(
"insert into "
+
dbName
+
"."
+
tName
+
" values ("
+
ts
+
", 1)"
);
statement
.
execute
Query
(
"select * from "
+
dbName
+
"."
+
tName
);
statement
.
execute
(
"select * from "
+
dbName
+
"."
+
tName
);
ResultSet
resultSet
=
statement
.
getResultSet
();
assertTrue
(
null
!=
resultSet
);
Assert
.
assertNotNull
(
resultSet
);
boolean
isClosed
=
statement
.
isClosed
();
assertEquals
(
false
,
isClosed
);
Assert
.
assertEquals
(
false
,
isClosed
);
}
@Test
(
expected
=
SQLException
.
class
)
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
浏览文件 @
42d5896b
...
...
@@ -9,13 +9,14 @@ import java.sql.DriverManager;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
public
class
SubscribeTest
{
Connection
connection
;
Statement
statement
;
String
dbName
=
"test"
;
String
tName
=
"t0"
;
String
host
=
"
localhost
"
;
String
host
=
"
127.0.0.1
"
;
String
topic
=
"test"
;
@Before
...
...
@@ -23,15 +24,15 @@ public class SubscribeTest {
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
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"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
statement
.
execute
(
"drop database if exists "
+
dbName
);
statement
.
execute
(
"create database if not exists "
+
dbName
);
statement
.
execute
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
long
ts
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
ts
+=
i
;
...
...
@@ -45,44 +46,40 @@ public class SubscribeTest {
}
@Test
public
void
subscribe
()
throws
Exception
{
TSDBSubscribe
subscribe
=
null
;
public
void
subscribe
()
{
try
{
String
rawSql
=
"select * from "
+
dbName
+
"."
+
tName
+
";"
;
System
.
out
.
println
(
rawSql
);
subscribe
=
((
TSDBConnection
)
connection
).
subscribe
(
topic
,
rawSql
,
false
);
TSDBSubscribe
subscribe
=
((
TSDBConnection
)
connection
).
subscribe
(
topic
,
rawSql
,
false
);
int
a
=
0
;
while
(
true
)
{
T
hread
.
sleep
(
9
00
);
T
imeUnit
.
MILLISECONDS
.
sleep
(
10
00
);
TSDBResultSet
resSet
=
subscribe
.
consume
();
while
(
resSet
.
next
())
{
for
(
int
i
=
1
;
i
<=
resSet
.
getMetaData
().
getColumnCount
();
i
++)
{
System
.
out
.
printf
(
i
+
": "
+
resSet
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
(
"\n======"
+
a
+
"=========="
);
}
resSet
.
close
();
a
++;
if
(
a
>=
2
)
{
break
;
}
// resSet.close();
}
subscribe
.
close
(
true
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
null
!=
subscribe
)
{
subscribe
.
close
(
true
);
}
}
}
@After
public
void
close
()
{
try
{
statement
.
execute
Query
(
"drop database "
+
dbName
);
statement
.
execute
(
"drop database "
+
dbName
);
if
(
statement
!=
null
)
statement
.
close
();
if
(
connection
!=
null
)
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
0 → 100644
浏览文件 @
42d5896b
package
com.taosdata.jdbc
;
import
org.junit.AfterClass
;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.util.Properties
;
import
java.util.UUID
;
public
class
TSDBStatementTest
{
private
static
final
String
host
=
"127.0.0.1"
;
private
static
Connection
conn
;
private
static
Statement
stmt
;
@Test
public
void
executeQuery
()
{
try
{
ResultSet
rs
=
stmt
.
executeQuery
(
"show databases"
);
Assert
.
assertNotNull
(
rs
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
": "
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
}
rs
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
executeUpdate
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
int
affectRows
=
stmt
.
executeUpdate
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
0
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
Assert
.
assertEquals
(
0
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
Assert
.
assertEquals
(
1
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
0
,
affectRows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
close
()
{
}
@Test
public
void
execute
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
boolean
isSelect
=
stmt
.
execute
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
int
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
1
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"select * from "
+
dbName
+
".weather"
);
Assert
.
assertEquals
(
true
,
isSelect
);
isSelect
=
stmt
.
execute
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
getResultSet
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
boolean
isSelect
=
stmt
.
execute
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
int
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
1
,
affectedRows
);
isSelect
=
stmt
.
execute
(
"select * from "
+
dbName
+
".weather"
);
Assert
.
assertEquals
(
true
,
isSelect
);
ResultSet
rs
=
stmt
.
getResultSet
();
Assert
.
assertNotNull
(
rs
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
Assert
.
assertEquals
(
3
,
meta
.
getColumnCount
());
int
count
=
0
;
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
": "
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
count
++;
}
Assert
.
assertEquals
(
1
,
count
);
isSelect
=
stmt
.
execute
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
false
,
isSelect
);
affectedRows
=
stmt
.
getUpdateCount
();
Assert
.
assertEquals
(
0
,
affectedRows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
getUpdateCount
()
{
execute
();
}
@Test
public
void
addBatch
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
stmt
.
addBatch
(
"create database "
+
dbName
);
stmt
.
addBatch
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
stmt
.
addBatch
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
stmt
.
addBatch
(
"select * from "
+
dbName
+
".weather"
);
stmt
.
addBatch
(
"drop database "
+
dbName
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
clearBatch
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
stmt
.
clearBatch
();
stmt
.
addBatch
(
"create database "
+
dbName
);
stmt
.
addBatch
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
stmt
.
addBatch
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
stmt
.
addBatch
(
"select * from "
+
dbName
+
".weather"
);
stmt
.
addBatch
(
"drop database "
+
dbName
);
stmt
.
clearBatch
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
executeBatch
()
{
final
String
dbName
=
(
"test_"
+
UUID
.
randomUUID
()).
replace
(
"-"
,
"_"
).
substring
(
0
,
32
);
try
{
stmt
.
addBatch
(
"create database "
+
dbName
);
stmt
.
addBatch
(
"create table "
+
dbName
+
".weather(ts timestamp, temperature float) tags(loc nchar(64))"
);
stmt
.
addBatch
(
"insert into "
+
dbName
+
".t1 using "
+
dbName
+
".weather tags('北京') values(now, 22.33)"
);
stmt
.
addBatch
(
"select * from "
+
dbName
+
".weather"
);
stmt
.
addBatch
(
"drop database "
+
dbName
);
int
[]
results
=
stmt
.
executeBatch
();
Assert
.
assertEquals
(
0
,
results
[
0
]);
Assert
.
assertEquals
(
0
,
results
[
1
]);
Assert
.
assertEquals
(
1
,
results
[
2
]);
Assert
.
assertEquals
(
Statement
.
SUCCESS_NO_INFO
,
results
[
3
]);
Assert
.
assertEquals
(
0
,
results
[
4
]);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
getConnection
()
{
try
{
Connection
connection
=
stmt
.
getConnection
();
Assert
.
assertNotNull
(
connection
);
Assert
.
assertTrue
(
this
.
conn
==
connection
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
isClosed
()
{
try
{
Assert
.
assertEquals
(
false
,
stmt
.
isClosed
());
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Properties
properties
=
new
Properties
();
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
);
stmt
=
conn
.
createStatement
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@AfterClass
public
static
void
afterClass
()
{
try
{
if
(
stmt
!=
null
)
stmt
.
close
();
if
(
conn
!=
null
)
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InvalidResultSetPointerTest.java
0 → 100644
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
浏览文件 @
42d5896b
...
...
@@ -259,10 +259,12 @@ public class RestfulResultSetTest {
rs
.
previous
();
}
@Test
(
expected
=
SQLException
.
class
)
@Test
public
void
setFetchDirection
()
throws
SQLException
{
rs
.
setFetchDirection
(
ResultSet
.
FETCH_FORWARD
);
Assert
.
assertEquals
(
ResultSet
.
FETCH_FORWARD
,
rs
.
getFetchDirection
());
rs
.
setFetchDirection
(
ResultSet
.
FETCH_UNKNOWN
);
Assert
.
assertEquals
(
ResultSet
.
FETCH_FORWARD
,
rs
.
getFetchDirection
());
}
@Test
...
...
@@ -270,14 +272,15 @@ public class RestfulResultSetTest {
Assert
.
assertEquals
(
ResultSet
.
FETCH_FORWARD
,
rs
.
getFetchDirection
());
}
@Test
(
expected
=
SQLException
.
class
)
@Test
public
void
setFetchSize
()
throws
SQLException
{
rs
.
setFetchSize
(
0
);
Assert
.
assertEquals
(
0
,
rs
.
getFetchSize
());
}
@Test
public
void
getFetchSize
()
throws
SQLException
{
Assert
.
assertEquals
(
1
,
rs
.
getFetchSize
());
Assert
.
assertEquals
(
0
,
rs
.
getFetchSize
());
}
@Test
...
...
@@ -526,9 +529,12 @@ public class RestfulResultSetTest {
rs
.
updateSQLXML
(
1
,
null
);
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
@Test
public
void
getNString
()
throws
SQLException
{
rs
.
getNString
(
"f1"
);
String
f10
=
rs
.
getNString
(
"f10"
);
Assert
.
assertEquals
(
"涛思数据"
,
f10
);
f10
=
rs
.
getNString
(
10
);
Assert
.
assertEquals
(
"涛思数据"
,
f10
);
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
42d5896b
...
...
@@ -356,7 +356,7 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BIGINT
;
strcpy
(
pSchema
[
cols
].
name
,
"time
(us)
"
);
strcpy
(
pSchema
[
cols
].
name
,
"time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
src/query/src/qExecutor.c
浏览文件 @
42d5896b
...
...
@@ -7649,7 +7649,10 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
*
continueExec
=
true
;
qDebug
(
"QInfo:%p has more results to retrieve"
,
pQInfo
);
}
if
(
pQInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
rpcFreeCont
(
*
pRsp
);
*
pRsp
=
NULL
;
}
return
pQInfo
->
code
;
}
...
...
tests/examples/python/taosdemo/README.md
0 → 100644
浏览文件 @
42d5896b
install build environment
===
/usr/bin/python3 -m pip install -r requirements.txt
run python version taosdemo
===
Usage: ./taosdemo.py [OPTION...]
Author: Shuduo Sang
<sangshuduo@gmail.com>
-H, --help Show usage.
-N, --native flag, Use native interface if set. Default is using RESTful interface.
-h, --host <hostname> host, The host to connect to TDengine. Default is localhost.
-p, --port <port> port, The TCP/IP port number to use for the connection. Default is 0.
-u, --user <username> user, The user name to use when connecting to the server. Default is 'root'.
-P, --password <password> password, The password to use when connecting to the server. Default is 'taosdata'.
-l, --colsPerRec <number> num_of_columns_per_record, The number of columns per record. Default is 3.
-d, --dbname <dbname> database, Destination database. Default is 'test'.
-a, --replica <replications> replica, Set the replica parameters of the database, Default 1, min: 1, max: 5.
-m, --tbname <table prefix> table_prefix, Table prefix name. Default is 't'.
-M, --stable flag, Use super table. Default is no
-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is 'st'
-Q, --query <DEFAULT | NO | command> query, Execute query command. set 'DEFAULT' means select * from each table
-T, --threads <number> num_of_threads, The number of threads. Default is 1.
-C, --processes <number> num_of_processes, The number of threads. Default is 1.
-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000.
-t, --numOfTb <number> num_of_tables, The number of tables. Default is 1.
-n, --numOfRec <number> num_of_records_per_table, The number of records per table. Default is 1.
-c, --config <path> config_directory, Configuration directory. Default is '/etc/taos/'.
-x, --inserOnly flag, Insert only flag.
-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order.
-R, --rateOOOO <number> rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50.
-D, --deleteMethod <number> Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database.
-v, --verbose Print verbose output
-g, --debug Print debug output
-y, --skipPrompt Skip read key for continous test, default is not skip
tests/examples/python/taosdemo/requirements.txt
0 → 100644
浏览文件 @
42d5896b
##
######## example-requirements.txt #######
##
####### Requirements without Version Specifiers ######
requests
multipledispatch
#beautifulsoup4
##
####### Requirements with Version Specifiers ######
## See https://www.python.org/dev/peps/pep-0440/#version-specifiers
#docopt == 0.6.1 # Version Matching. Must be version 0.6.1
#keyring >= 4.1.1 # Minimum version 4.1.1
#coverage != 3.5 # Version Exclusion. Anything except version 3.5
#Mopidy-Dirble ~= 1.1 # Compatible release. Same as >= 1.1, == 1.*
##
####### Refer to other requirements files ######
#-r other-requirements.txt
##
##
####### A particular file ######
#./downloads/numpy-1.9.2-cp34-none-win32.whl
#http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl
##
####### Additional Requirements without Version Specifiers ######
## Same as 1st section, just here to show that you can put things in any order.
#rejected
#green
##
tests/examples/python/taosdemo/taosdemo.py
0 → 100755
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
tests/pytest/concurrent_inquiry.sh
0 → 100755
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
tests/pytest/pytest_2.sh
浏览文件 @
42d5896b
...
...
@@ -7,15 +7,10 @@ python3 ./test.py -f update/append_commit_data.py
python3 ./test.py
-f
update/append_commit_last-0.py
python3 ./test.py
-f
update/append_commit_last.py
python3 ./test.py
-f
update/merge_commit_data.py
python3 ./test.py
-f
update/merge_commit_data-0.py
python3 ./test.py
-f
update/merge_commit_data2.py
python3 ./test.py
-f
update/merge_commit_data2_update0.py
python3 ./test.py
-f
update/merge_commit_last-0.py
python3 ./test.py
-f
update/merge_commit_last.py
python3 ./test.py
-f
update/bug_td2279.py
# wal
python3 ./test.py
-f
wal/addOldWalTest.py
# function
python3 ./test.py
-f
functions/all_null_value.py
\ No newline at end of file
tests/pytest/pytest_3.sh
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
tests/pytest/pytest_4.sh
0 → 100755
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
tests/script/jenkins/basic_4.txt
浏览文件 @
42d5896b
./test.sh -f unique/dnode/alternativeRole.sim
./test.sh -f unique/dnode/balance1.sim
./test.sh -f unique/dnode/balance2.sim
./test.sh -f unique/dnode/balance3.sim
./test.sh -f unique/dnode/balancex.sim
./test.sh -f unique/dnode/offline1.sim
./test.sh -f unique/dnode/offline2.sim
./test.sh -f unique/dnode/reason.sim
./test.sh -f unique/dnode/remove1.sim
./test.sh -f unique/dnode/remove2.sim
./test.sh -f unique/dnode/vnode_clean.sim
./test.sh -f unique/http/admin.sim
./test.sh -f unique/http/opentsdb.sim
...
...
tests/script/jenkins/basic_5.txt
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
tests/script/jenkins/basic_6.txt
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
tests/test-all.sh
浏览文件 @
42d5896b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录