Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
4dff524a
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4dff524a
编写于
11月 18, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] refactor jdbc driver
上级
59c32df4
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
136 addition
and
133 deletion
+136
-133
src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
.../jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
+4
-4
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
...ctor/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
+16
-13
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
+22
-18
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java
...c/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java
+68
-72
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+26
-26
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java
浏览文件 @
4dff524a
...
...
@@ -16,10 +16,10 @@ package com.taosdata.jdbc;
public
class
ColumnMetaData
{
int
colType
=
0
;
String
colName
=
null
;
int
colSize
=
-
1
;
int
colIndex
=
0
;
private
int
colType
=
0
;
private
String
colName
=
null
;
private
int
colSize
=
-
1
;
private
int
colIndex
=
0
;
public
int
getColSize
()
{
return
colSize
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
4dff524a
...
...
@@ -86,6 +86,11 @@ public class TSDBDriver extends AbstractTaosDriver {
*/
public
static
final
String
PROPERTY_KEY_CHARSET
=
"charset"
;
/**
* fetch data from native function in a batch model
*/
public
static
final
String
PROPERTY_KEY_BATCH_LOAD
=
"batch"
;
private
TSDBDatabaseMetaData
dbMetaData
=
null
;
static
{
...
...
@@ -172,26 +177,21 @@ public class TSDBDriver extends AbstractTaosDriver {
url
=
url
.
substring
(
0
,
index
);
StringTokenizer
queryParams
=
new
StringTokenizer
(
paramString
,
"&"
);
while
(
queryParams
.
hasMoreElements
())
{
String
parameterValuePair
=
queryParams
.
nextToken
();
int
indexOfEqual
=
parameterValuePair
.
indexOf
(
"="
);
String
parameter
=
null
;
String
value
=
null
;
if
(
indexOfEqual
!=
-
1
)
{
parameter
=
parameterValuePair
.
substring
(
0
,
indexOfEqual
);
if
(
indexOfEqual
+
1
<
parameterValuePair
.
length
())
{
value
=
parameterValuePair
.
substring
(
indexOfEqual
+
1
);
}
}
if
((
value
!=
null
&&
value
.
length
()
>
0
)
&&
(
parameter
!=
null
&&
parameter
.
length
()
>
0
))
{
urlProps
.
setProperty
(
parameter
,
value
);
String
oneToken
=
queryParams
.
nextToken
();
String
[]
pair
=
oneToken
.
split
(
"="
);
if
((
pair
[
0
]
!=
null
&&
pair
[
0
].
trim
().
length
()
>
0
)
&&
(
pair
[
1
]
!=
null
&&
pair
[
1
].
trim
().
length
()
>
0
))
{
urlProps
.
setProperty
(
pair
[
0
].
trim
(),
pair
[
1
].
trim
());
}
}
}
// parse Product Name
String
dbProductName
=
url
.
substring
(
0
,
beginningOfSlashes
);
dbProductName
=
dbProductName
.
substring
(
dbProductName
.
indexOf
(
":"
)
+
1
);
dbProductName
=
dbProductName
.
substring
(
0
,
dbProductName
.
indexOf
(
":"
));
// parse dbname
// parse database name
url
=
url
.
substring
(
beginningOfSlashes
+
2
);
int
indexOfSlash
=
url
.
indexOf
(
"/"
);
if
(
indexOfSlash
!=
-
1
)
{
...
...
@@ -200,6 +200,7 @@ public class TSDBDriver extends AbstractTaosDriver {
}
url
=
url
.
substring
(
0
,
indexOfSlash
);
}
// parse port
int
indexOfColon
=
url
.
indexOf
(
":"
);
if
(
indexOfColon
!=
-
1
)
{
...
...
@@ -208,9 +209,11 @@ public class TSDBDriver extends AbstractTaosDriver {
}
url
=
url
.
substring
(
0
,
indexOfColon
);
}
if
(
url
!=
null
&&
url
.
length
()
>
0
&&
url
.
trim
().
length
()
>
0
)
{
urlProps
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
url
);
}
this
.
dbMetaData
=
new
TSDBDatabaseMetaData
(
dbProductName
,
urlForMeta
,
urlProps
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
));
return
urlProps
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java
浏览文件 @
4dff524a
...
...
@@ -49,7 +49,7 @@ public class TSDBResultSet implements ResultSet {
private
TSDBResultSetRowData
rowData
;
private
TSDBResultSetBlockData
blockData
;
private
boolean
b
lockwise
Fetch
=
false
;
private
boolean
b
atch
Fetch
=
false
;
private
boolean
lastWasNull
=
false
;
private
final
int
COLUMN_INDEX_START_VALUE
=
1
;
...
...
@@ -71,8 +71,12 @@ public class TSDBResultSet implements ResultSet {
this
.
resultSetPointer
=
resultSetPointer
;
}
public
void
setBlockWiseFetch
(
boolean
fetchBlock
)
{
this
.
blockwiseFetch
=
fetchBlock
;
public
void
setBatchFetch
(
boolean
batchFetch
)
{
this
.
batchFetch
=
batchFetch
;
}
public
Boolean
getBatchFetch
()
{
return
this
.
batchFetch
;
}
public
List
<
ColumnMetaData
>
getColumnMetaDataList
()
{
...
...
@@ -102,8 +106,8 @@ public class TSDBResultSet implements ResultSet {
public
TSDBResultSet
()
{
}
public
TSDBResultSet
(
TSDBJNIConnector
connect
e
r
,
long
resultSetPointer
)
throws
SQLException
{
this
.
jniConnector
=
connect
e
r
;
public
TSDBResultSet
(
TSDBJNIConnector
connect
o
r
,
long
resultSetPointer
)
throws
SQLException
{
this
.
jniConnector
=
connect
o
r
;
this
.
resultSetPointer
=
resultSetPointer
;
int
code
=
this
.
jniConnector
.
getSchemaMetaData
(
this
.
resultSetPointer
,
this
.
columnMetaDataList
);
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
...
...
@@ -127,13 +131,13 @@ public class TSDBResultSet implements ResultSet {
}
public
boolean
next
()
throws
SQLException
{
if
(
this
.
blockwiseFetch
)
{
if
(
this
.
getBatchFetch
()
)
{
if
(
this
.
blockData
.
forward
())
{
return
true
;
}
int
code
=
this
.
jniConnector
.
fetchBlock
(
this
.
resultSetPointer
,
this
.
blockData
);
this
.
blockData
.
reset
Cursor
();
this
.
blockData
.
reset
();
if
(
code
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
...
...
@@ -185,7 +189,7 @@ public class TSDBResultSet implements ResultSet {
String
res
=
null
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getString
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -200,7 +204,7 @@ public class TSDBResultSet implements ResultSet {
boolean
res
=
false
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getBoolean
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -216,7 +220,7 @@ public class TSDBResultSet implements ResultSet {
byte
res
=
0
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
(
byte
)
this
.
rowData
.
getInt
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -231,7 +235,7 @@ public class TSDBResultSet implements ResultSet {
short
res
=
0
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
(
short
)
this
.
rowData
.
getInt
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -246,7 +250,7 @@ public class TSDBResultSet implements ResultSet {
int
res
=
0
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getInt
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -262,7 +266,7 @@ public class TSDBResultSet implements ResultSet {
long
res
=
0
l
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getLong
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -277,7 +281,7 @@ public class TSDBResultSet implements ResultSet {
float
res
=
0
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getFloat
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -292,7 +296,7 @@ public class TSDBResultSet implements ResultSet {
double
res
=
0
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getDouble
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
());
...
...
@@ -334,7 +338,7 @@ public class TSDBResultSet implements ResultSet {
Timestamp
res
=
null
;
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
if
(!
lastWasNull
)
{
res
=
this
.
rowData
.
getTimestamp
(
colIndex
);
...
...
@@ -454,7 +458,7 @@ public class TSDBResultSet implements ResultSet {
public
Object
getObject
(
int
columnIndex
)
throws
SQLException
{
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
return
this
.
rowData
.
get
(
colIndex
);
}
else
{
...
...
@@ -491,7 +495,7 @@ public class TSDBResultSet implements ResultSet {
public
BigDecimal
getBigDecimal
(
int
columnIndex
)
throws
SQLException
{
int
colIndex
=
getTrueColumnIndex
(
columnIndex
);
if
(!
this
.
blockwiseFetch
)
{
if
(!
this
.
getBatchFetch
()
)
{
this
.
lastWasNull
=
this
.
rowData
.
wasNull
(
colIndex
);
return
new
BigDecimal
(
this
.
rowData
.
getLong
(
colIndex
,
this
.
columnMetaDataList
.
get
(
colIndex
).
getColType
()));
}
else
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java
浏览文件 @
4dff524a
...
...
@@ -56,13 +56,6 @@ public class TSDBResultSetBlockData {
if
(
this
.
numOfCols
==
0
)
{
return
;
}
this
.
colData
=
new
ArrayList
<
Object
>(
numOfCols
);
this
.
colData
.
addAll
(
Collections
.
nCopies
(
this
.
numOfCols
,
null
));
}
public
boolean
wasNull
(
int
col
)
{
return
colData
.
get
(
col
)
==
null
;
}
public
int
getNumOfRows
()
{
...
...
@@ -82,20 +75,19 @@ public class TSDBResultSetBlockData {
this
.
clear
();
}
public
void
setColumnData
(
int
col
,
byte
val
)
{
this
.
colData
.
set
(
col
,
val
);
}
public
boolean
hasMore
()
{
return
this
.
rowIndex
<
this
.
numOfRows
;
}
public
boolean
forward
()
{
this
.
rowIndex
++;
return
(
this
.
rowIndex
<
this
.
numOfRows
)
;
if
(
this
.
rowIndex
>
this
.
numOfRows
)
{
return
false
;
}
public
void
resetCursor
()
{
return
((++
this
.
rowIndex
)
<
this
.
numOfRows
);
}
public
void
reset
()
{
this
.
rowIndex
=
0
;
}
...
...
@@ -172,71 +164,75 @@ public class TSDBResultSetBlockData {
}
}
class
NullType
{
public
String
toString
()
{
return
new
String
(
"null"
);
}
}
/**
* The original type may not be a string type, but will be converted to by
* calling this method
*
* @param col column index
* @return
* @throws SQLException
*/
public
String
getString
(
int
col
)
throws
SQLException
{
Object
obj
=
get
(
col
);
if
(
obj
==
null
)
{
return
new
NullType
().
toString
();
}
private
static
class
NullType
{
private
static
final
byte
NULL_BOOL_VAL
=
0x2
;
private
static
final
String
NULL_STR
=
"null"
;
return
obj
.
toString
();
public
String
toString
()
{
return
NullType
.
NULL_STR
;
}
private
boolean
isBooleanNull
(
byte
val
)
{
return
val
==
0x2
;
public
static
boolean
isBooleanNull
(
byte
val
)
{
return
val
==
NullType
.
NULL_BOOL_VAL
;
}
private
boolean
isTinyIntNull
(
byte
val
)
{
return
val
==
0x80
;
private
static
boolean
isTinyIntNull
(
byte
val
)
{
return
val
==
Byte
.
MIN_VALUE
;
}
private
boolean
isSmallIntNull
(
short
val
)
{
return
val
==
0x8000
;
private
static
boolean
isSmallIntNull
(
short
val
)
{
return
val
==
Short
.
MIN_VALUE
;
}
private
boolean
isIntNull
(
int
val
)
{
return
val
==
0x80000000
L
;
private
static
boolean
isIntNull
(
int
val
)
{
return
val
==
Integer
.
MIN_VALUE
;
}
private
boolean
isBigIntNull
(
long
val
)
{
return
val
==
0x8000000000000000
L
;
private
static
boolean
isBigIntNull
(
long
val
)
{
return
val
==
Long
.
MIN_VALUE
;
}
private
boolean
isFloatNull
(
float
val
)
{
private
static
boolean
isFloatNull
(
float
val
)
{
return
Float
.
isNaN
(
val
);
}
private
boolean
isDoubleNull
(
double
val
)
{
private
static
boolean
isDoubleNull
(
double
val
)
{
return
Double
.
isNaN
(
val
);
}
private
boolean
isBinaryNull
(
byte
[]
val
,
int
length
)
{
if
(
length
!=
1
)
{
private
static
boolean
isBinaryNull
(
byte
[]
val
,
int
length
)
{
if
(
length
!=
Byte
.
BYTES
)
{
return
false
;
}
return
val
[
0
]
==
0xFF
;
}
private
boolean
isNcharNull
(
byte
[]
val
,
int
length
)
{
if
(
length
!=
4
)
{
private
static
boolean
isNcharNull
(
byte
[]
val
,
int
length
)
{
if
(
length
!=
Integer
.
BYTES
)
{
return
false
;
}
return
(
val
[
0
]
&
val
[
1
]
&
val
[
2
]
&
val
[
3
])
==
0xFF
;
return
(
val
[
0
]
&
val
[
1
]
&
val
[
2
]
&
val
[
3
])
==
0xFF
;
}
}
/**
* The original type may not be a string type, but will be converted to by
* calling this method
*
* @param col column index
* @return
* @throws SQLException
*/
public
String
getString
(
int
col
)
throws
SQLException
{
Object
obj
=
get
(
col
);
if
(
obj
==
null
)
{
return
new
NullType
().
toString
();
}
return
obj
.
toString
();
}
public
int
getInt
(
int
col
)
{
...
...
@@ -284,16 +280,16 @@ public class TSDBResultSetBlockData {
case
TSDBConstants
.
TSDB_DATA_TYPE_TINYINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
{
return
((
int
)
obj
==
0L
)
?
Boolean
.
FALSE
:
Boolean
.
TRUE
;
return
((
int
)
obj
==
0L
)
?
Boolean
.
FALSE
:
Boolean
.
TRUE
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_TIMESTAMP
:
{
return
(((
Long
)
obj
)
==
0L
)
?
Boolean
.
FALSE
:
Boolean
.
TRUE
;
return
(((
Long
)
obj
)
==
0L
)
?
Boolean
.
FALSE
:
Boolean
.
TRUE
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
{
return
(((
Double
)
obj
)
==
0
)
?
Boolean
.
FALSE
:
Boolean
.
TRUE
;
return
(((
Double
)
obj
)
==
0
)
?
Boolean
.
FALSE
:
Boolean
.
TRUE
;
}
case
TSDBConstants
.
TSDB_DATA_TYPE_NCHAR
:
...
...
@@ -395,7 +391,7 @@ public class TSDBResultSetBlockData {
ByteBuffer
bb
=
(
ByteBuffer
)
this
.
colData
.
get
(
col
);
byte
val
=
bb
.
get
(
this
.
rowIndex
);
if
(
isBooleanNull
(
val
))
{
if
(
NullType
.
isBooleanNull
(
val
))
{
return
null
;
}
...
...
@@ -406,7 +402,7 @@ public class TSDBResultSetBlockData {
ByteBuffer
bb
=
(
ByteBuffer
)
this
.
colData
.
get
(
col
);
byte
val
=
bb
.
get
(
this
.
rowIndex
);
if
(
isTinyIntNull
(
val
))
{
if
(
NullType
.
isTinyIntNull
(
val
))
{
return
null
;
}
...
...
@@ -416,7 +412,7 @@ public class TSDBResultSetBlockData {
case
TSDBConstants
.
TSDB_DATA_TYPE_SMALLINT
:
{
ShortBuffer
sb
=
(
ShortBuffer
)
this
.
colData
.
get
(
col
);
short
val
=
sb
.
get
(
this
.
rowIndex
);
if
(
isSmallIntNull
(
val
))
{
if
(
NullType
.
isSmallIntNull
(
val
))
{
return
null
;
}
...
...
@@ -426,7 +422,7 @@ public class TSDBResultSetBlockData {
case
TSDBConstants
.
TSDB_DATA_TYPE_INT
:
{
IntBuffer
ib
=
(
IntBuffer
)
this
.
colData
.
get
(
col
);
int
val
=
ib
.
get
(
this
.
rowIndex
);
if
(
isIntNull
(
val
))
{
if
(
NullType
.
isIntNull
(
val
))
{
return
null
;
}
...
...
@@ -437,7 +433,7 @@ public class TSDBResultSetBlockData {
case
TSDBConstants
.
TSDB_DATA_TYPE_BIGINT
:
{
LongBuffer
lb
=
(
LongBuffer
)
this
.
colData
.
get
(
col
);
long
val
=
lb
.
get
(
this
.
rowIndex
);
if
(
isBigIntNull
(
val
))
{
if
(
NullType
.
isBigIntNull
(
val
))
{
return
null
;
}
...
...
@@ -447,7 +443,7 @@ public class TSDBResultSetBlockData {
case
TSDBConstants
.
TSDB_DATA_TYPE_FLOAT
:
{
FloatBuffer
fb
=
(
FloatBuffer
)
this
.
colData
.
get
(
col
);
float
val
=
fb
.
get
(
this
.
rowIndex
);
if
(
isFloatNull
(
val
))
{
if
(
NullType
.
isFloatNull
(
val
))
{
return
null
;
}
...
...
@@ -457,7 +453,7 @@ public class TSDBResultSetBlockData {
case
TSDBConstants
.
TSDB_DATA_TYPE_DOUBLE
:
{
DoubleBuffer
lb
=
(
DoubleBuffer
)
this
.
colData
.
get
(
col
);
double
val
=
lb
.
get
(
this
.
rowIndex
);
if
(
isDoubleNull
(
val
))
{
if
(
NullType
.
isDoubleNull
(
val
))
{
return
null
;
}
...
...
@@ -472,7 +468,7 @@ public class TSDBResultSetBlockData {
byte
[]
dest
=
new
byte
[
length
];
bb
.
get
(
dest
,
0
,
length
);
if
(
isBinaryNull
(
dest
,
length
))
{
if
(
NullType
.
isBinaryNull
(
dest
,
length
))
{
return
null
;
}
...
...
@@ -487,7 +483,7 @@ public class TSDBResultSetBlockData {
byte
[]
dest
=
new
byte
[
length
];
bb
.
get
(
dest
,
0
,
length
);
if
(
isNcharNull
(
dest
,
length
))
{
if
(
NullType
.
isNcharNull
(
dest
,
length
))
{
return
null
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
4dff524a
...
...
@@ -19,7 +19,7 @@ import java.util.ArrayList;
import
java.util.List
;
public
class
TSDBStatement
implements
Statement
{
private
TSDBJNIConnector
connect
e
r
=
null
;
private
TSDBJNIConnector
connect
o
r
=
null
;
/**
* To store batched commands
...
...
@@ -45,9 +45,9 @@ public class TSDBStatement implements Statement {
this
.
connection
=
connection
;
}
TSDBStatement
(
TSDBConnection
connection
,
TSDBJNIConnector
connect
e
r
)
{
TSDBStatement
(
TSDBConnection
connection
,
TSDBJNIConnector
connect
o
r
)
{
this
.
connection
=
connection
;
this
.
connect
er
=
connecte
r
;
this
.
connect
or
=
connecto
r
;
this
.
isClosed
=
false
;
}
...
...
@@ -65,27 +65,27 @@ public class TSDBStatement implements Statement {
}
// TODO make sure it is not a update query
pSql
=
this
.
connect
e
r
.
executeQuery
(
sql
);
pSql
=
this
.
connect
o
r
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connect
e
r
.
getResultSet
();
long
resultSetPointer
=
this
.
connect
o
r
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
// create/insert/update/delete/alter
if
(
resultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
return
null
;
}
if
(!
this
.
connect
e
r
.
isUpdateQuery
(
pSql
))
{
TSDBResultSet
res
=
new
TSDBResultSet
(
this
.
connect
e
r
,
resultSetPointer
);
res
.
setB
lockWiseFetch
(
true
);
if
(!
this
.
connect
o
r
.
isUpdateQuery
(
pSql
))
{
TSDBResultSet
res
=
new
TSDBResultSet
(
this
.
connect
o
r
,
resultSetPointer
);
res
.
setB
atchFetch
(
this
.
connection
.
getBatchFetch
()
);
return
res
;
}
else
{
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
return
null
;
}
...
...
@@ -97,28 +97,28 @@ public class TSDBStatement implements Statement {
}
// TODO check if current query is update query
pSql
=
this
.
connect
e
r
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connect
e
r
.
getResultSet
();
pSql
=
this
.
connect
o
r
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connect
o
r
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
this
.
affectedRows
=
this
.
connect
e
r
.
getAffectedRows
(
pSql
);
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
affectedRows
=
this
.
connect
o
r
.
getAffectedRows
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
return
this
.
affectedRows
;
}
public
String
getErrorMsg
(
long
pSql
)
{
return
this
.
connect
e
r
.
getErrMsg
(
pSql
);
return
this
.
connect
o
r
.
getErrMsg
(
pSql
);
}
public
void
close
()
throws
SQLException
{
if
(!
isClosed
)
{
if
(!
this
.
connect
e
r
.
isResultsetClosed
())
{
this
.
connect
e
r
.
freeResultSet
();
if
(!
this
.
connect
o
r
.
isResultsetClosed
())
{
this
.
connect
o
r
.
freeResultSet
();
}
isClosed
=
true
;
}
...
...
@@ -174,15 +174,15 @@ public class TSDBStatement implements Statement {
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
boolean
res
=
true
;
pSql
=
this
.
connect
e
r
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connect
e
r
.
getResultSet
();
pSql
=
this
.
connect
o
r
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connect
o
r
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
else
if
(
resultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
// no result set is retrieved
this
.
connect
e
r
.
freeResultSet
(
pSql
);
this
.
connect
o
r
.
freeResultSet
(
pSql
);
res
=
false
;
}
...
...
@@ -193,10 +193,10 @@ public class TSDBStatement implements Statement {
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
long
resultSetPointer
=
connect
e
r
.
getResultSet
();
long
resultSetPointer
=
connect
o
r
.
getResultSet
();
TSDBResultSet
resSet
=
null
;
if
(
resultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
resSet
=
new
TSDBResultSet
(
connect
e
r
,
resultSetPointer
);
resSet
=
new
TSDBResultSet
(
connect
o
r
,
resultSetPointer
);
}
return
resSet
;
}
...
...
@@ -269,7 +269,7 @@ public class TSDBStatement implements Statement {
}
public
Connection
getConnection
()
throws
SQLException
{
if
(
this
.
connect
e
r
!=
null
)
if
(
this
.
connect
o
r
!=
null
)
return
this
.
connection
;
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORT_METHOD_EXCEPTIONZ_MSG
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录