Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5d51c463
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5d51c463
编写于
2月 06, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
7db50342
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
58 deletion
+57
-58
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
+52
-54
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+2
-2
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/test/java/com/taosdata/jdbc/ResultSetTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
+1
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
+1
-1
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
浏览文件 @
5d51c463
...
...
@@ -17,12 +17,12 @@ package com.taosdata.jdbc;
import
java.math.BigDecimal
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
public
class
TSDBResultSet
extends
AbstractResultSet
implements
ResultSet
{
private
TSDBJNIConnector
jniConnector
=
null
;
private
TSDBJNIConnector
jniConnector
;
private
final
TSDBStatement
statement
;
private
long
resultSetPointer
=
0L
;
private
List
<
ColumnMetaData
>
columnMetaDataList
=
new
ArrayList
<>();
...
...
@@ -33,24 +33,6 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
private
boolean
lastWasNull
=
false
;
private
final
int
COLUMN_INDEX_START_VALUE
=
1
;
private
int
rowIndex
=
0
;
public
TSDBJNIConnector
getJniConnector
()
{
return
jniConnector
;
}
public
void
setJniConnector
(
TSDBJNIConnector
jniConnector
)
{
this
.
jniConnector
=
jniConnector
;
}
public
long
getResultSetPointer
()
{
return
resultSetPointer
;
}
public
void
setResultSetPointer
(
long
resultSetPointer
)
{
this
.
resultSetPointer
=
resultSetPointer
;
}
public
void
setBatchFetch
(
boolean
batchFetch
)
{
this
.
batchFetch
=
batchFetch
;
}
...
...
@@ -59,10 +41,6 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
return
this
.
batchFetch
;
}
public
List
<
ColumnMetaData
>
getColumnMetaDataList
()
{
return
columnMetaDataList
;
}
public
void
setColumnMetaDataList
(
List
<
ColumnMetaData
>
columnMetaDataList
)
{
this
.
columnMetaDataList
=
columnMetaDataList
;
}
...
...
@@ -71,25 +49,11 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
return
rowData
;
}
public
void
setRowData
(
TSDBResultSetRowData
rowData
)
{
this
.
rowData
=
rowData
;
}
public
boolean
isLastWasNull
()
{
return
lastWasNull
;
}
public
void
setLastWasNull
(
boolean
lastWasNull
)
{
this
.
lastWasNull
=
lastWasNull
;
}
public
TSDBResultSet
()
{
}
public
TSDBResultSet
(
TSDBJNIConnector
connector
,
long
resultSetPointer
)
throws
SQLException
{
public
TSDBResultSet
(
TSDBStatement
statement
,
TSDBJNIConnector
connector
,
long
resultSetPointer
)
throws
SQLException
{
this
.
statement
=
statement
;
this
.
jniConnector
=
connector
;
this
.
resultSetPointer
=
resultSetPointer
;
int
code
=
this
.
jniConnector
.
getSchemaMetaData
(
this
.
resultSetPointer
,
this
.
columnMetaDataList
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
...
...
@@ -349,75 +313,109 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet {
@Override
public
boolean
isBeforeFirst
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
return
false
;
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
)
;
}
@Override
public
boolean
isAfterLast
()
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
isFirst
()
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
isLast
()
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
void
beforeFirst
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
void
afterLast
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
first
()
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
last
()
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
int
getRow
()
throws
SQLException
{
return
0
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
absolute
(
int
row
)
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
relative
(
int
rows
)
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
@Override
public
boolean
previous
()
throws
SQLException
{
return
false
;
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
);
}
public
Statement
getStatement
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_RESULTSET_CLOSED
);
// return this.statement;
return
null
;
return
this
.
statement
;
}
public
boolean
isClosed
()
throws
SQLException
{
//TODO:
//TODO:
check if need release resources
boolean
isClosed
=
true
;
if
(
jniConnector
!=
null
)
{
isClosed
=
jniConnector
.
isResultsetClosed
();
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
5d51c463
...
...
@@ -56,7 +56,7 @@ public class TSDBStatement extends AbstractStatement {
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_WITH_EXECUTEQUERY
);
}
TSDBResultSet
res
=
new
TSDBResultSet
(
this
.
connector
,
pSql
);
TSDBResultSet
res
=
new
TSDBResultSet
(
this
,
this
.
connector
,
pSql
);
res
.
setBatchFetch
(
this
.
connection
.
getBatchFetch
());
return
res
;
}
...
...
@@ -97,7 +97,7 @@ public class TSDBStatement extends AbstractStatement {
return
false
;
}
this
.
resultSet
=
new
TSDBResultSet
(
this
.
connector
,
pSql
);
this
.
resultSet
=
new
TSDBResultSet
(
this
,
this
.
connector
,
pSql
);
this
.
resultSet
.
setBatchFetch
(
this
.
connection
.
getBatchFetch
());
return
true
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java
浏览文件 @
5d51c463
...
...
@@ -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/test/java/com/taosdata/jdbc/ResultSetTest.java
浏览文件 @
5d51c463
...
...
@@ -115,6 +115,7 @@ public class ResultSetTest {
public
void
testUnsupport
()
throws
SQLException
{
statement
.
executeQuery
(
"show databases"
);
resSet
=
statement
.
getResultSet
();
Assert
.
assertNotNull
(
resSet
.
unwrap
(
TSDBResultSet
.
class
));
Assert
.
assertTrue
(
resSet
.
isWrapperFor
(
TSDBResultSet
.
class
));
try
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
浏览文件 @
5d51c463
...
...
@@ -55,7 +55,7 @@ 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
();
Assert
.
assertNotNull
(
resultSet
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录