hi tiany??
i am so sorry ?? my english is poor??
Connection conn = null;
Statement stmt = null;
conn = .......;
stmt = conm.createStatement(xxxxxx);
ResultSet rs = stmt.executeQuery(sql1);
while(rs.next()){
str = rs.getString(xxxxx);
ResultSet rs1 = stmt.executeQuery(\"select * from
anyTable where any=str\");
}
it's true??
????????iPhone
------------------ Original ------------------
From: ???? <[email protected]>
Date: Wed,Nov 6,2019 6:34 PM
To: dev <[email protected]>
Subject: Re: (IOTDB-291) Statement close operation may cause the whole
connection's resource to be released
Hi, Liu
You mean at the same time, one statement can only hold one ResultSet in
mysql-jdbc?
> -----????????-----
> ??????: "????????.????`" <[email protected]>
> ????????: 2019-11-06 17:41:28 (??????)
> ??????: dev <[email protected]>
> ????:
> ????: ?????? (IOTDB-291) Statement close operation may cause the whole
connection's resource to be released
>
> hi&nbsp;tiany,&nbsp;
> in&nbsp;cluster, how to save the&nbsp;statementId Map, and how to
releases the resources corresponding of&nbsp;queryIds ,&nbsp;
> i see mysql jdbc when call execute(sql) method , it will
to&nbsp;implicitlyCloseAllOpenResults ,why not&nbsp;refer to this??
> you want the client nested call ?
> ------------------&nbsp;????????&nbsp;------------------
> ??????:&nbsp;"????"<[email protected]&gt;;
> ????????:&nbsp;2019??11??6??(??????) ????5:13
> ??????:&nbsp;"dev"<[email protected]&gt;;
>
> ????:&nbsp;Re: (IOTDB-291) Statement close operation may cause the
whole connection's resource to be released
>
>
>
> Hi,
>
> I have solved the issued by maintaining a ThreadLocal<Map<Long,
Set<Long&gt;&gt;&gt; in the TSServiceImpl which is a map
(statementId -&gt; all queryIds in that statement).
>
> Every time the statement is closed, all the queryIds in that map should
also be closed.
> However, when a ResultSet is closed, it only releases the resources
corresponding to that queryId.
> When the connection is closed, the function closeSession() is invoked, it
will release all the resource saved in that session thread.
>
> The PR link is https://github.com/apache/incubator-iotdb/pull/526.
>
>
> &gt; -----????????-----
> &gt; ??????: "Yuan Tian (Jira)" <[email protected]&gt;
> &gt; ????????: 2019-11-05 22:53:00 (??????)
> &gt; ??????: [email protected]
> &gt; ????:
> &gt; ????: [jira] [Created] (IOTDB-291) Statement close operation may
cause the whole connection's resource to be released
> &gt;
> &gt; Yuan Tian created IOTDB-291:
> &gt; -------------------------------
> &gt;
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Summary: Statement close operation may cause the whole connection's resource
to be released
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Key: IOTDB-291
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
URL: https://issues.apache.org/jira/browse/IOTDB-291
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Project: Apache IoTDB
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Issue Type: Bug
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Reporter: Yuan Tian
> &gt;
> &gt;
> &gt; The function closeClientOperation() in IoTDBStatement.java
invokes the function closeOperation(TSCloseOperationReq) in TSServiceImpl.
> &gt; Because the queryId field in TSCloseOperationReq is set to be
-1L, the releaseQueryResource&nbsp; function will release all the
resources&nbsp; in that connection.
> &gt;
> &gt; {code:java}
> &gt;&nbsp;&nbsp; private void closeClientOperation() throws
SQLException {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; try {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
(operationHandle != null) {
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TSCloseOperationReq closeReq = new TSCloseOperationReq(operationHandle, -1);
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
closeReq.setStmtId(stmtId);
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TSStatus closeResp = client.closeOperation(closeReq);
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
RpcUtils.verifySuccess(closeResp);
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; } catch (Exception e) {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw
new SQLException("Error occurs when closing statement.", e);
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt;&nbsp;&nbsp; }
> &gt; {code}
> &gt;
> &gt; {code:java}
> &gt;&nbsp;&nbsp; private void
releaseQueryResource(TSCloseOperationReq req) throws StorageEngineException {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; Map<Long,
QueryContext&gt; contextMap = contextMapLocal.get();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; if (contextMap == null) {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return;
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; if (req == null ||
req.queryId == -1) {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
end query for all the query tokens created by current thread
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for
(QueryContext context : contextMap.values()) {
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
QueryResourceManager.getInstance().endQueryForGivenJob(context.getJobId());
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
contextMapLocal.set(new HashMap<&gt;());
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; } else {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
QueryResourceManager.getInstance()
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
.endQueryForGivenJob(contextMap.remove(req.queryId).getJobId());
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt;&nbsp;&nbsp; }
> &gt; {code}
> &gt;
> &gt;
> &gt;
> &gt;
> &gt; --
> &gt; This message was sent by Atlassian Jira
> &gt; (v8.3.4#803005)