Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
9a58d6d8
TDengine
项目概览
冷面1992
/
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,发现更多精彩内容 >>
提交
9a58d6d8
编写于
2月 25, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
faa7a555
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
48 deletion
+43
-48
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
...ector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
+25
-29
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
+14
-14
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+3
-4
tests/examples/JDBC/JDBCDemo/pom.xml
tests/examples/JDBC/JDBCDemo/pom.xml
+1
-1
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
浏览文件 @
9a58d6d8
...
...
@@ -24,49 +24,45 @@ public class TSDBError {
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_INVALID_FOR_EXECUTE
,
"not a valid sql for execute: (?)"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_PARAMETER_INDEX_OUT_RANGE
,
"parameter index out of range"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED
,
"connection already closed"
);
/**************************************************/
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
)
{
return
"TDengine Error: "
+
msg
;
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
SQLException
createSQLException
(
int
errorNumber
)
{
return
createSQLException
(
errorNumber
,
null
);
public
static
SQLException
createSQLException
(
int
errorCode
)
{
String
message
;
if
(
TSDBErrorNumbers
.
contains
(
errorCode
))
message
=
TSDBErrorMap
.
get
(
errorCode
);
else
message
=
TSDBErrorMap
.
get
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
);
return
createSQLException
(
errorCode
,
message
);
}
public
static
SQLException
createSQLException
(
int
errorNumber
,
String
message
)
{
if
(
message
==
null
||
message
.
isEmpty
()
||
message
.
replaceAll
(
"\\s"
,
""
).
isEmpty
())
{
if
(
TSDBErrorNumbers
.
contains
(
errorNumber
))
message
=
TSDBErrorMap
.
get
(
errorNumber
);
else
message
=
TSDBErrorMap
.
get
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
);
}
public
static
SQLException
createSQLException
(
int
errorCode
,
String
message
)
{
// throw SQLFeatureNotSupportedException
if
(
error
Number
==
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
)
return
new
SQLFeatureNotSupportedException
(
message
,
""
,
error
Number
);
if
(
error
Code
==
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_METHOD
)
return
new
SQLFeatureNotSupportedException
(
message
,
""
,
error
Code
);
// throw SQLClientInfoException
if
(
error
Number
==
TSDBErrorNumbers
.
ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED
)
return
new
SQLClientInfoException
(
message
,
null
);
if
(
error
Code
==
TSDBErrorNumbers
.
ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED
)
return
new
SQLClientInfoException
(
message
,
null
);
if
(
error
Number
<
TSDBErrorNumbers
.
ERROR_UNKNOWN
)
if
(
error
Code
>
0x2300
&&
errorCode
<
0x2350
)
// JDBC exception's error number is less than 0x2350
return
new
SQLException
(
"ERROR ("
+
Integer
.
toHexString
(
errorNumber
)
+
"): "
+
message
,
""
,
errorNumber
);
// JNI exception's error number is large than 0x2350
return
new
SQLException
(
"TDengine ERROR ("
+
Integer
.
toHexString
(
errorNumber
)
+
"): "
+
message
,
""
,
errorNumber
);
return
new
SQLException
(
"ERROR ("
+
Integer
.
toHexString
(
errorCode
)
+
"): "
+
message
,
""
,
errorCode
);
if
(
errorCode
>
0x2350
&&
errorCode
<
0x2400
)
// JNI exception's error number is large than 0x2350
return
new
SQLException
(
"JNI ERROR ("
+
Integer
.
toHexString
(
errorCode
)
+
"): "
+
message
,
""
,
errorCode
);
return
new
SQLException
(
"TDengine ERROR ("
+
Integer
.
toHexString
(
errorCode
)
+
"): "
+
message
,
""
,
errorCode
);
}
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
浏览文件 @
9a58d6d8
...
...
@@ -13,24 +13,24 @@ public class TSDBErrorNumbers {
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_INVALID_FOR_EXECUTE_QUERY
=
0x2309
;
//not a valid sql for executeQuery: (SQL)
public
static
final
int
ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE
=
0x23
10
;
//Database not specified or available
public
static
final
int
ERROR_INVALID_FOR_EXECUTE_UPDATE
=
0x23
11
;
//not a valid sql for executeUpdate: (SQL)
public
static
final
int
ERROR_INVALID_FOR_EXECUTE
=
0x23
12
;
//not a valid sql for execute: (SQL)
public
static
final
int
ERROR_PARAMETER_INDEX_OUT_RANGE
=
0x23
13
;
// parameter index out of range
public
static
final
int
ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED
=
0x23
14
;
// connection already closed
public
static
final
int
ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE
=
0x23
0a
;
//Database not specified or available
public
static
final
int
ERROR_INVALID_FOR_EXECUTE_UPDATE
=
0x23
0b
;
//not a valid sql for executeUpdate: (SQL)
public
static
final
int
ERROR_INVALID_FOR_EXECUTE
=
0x23
0c
;
//not a valid sql for execute: (SQL)
public
static
final
int
ERROR_PARAMETER_INDEX_OUT_RANGE
=
0x23
0d
;
// parameter index out of range
public
static
final
int
ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED
=
0x23
0e
;
// connection already closed
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_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
;
public
static
final
int
ERROR_JNI_TDENGINE_ERROR
=
0x2353
;
// internal error of database
public
static
final
int
ERROR_JNI_CONNECTION_NULL
=
0x2354
;
//
JNI connection already closed
public
static
final
int
ERROR_JNI_RESULT_SET_NULL
=
0x2355
;
// invalid JNI result set
public
static
final
int
ERROR_JNI_NUM_OF_FIELDS_0
=
0x2356
;
// invalid num of fields
public
static
final
int
ERROR_JNI_SQL_NULL
=
0x2357
;
// empty sql string
public
static
final
int
ERROR_JNI_FETCH_END
=
0x2358
;
// fetch to the end of resultSet
public
static
final
int
ERROR_JNI_OUT_OF_MEMORY
=
0x2359
;
// JNI alloc memory failed
private
static
final
HashSet
<
Integer
>
errorNumbers
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
9a58d6d8
...
...
@@ -102,7 +102,8 @@ public class TSDBJNIConnector {
this
.
taos
=
this
.
connectImp
(
host
,
port
,
dbName
,
user
,
password
);
if
(
this
.
taos
==
TSDBConstants
.
JNI_NULL_POINTER
)
{
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
this
.
getErrMsg
(
0L
)),
""
,
this
.
getErrCode
(
0
l
));
throw
TSDBError
.
createSQLException
(
this
.
getErrCode
(
0
l
),
this
.
getErrMsg
(
0L
));
// throw new SQLException(TSDBConstants.WrapErrMsg(, "", );
}
// invoke connectImp only here
taosInfo
.
conn_open_increment
();
...
...
@@ -187,7 +188,6 @@ public class TSDBJNIConnector {
// public long getResultSet() {
// return taosResultSetPointer;
// }
private
native
long
getResultSetImp
(
long
connection
,
long
pSql
);
public
boolean
isUpdateQuery
(
long
pSql
)
{
...
...
@@ -206,7 +206,7 @@ public class TSDBJNIConnector {
// }
// if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
res
=
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
res
=
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
// }
...
...
@@ -227,7 +227,6 @@ public class TSDBJNIConnector {
// }
// return resCode;
// }
private
native
int
freeResultSetImp
(
long
connection
,
long
result
);
/**
...
...
tests/examples/JDBC/JDBCDemo/pom.xml
浏览文件 @
9a58d6d8
...
...
@@ -13,7 +13,7 @@
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.1
8
</version>
<version>
2.0.1
4
</version>
</dependency>
</dependencies>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录