Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
f146ada4
T
TDengine
项目概览
小楼昨夜-听风雨
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f146ada4
编写于
2月 03, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
d719810b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
112 deletion
+45
-112
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
...bc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
+32
-6
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+0
-42
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+0
-56
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
...bc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
+13
-8
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractStatement.java
浏览文件 @
f146ada4
...
...
@@ -5,6 +5,7 @@ import java.sql.*;
public
abstract
class
AbstractStatement
implements
Statement
{
private
volatile
boolean
closeOnCompletion
;
private
int
fetchSize
;
@Override
public
abstract
ResultSet
executeQuery
(
String
sql
)
throws
SQLException
;
...
...
@@ -116,7 +117,11 @@ public abstract class AbstractStatement implements Statement {
}
@Override
public
abstract
int
getFetchDirection
()
throws
SQLException
;
public
int
getFetchDirection
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
FETCH_FORWARD
;
}
@Override
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
...
...
@@ -125,16 +130,29 @@ public abstract class AbstractStatement implements Statement {
if
(
rows
<
0
)
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
//nothing to do
this
.
fetchSize
=
rows
;
}
@Override
public
abstract
int
getFetchSize
()
throws
SQLException
;
public
int
getFetchSize
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
fetchSize
;
}
@Override
public
abstract
int
getResultSetConcurrency
()
throws
SQLException
;
public
int
getResultSetConcurrency
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
CONCUR_READ_ONLY
;
}
@Override
public
abstract
int
getResultSetType
()
throws
SQLException
;
public
int
getResultSetType
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
TYPE_FORWARD_ONLY
;
}
@Override
public
abstract
void
addBatch
(
String
sql
)
throws
SQLException
;
...
...
@@ -149,7 +167,11 @@ public abstract class AbstractStatement implements Statement {
public
abstract
Connection
getConnection
()
throws
SQLException
;
@Override
public
abstract
boolean
getMoreResults
(
int
current
)
throws
SQLException
;
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
false
;
}
@Override
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
...
...
@@ -187,7 +209,11 @@ public abstract class AbstractStatement implements Statement {
}
@Override
public
abstract
int
getResultSetHoldability
()
throws
SQLException
;
public
int
getResultSetHoldability
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
;
}
@Override
public
abstract
boolean
isClosed
()
throws
SQLException
;
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
f146ada4
...
...
@@ -21,12 +21,10 @@ import java.util.List;
public
class
TSDBStatement
extends
AbstractStatement
{
private
TSDBJNIConnector
connector
;
/**
* To store batched commands
*/
protected
List
<
String
>
batchedArgs
;
// private Long pSql = 0l;
/**
* Status of current statement
*/
...
...
@@ -107,7 +105,6 @@ public class TSDBStatement extends AbstractStatement {
public
ResultSet
getResultSet
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
// long resultSetPointer = connector.getResultSet();
// TSDBResultSet resSet = null;
// if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
...
...
@@ -122,33 +119,6 @@ public class TSDBStatement extends AbstractStatement {
return
this
.
affectedRows
;
}
public
int
getFetchDirection
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
resultSet
.
getFetchDirection
();
}
/*
* used by spark
*/
public
int
getFetchSize
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
resultSet
.
getFetchSize
();
}
public
int
getResultSetConcurrency
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
resultSet
.
getConcurrency
();
}
public
int
getResultSetType
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
resultSet
.
getType
();
}
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
...
...
@@ -192,18 +162,6 @@ public class TSDBStatement extends AbstractStatement {
return
this
.
connection
;
}
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
new
SQLException
(
TSDBConstants
.
UNSUPPORTED_METHOD_EXCEPTION_MSG
);
}
public
int
getResultSetHoldability
()
throws
SQLException
{
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
return
this
.
resultSet
.
getHoldability
();
}
public
boolean
isClosed
()
throws
SQLException
{
return
isClosed
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
f146ada4
...
...
@@ -192,32 +192,6 @@ public class RestfulStatement extends AbstractStatement {
return
this
.
affectedRows
;
}
@Override
public
int
getFetchDirection
()
throws
SQLException
{
return
this
.
resultSet
.
getFetchDirection
();
}
@Override
public
int
getFetchSize
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
0
;
}
@Override
public
int
getResultSetConcurrency
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
resultSet
.
getConcurrency
();
}
@Override
public
int
getResultSetType
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
resultSet
.
getType
();
}
@Override
public
void
addBatch
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
...
...
@@ -243,36 +217,6 @@ public class RestfulStatement extends AbstractStatement {
return
this
.
conn
;
}
@Override
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
if
(
resultSet
==
null
)
return
false
;
// switch (current) {
// case CLOSE_CURRENT_RESULT:
// resultSet.close();
// break;
// case KEEP_CURRENT_RESULT:
// break;
// case CLOSE_ALL_RESULTS:
// resultSet.close();
// break;
// default:
// throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// }
// return next;
return
false
;
}
@Override
public
int
getResultSetHoldability
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
STATEMENT_CLOSED
);
return
this
.
resultSet
.
getHoldability
();
}
@Override
public
boolean
isClosed
()
throws
SQLException
{
return
closed
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBStatementTest.java
浏览文件 @
f146ada4
package
com.taosdata.jdbc
;
import
org.junit.AfterClass
;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.util.Properties
;
import
java.util.UUID
;
public
class
TSDBStatementTest
{
private
static
final
String
host
=
"127.0.0.1"
;
...
...
@@ -16,6 +18,7 @@ public class TSDBStatementTest {
public
void
executeQuery
()
{
try
{
ResultSet
rs
=
stmt
.
executeQuery
(
"show databases"
);
Assert
.
assertNotNull
(
rs
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
...
...
@@ -31,6 +34,15 @@ public class TSDBStatementTest {
@Test
public
void
executeUpdate
()
{
final
String
dbName
=
"test_"
+
UUID
.
randomUUID
();
try
{
int
affectRows
=
stmt
.
executeUpdate
(
"create database "
+
dbName
);
Assert
.
assertEquals
(
0
,
affectRows
);
affectRows
=
stmt
.
executeUpdate
(
"drop database "
+
dbName
);
Assert
.
assertEquals
(
0
,
affectRows
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
...
...
@@ -39,6 +51,7 @@ public class TSDBStatementTest {
@Test
public
void
execute
()
{
}
@Test
...
...
@@ -49,14 +62,6 @@ public class TSDBStatementTest {
public
void
getUpdateCount
()
{
}
@Test
public
void
getFetchDirection
()
{
}
@Test
public
void
getFetchSize
()
{
}
@Test
public
void
getResultSetConcurrency
()
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录