Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
293524b4
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
293524b4
编写于
2月 25, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
a3d87f88
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
62 deletion
+40
-62
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
...bc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
+35
-3
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+3
-39
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+0
-18
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulStatementTest.java
.../test/java/com/taosdata/jdbc/rs/RestfulStatementTest.java
+2
-2
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
浏览文件 @
293524b4
package
com.taosdata.jdbc
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.List
;
public
abstract
class
AbstractStatement
extends
WrapperImpl
implements
Statement
{
protected
List
<
String
>
batchedArgs
;
private
int
fetchSize
;
@Override
...
...
@@ -168,13 +171,42 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
}
@Override
public
abstract
void
addBatch
(
String
sql
)
throws
SQLException
;
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
==
null
)
{
batchedArgs
=
new
ArrayList
<>();
}
batchedArgs
.
add
(
sql
);
}
@Override
public
abstract
void
clearBatch
()
throws
SQLException
;
public
void
clearBatch
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
!=
null
)
batchedArgs
.
clear
();
}
@Override
public
abstract
int
[]
executeBatch
()
throws
SQLException
;
public
int
[]
executeBatch
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
==
null
||
batchedArgs
.
isEmpty
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_BATCH_IS_EMPTY
);
int
[]
res
=
new
int
[
batchedArgs
.
size
()];
for
(
int
i
=
0
;
i
<
batchedArgs
.
size
();
i
++)
{
boolean
isSelect
=
execute
(
batchedArgs
.
get
(
i
));
if
(
isSelect
)
{
res
[
i
]
=
SUCCESS_NO_INFO
;
}
else
{
res
[
i
]
=
getUpdateCount
();
}
}
return
res
;
}
@Override
public
abstract
Connection
getConnection
()
throws
SQLException
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
293524b4
...
...
@@ -14,9 +14,9 @@
*****************************************************************************/
package
com.taosdata.jdbc
;
import
java.sql.
*
;
import
java.
util.ArrayLis
t
;
import
java.
util.List
;
import
java.sql.
Connection
;
import
java.
sql.ResultSe
t
;
import
java.
sql.SQLException
;
public
class
TSDBStatement
extends
AbstractStatement
{
...
...
@@ -24,7 +24,6 @@ public class TSDBStatement extends AbstractStatement {
/**
* To store batched commands
*/
protected
List
<
String
>
batchedArgs
;
/**
* Status of current statement
*/
...
...
@@ -119,41 +118,6 @@ public class TSDBStatement extends AbstractStatement {
return
this
.
affectedRows
;
}
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
==
null
)
{
batchedArgs
=
new
ArrayList
<>();
}
batchedArgs
.
add
(
sql
);
}
public
void
clearBatch
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
!=
null
)
batchedArgs
.
clear
();
}
public
int
[]
executeBatch
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(
batchedArgs
==
null
||
batchedArgs
.
isEmpty
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_BATCH_IS_EMPTY
);
int
[]
res
=
new
int
[
batchedArgs
.
size
()];
for
(
int
i
=
0
;
i
<
batchedArgs
.
size
();
i
++)
{
boolean
isSelect
=
execute
(
batchedArgs
.
get
(
i
));
if
(
isSelect
)
{
res
[
i
]
=
SUCCESS_NO_INFO
;
}
else
{
res
[
i
]
=
getUpdateCount
();
}
}
return
res
;
}
public
Connection
getConnection
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
293524b4
...
...
@@ -213,24 +213,6 @@ public class RestfulStatement extends AbstractStatement {
return
this
.
affectedRows
;
}
@Override
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
//TODO:
}
@Override
public
void
clearBatch
()
throws
SQLException
{
//TODO:
}
@Override
public
int
[]
executeBatch
()
throws
SQLException
{
//TODO:
return
new
int
[
0
];
}
@Override
public
Connection
getConnection
()
throws
SQLException
{
if
(
isClosed
())
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulStatementTest.java
浏览文件 @
293524b4
...
...
@@ -11,8 +11,8 @@ import java.util.Properties;
import
java.util.UUID
;
public
class
RestfulStatementTest
{
private
static
final
String
host
=
"127.0.0.1"
;
//
private static final String host = "master";
//
private static final String host = "127.0.0.1";
private
static
final
String
host
=
"master"
;
private
static
Connection
conn
;
private
static
Statement
stmt
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录