Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
197e59d8
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看板
未验证
提交
197e59d8
编写于
8月 20, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
8月 20, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3152 from taosdata/hotfix/jdbcmemleak
fix jdbc memleaks #3098
上级
644749a3
e9bba3cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
24 deletion
+26
-24
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+3
-4
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+14
-12
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+9
-8
未找到文件。
src/client/src/TSDBJNIConnector.c
浏览文件 @
197e59d8
...
...
@@ -327,13 +327,12 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp(
STscObj
*
pObj
=
pSql
->
pTscObj
;
if
(
tscIsUpdateQuery
(
pSql
))
{
// taos_free_result(pSql); // free result here
jniDebug
(
"jobj:%p, conn:%p, no resultset, %p"
,
jobj
,
pObj
,
(
void
*
)
tres
);
return
0
;
jniDebug
(
"jobj:%p, conn:%p, update query, no resultset, %p"
,
jobj
,
pObj
,
(
void
*
)
tres
);
}
else
{
jniDebug
(
"jobj:%p, conn:%p, get resultset, %p"
,
jobj
,
pObj
,
(
void
*
)
tres
);
return
tres
;
}
return
tres
;
}
JNIEXPORT
jint
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
con
,
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
197e59d8
...
...
@@ -111,6 +111,8 @@ public class TSDBJNIConnector {
* @throws SQLException
*/
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
);
}
...
...
@@ -123,21 +125,20 @@ public class TSDBJNIConnector {
this
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"Unsupported encoding"
));
}
int
code
=
this
.
getErrCode
(
pSql
);
if
(
code
!=
0
)
{
affectedRows
=
-
1
;
String
err_msg
=
this
.
getErrMsg
(
pSql
);
String
msg
=
this
.
getErrMsg
(
pSql
);
this
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
err_
msg
),
""
,
code
);
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
msg
),
""
,
code
);
}
// Try retrieving result set for the executed SQL using the current connection pointer. If the executed
// SQL is a DML/DDL which doesn't return a result set, then taosResultSetPointer should be 0L. Otherwise,
// taosResultSetPointer should be a non-zero value.
// Try retrieving result set for the executed SQL using the current connection pointer.
taosResultSetPointer
=
this
.
getResultSetImp
(
this
.
taos
,
pSql
);
if
(
taosResultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
isResultsetClosed
=
false
;
}
isResultsetClosed
=
(
taosResultSetPointer
==
TSDBConstants
.
JNI_NULL_POINTER
);
return
pSql
;
}
...
...
@@ -178,13 +179,14 @@ public class TSDBJNIConnector {
int
res
=
TSDBConstants
.
JNI_SUCCESS
;
if
(
result
!=
taosResultSetPointer
&&
taosResultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
throw
new
RuntimeException
(
"Invalid result set pointer"
);
}
else
if
(
taosResultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
}
if
(
taosResultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
res
=
this
.
freeResultSetImp
(
this
.
taos
,
result
);
isResultsetClosed
=
true
;
// reset resultSetPointer to 0 after freeResultSetImp() return
taosResultSetPointer
=
TSDBConstants
.
JNI_NULL_POINTER
;
}
else
{
isResultsetClosed
=
true
;
}
isResultsetClosed
=
true
;
return
res
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
197e59d8
...
...
@@ -51,6 +51,8 @@ public class TSDBStatement implements Statement {
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
// TODO make sure it is not a update query
pSql
=
this
.
connecter
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connecter
.
getResultSet
();
...
...
@@ -71,20 +73,19 @@ public class TSDBStatement implements Statement {
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
// TODO check if current query is update query
pSql
=
this
.
connecter
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connecter
.
getResultSet
();
if
(
resultSetPointer
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
this
.
connecter
.
freeResultSet
(
pSql
);
throw
new
SQLException
(
TSDBConstants
.
FixErrMsg
(
TSDBConstants
.
JNI_CONNECTION_NULL
));
}
else
if
(
resultSetPointer
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
this
.
connecter
.
freeResultSet
();
throw
new
SQLException
(
"The executed SQL is not a DML or a DDL"
);
}
else
{
int
num
=
this
.
connecter
.
getAffectedRows
(
pSql
);
this
.
connecter
.
freeResultSet
(
pSql
);
return
num
;
}
}
int
num
=
this
.
connecter
.
getAffectedRows
(
pSql
);
this
.
connecter
.
freeResultSet
(
pSql
);
return
num
;
}
public
String
getErrorMsg
(
long
pSql
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录