Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
b0b119
TDengine
提交
e74d20ec
TDengine
项目概览
b0b119
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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,发现更多精彩内容 >>
提交
e74d20ec
编写于
11月 18, 2020
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change name
上级
af51dce4
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
908 addition
and
21 deletion
+908
-21
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
...src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
+5
-4
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
...in/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
+886
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
...dbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+3
-3
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
+3
-3
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java
...n/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java
+2
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+6
-6
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
...src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
+3
-3
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/
Taos
RestfulConnection.java
→
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java
浏览文件 @
e74d20ec
...
...
@@ -7,7 +7,7 @@ import java.util.Map;
import
java.util.Properties
;
import
java.util.concurrent.Executor
;
public
class
Taos
RestfulConnection
implements
Connection
{
public
class
RestfulConnection
implements
Connection
{
private
final
String
host
;
private
final
int
port
;
...
...
@@ -16,7 +16,7 @@ public class TaosRestfulConnection implements Connection {
private
final
String
url
;
public
Taos
RestfulConnection
(
String
host
,
String
port
,
Properties
props
,
String
database
,
String
url
)
{
public
RestfulConnection
(
String
host
,
String
port
,
Properties
props
,
String
database
,
String
url
)
{
this
.
host
=
host
;
this
.
port
=
Integer
.
parseInt
(
port
);
this
.
props
=
props
;
...
...
@@ -28,7 +28,7 @@ public class TaosRestfulConnection implements Connection {
public
Statement
createStatement
()
throws
SQLException
{
if
(
isClosed
())
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"restful TDengine connection is closed."
));
return
new
Taos
RestfulStatement
(
this
,
this
.
database
);
return
new
RestfulStatement
(
this
,
this
.
database
);
}
@Override
...
...
@@ -78,7 +78,8 @@ public class TaosRestfulConnection implements Connection {
@Override
public
DatabaseMetaData
getMetaData
()
throws
SQLException
{
return
null
;
//TODO: RestfulDatabaseMetaData is not implemented
return
new
RestfulDatabaseMetaData
();
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java
0 → 100644
浏览文件 @
e74d20ec
此差异已折叠。
点击以展开。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/
Taos
RestfulDriver.java
→
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
浏览文件 @
e74d20ec
...
...
@@ -11,13 +11,13 @@ import java.sql.*;
import
java.util.Properties
;
import
java.util.logging.Logger
;
public
class
Taos
RestfulDriver
extends
AbstractTaosDriver
{
public
class
RestfulDriver
extends
AbstractTaosDriver
{
private
static
final
String
URL_PREFIX
=
"jdbc:TAOS-RS://"
;
static
{
try
{
DriverManager
.
registerDriver
(
new
Taos
RestfulDriver
());
DriverManager
.
registerDriver
(
new
RestfulDriver
());
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
TSDBConstants
.
WrapErrMsg
(
"can not register Restful JDBC driver"
),
e
);
}
...
...
@@ -48,7 +48,7 @@ public class TaosRestfulDriver extends AbstractTaosDriver {
throw
new
SQLException
(
jsonResult
.
getString
(
"desc"
));
}
return
new
Taos
RestfulConnection
(
host
,
port
,
props
,
database
,
url
);
return
new
RestfulConnection
(
host
,
port
,
props
,
database
,
url
);
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/
Taos
RestfulResultSet.java
→
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
浏览文件 @
e74d20ec
...
...
@@ -13,13 +13,13 @@ import java.util.Arrays;
import
java.util.Calendar
;
import
java.util.Map
;
public
class
Taos
RestfulResultSet
implements
ResultSet
{
public
class
RestfulResultSet
implements
ResultSet
{
private
boolean
isClosed
=
false
;
private
int
pos
=
-
1
;
private
ArrayList
<
ArrayList
<
String
>>
data
;
private
ArrayList
<
String
>
fields
;
public
Taos
RestfulResultSet
(
String
str
,
String
fieldData
)
{
public
RestfulResultSet
(
String
str
,
String
fieldData
)
{
data
=
new
ArrayList
<>();
str
=
str
.
substring
(
2
,
str
.
length
()
-
2
);
ArrayList
<
String
>
strTemp
=
new
ArrayList
<>(
Arrays
.
asList
(
str
.
split
(
"],\\["
)));
...
...
@@ -262,7 +262,7 @@ public class TaosRestfulResultSet implements ResultSet {
@Override
public
ResultSetMetaData
getMetaData
()
throws
SQLException
{
return
new
Taos
RestfulResultSetMetaData
(
fields
);
return
new
RestfulResultSetMetaData
(
fields
);
}
@Override
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/
Taos
RestfulResultSetMetaData.java
→
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java
浏览文件 @
e74d20ec
...
...
@@ -4,11 +4,11 @@ import java.sql.ResultSetMetaData;
import
java.sql.SQLException
;
import
java.util.List
;
public
class
Taos
RestfulResultSetMetaData
implements
ResultSetMetaData
{
public
class
RestfulResultSetMetaData
implements
ResultSetMetaData
{
private
List
<
String
>
fields
;
public
Taos
RestfulResultSetMetaData
(
List
<
String
>
fields
)
{
public
RestfulResultSetMetaData
(
List
<
String
>
fields
)
{
this
.
fields
=
fields
;
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/
Taos
RestfulStatement.java
→
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
e74d20ec
...
...
@@ -9,12 +9,12 @@ import java.sql.*;
import
java.util.Arrays
;
import
java.util.List
;
public
class
Taos
RestfulStatement
implements
Statement
{
public
class
RestfulStatement
implements
Statement
{
private
final
String
catalog
;
private
final
Taos
RestfulConnection
conn
;
private
final
RestfulConnection
conn
;
public
TaosRestfulStatement
(
Taos
RestfulConnection
c
,
String
catalog
)
{
public
RestfulStatement
(
RestfulConnection
c
,
String
catalog
)
{
this
.
conn
=
c
;
this
.
catalog
=
catalog
;
}
...
...
@@ -46,12 +46,12 @@ public class TaosRestfulStatement implements Statement {
}
String
dataStr
=
jsonObject
.
getString
(
"data"
);
if
(
"use"
.
equalsIgnoreCase
(
fields
.
split
(
" "
)[
0
]))
{
return
new
Taos
RestfulResultSet
(
dataStr
,
""
);
return
new
RestfulResultSet
(
dataStr
,
""
);
}
JSONObject
jsonField
=
JSON
.
parseObject
(
fields
);
if
(
jsonField
==
null
)
{
return
new
Taos
RestfulResultSet
(
dataStr
,
""
);
return
new
RestfulResultSet
(
dataStr
,
""
);
}
if
(
jsonField
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"SQL execution error: "
+
...
...
@@ -60,7 +60,7 @@ public class TaosRestfulStatement implements Statement {
}
String
fieldData
=
jsonField
.
getString
(
"data"
);
return
new
Taos
RestfulResultSet
(
dataStr
,
fieldData
);
return
new
RestfulResultSet
(
dataStr
,
fieldData
);
}
@Override
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/
Taos
RestfulDriverTest.java
→
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java
浏览文件 @
e74d20ec
...
...
@@ -5,12 +5,12 @@ import org.junit.Test;
import
java.sql.*
;
public
class
Taos
RestfulDriverTest
{
public
class
RestfulDriverTest
{
@Test
public
void
testCase001
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.
Taos
RestfulDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
Connection
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://master:6041/?user=root&password=taosdata"
);
Statement
statement
=
connection
.
createStatement
();
ResultSet
resultSet
=
statement
.
executeQuery
(
"select * from log.log"
);
...
...
@@ -32,7 +32,7 @@ public class TaosRestfulDriverTest {
@Test
public
void
testAcceptUrl
()
throws
SQLException
{
Driver
driver
=
new
Taos
RestfulDriver
();
Driver
driver
=
new
RestfulDriver
();
boolean
isAccept
=
driver
.
acceptsURL
(
"jdbc:TAOS-RS://master:6041"
);
Assert
.
assertTrue
(
isAccept
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录