Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
99741286
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
99741286
编写于
9月 14, 2020
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adapt the calcite for customer GLD
上级
21584e30
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
561 addition
and
468 deletion
+561
-468
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+125
-102
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
.../jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
+0
-54
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
...src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
+3
-3
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
...ctor/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
+353
-309
src/connector/jdbc/src/main/java/com/taosdata/jdbc/cases/CalciteTest.java
...bc/src/main/java/com/taosdata/jdbc/cases/CalciteTest.java
+80
-0
未找到文件。
src/connector/jdbc/pom.xml
浏览文件 @
99741286
...
@@ -59,6 +59,29 @@
...
@@ -59,6 +59,29 @@
<version>
4.13
</version>
<version>
4.13
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<!-- calcite -->
<dependency>
<groupId>
org.apache.calcite
</groupId>
<artifactId>
calcite-core
</artifactId>
<version>
1.23.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-dbcp2
</artifactId>
<version>
2.7.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.calcite.avatica
</groupId>
<artifactId>
avatica-core
</artifactId>
<version>
1.17.0
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.47
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java
浏览文件 @
99741286
...
@@ -53,66 +53,12 @@ public class TSDBConnection implements Connection {
...
@@ -53,66 +53,12 @@ public class TSDBConnection implements Connection {
public
TSDBConnection
(
Properties
info
,
TSDBDatabaseMetaData
meta
)
throws
SQLException
{
public
TSDBConnection
(
Properties
info
,
TSDBDatabaseMetaData
meta
)
throws
SQLException
{
this
.
dbMetaData
=
meta
;
this
.
dbMetaData
=
meta
;
//load taos.cfg start
File
cfgDir
=
loadConfigDir
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_CONFIG_DIR
));
File
cfgFile
=
cfgDir
.
listFiles
((
dir
,
name
)
->
"taos.cfg"
.
equalsIgnoreCase
(
name
))[
0
];
List
<
String
>
endpoints
=
loadConfigEndpoints
(
cfgFile
);
if
(!
endpoints
.
isEmpty
())
{
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
endpoints
.
get
(
0
).
split
(
":"
)[
0
]);
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
endpoints
.
get
(
0
).
split
(
":"
)[
1
]);
}
//load taos.cfg end
connect
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
),
connect
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
),
Integer
.
parseInt
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
"0"
)),
Integer
.
parseInt
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
"0"
)),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_DBNAME
),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
),
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
));
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
));
}
}
private
List
<
String
>
loadConfigEndpoints
(
File
cfgFile
)
{
List
<
String
>
endpoints
=
new
ArrayList
<>();
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
cfgFile
)))
{
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
trim
().
startsWith
(
"firstEp"
)
||
line
.
trim
().
startsWith
(
"secondEp"
))
{
endpoints
.
add
(
line
.
substring
(
line
.
indexOf
(
'p'
)
+
1
).
trim
());
}
if
(
endpoints
.
size
()
>
1
)
break
;
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
endpoints
;
}
/**
* @param cfgDirPath
* @return return the config dir
**/
private
File
loadConfigDir
(
String
cfgDirPath
)
{
if
(
cfgDirPath
==
null
)
return
loadDefaultConfigDir
();
File
cfgDir
=
new
File
(
cfgDirPath
);
if
(!
cfgDir
.
exists
())
return
loadDefaultConfigDir
();
return
cfgDir
;
}
/**
* @return search the default config dir, if the config dir is not exist will return null
*/
private
File
loadDefaultConfigDir
()
{
File
cfgDir
;
File
cfgDir_linux
=
new
File
(
"/etc/taos"
);
cfgDir
=
cfgDir_linux
.
exists
()
?
cfgDir_linux
:
null
;
File
cfgDir_windows
=
new
File
(
"C:\\TDengine\\cfg"
);
cfgDir
=
(
cfgDir
==
null
&&
cfgDir_windows
.
exists
())
?
cfgDir_windows
:
cfgDir
;
return
cfgDir
;
}
private
void
connect
(
String
host
,
int
port
,
String
dbName
,
String
user
,
String
password
)
throws
SQLException
{
private
void
connect
(
String
host
,
int
port
,
String
dbName
,
String
user
,
String
password
)
throws
SQLException
{
this
.
connector
=
new
TSDBJNIConnector
();
this
.
connector
=
new
TSDBJNIConnector
();
this
.
connector
.
connect
(
host
,
port
,
dbName
,
user
,
password
);
this
.
connector
.
connect
(
host
,
port
,
dbName
,
user
,
password
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java
浏览文件 @
99741286
...
@@ -68,15 +68,15 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
...
@@ -68,15 +68,15 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
}
}
public
boolean
nullsAreSortedLow
()
throws
SQLException
{
public
boolean
nullsAreSortedLow
()
throws
SQLException
{
return
false
;
return
!
nullsAreSortedHigh
()
;
}
}
public
boolean
nullsAreSortedAtStart
()
throws
SQLException
{
public
boolean
nullsAreSortedAtStart
()
throws
SQLException
{
return
fals
e
;
return
tru
e
;
}
}
public
boolean
nullsAreSortedAtEnd
()
throws
SQLException
{
public
boolean
nullsAreSortedAtEnd
()
throws
SQLException
{
return
false
;
return
!
nullsAreSortedAtStart
()
;
}
}
public
String
getDatabaseProductName
()
throws
SQLException
{
public
String
getDatabaseProductName
()
throws
SQLException
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
99741286
...
@@ -16,7 +16,10 @@ package com.taosdata.jdbc;
...
@@ -16,7 +16,10 @@ package com.taosdata.jdbc;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.*
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
...
@@ -118,17 +121,71 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -118,17 +121,71 @@ public class TSDBDriver implements java.sql.Driver {
}
}
}
}
private
List
<
String
>
loadConfigEndpoints
(
File
cfgFile
)
{
List
<
String
>
endpoints
=
new
ArrayList
<>();
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
cfgFile
)))
{
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
trim
().
startsWith
(
"firstEp"
)
||
line
.
trim
().
startsWith
(
"secondEp"
))
{
endpoints
.
add
(
line
.
substring
(
line
.
indexOf
(
'p'
)
+
1
).
trim
());
}
if
(
endpoints
.
size
()
>
1
)
break
;
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
endpoints
;
}
/**
* @param cfgDirPath
* @return return the config dir
**/
private
File
loadConfigDir
(
String
cfgDirPath
)
{
if
(
cfgDirPath
==
null
)
return
loadDefaultConfigDir
();
File
cfgDir
=
new
File
(
cfgDirPath
);
if
(!
cfgDir
.
exists
())
return
loadDefaultConfigDir
();
return
cfgDir
;
}
/**
* @return search the default config dir, if the config dir is not exist will return null
*/
private
File
loadDefaultConfigDir
()
{
File
cfgDir
;
File
cfgDir_linux
=
new
File
(
"/etc/taos"
);
cfgDir
=
cfgDir_linux
.
exists
()
?
cfgDir_linux
:
null
;
File
cfgDir_windows
=
new
File
(
"C:\\TDengine\\cfg"
);
cfgDir
=
(
cfgDir
==
null
&&
cfgDir_windows
.
exists
())
?
cfgDir_windows
:
cfgDir
;
return
cfgDir
;
}
public
Connection
connect
(
String
url
,
Properties
info
)
throws
SQLException
{
public
Connection
connect
(
String
url
,
Properties
info
)
throws
SQLException
{
if
(
url
==
null
)
{
if
(
url
==
null
)
{
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"url is not set!"
));
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
"url is not set!"
));
}
}
Properties
props
=
null
;
Properties
props
=
null
;
if
((
props
=
parseURL
(
url
,
info
))
==
null
)
{
if
((
props
=
parseURL
(
url
,
info
))
==
null
)
{
return
null
;
return
null
;
}
}
//load taos.cfg start
if
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
)
==
null
&&
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
)
==
null
){
File
cfgDir
=
loadConfigDir
(
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_CONFIG_DIR
));
File
cfgFile
=
cfgDir
.
listFiles
((
dir
,
name
)
->
"taos.cfg"
.
equalsIgnoreCase
(
name
))[
0
];
List
<
String
>
endpoints
=
loadConfigEndpoints
(
cfgFile
);
if
(!
endpoints
.
isEmpty
())
{
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
endpoints
.
get
(
0
).
split
(
":"
)[
0
]);
info
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
,
endpoints
.
get
(
0
).
split
(
":"
)[
1
]);
}
}
try
{
try
{
TSDBJNIConnector
.
init
((
String
)
props
.
get
(
PROPERTY_KEY_CONFIG_DIR
),
(
String
)
props
.
get
(
PROPERTY_KEY_LOCALE
),
(
String
)
props
.
get
(
PROPERTY_KEY_CHARSET
),
TSDBJNIConnector
.
init
((
String
)
props
.
get
(
PROPERTY_KEY_CONFIG_DIR
),
(
String
)
props
.
get
(
PROPERTY_KEY_LOCALE
),
(
String
)
props
.
get
(
PROPERTY_KEY_CHARSET
),
(
String
)
props
.
get
(
PROPERTY_KEY_TIME_ZONE
));
(
String
)
props
.
get
(
PROPERTY_KEY_TIME_ZONE
));
...
@@ -153,13 +210,9 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -153,13 +210,9 @@ public class TSDBDriver implements java.sql.Driver {
* and the element of index PORT_NUMBER_INDEX being the port (or null if not
* and the element of index PORT_NUMBER_INDEX being the port (or null if not
* specified).
* specified).
*
*
* @param hostPortPair
* @param hostPortPair host and port in form of of [host][:port]
* host and port in form of of [host][:port]
*
* @return array containing host and port as Strings
* @return array containing host and port as Strings
*
* @throws SQLException if a parse error occurs
* @throws SQLException
* if a parse error occurs
*/
*/
protected
static
String
[]
parseHostPortPair
(
String
hostPortPair
)
throws
SQLException
{
protected
static
String
[]
parseHostPortPair
(
String
hostPortPair
)
throws
SQLException
{
String
[]
splitValues
=
new
String
[
2
];
String
[]
splitValues
=
new
String
[
2
];
...
@@ -203,8 +256,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -203,8 +256,7 @@ public class TSDBDriver implements java.sql.Driver {
DriverPropertyInfo
hostProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_HOST
,
info
.
getProperty
(
PROPERTY_KEY_HOST
));
DriverPropertyInfo
hostProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_HOST
,
info
.
getProperty
(
PROPERTY_KEY_HOST
));
hostProp
.
required
=
true
;
hostProp
.
required
=
true
;
DriverPropertyInfo
portProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_PORT
,
DriverPropertyInfo
portProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_PORT
,
info
.
getProperty
(
PROPERTY_KEY_PORT
,
TSDBConstants
.
DEFAULT_PORT
));
info
.
getProperty
(
PROPERTY_KEY_PORT
,
TSDBConstants
.
DEFAULT_PORT
));
portProp
.
required
=
false
;
portProp
.
required
=
false
;
DriverPropertyInfo
dbProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_DBNAME
,
info
.
getProperty
(
PROPERTY_KEY_DBNAME
));
DriverPropertyInfo
dbProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_DBNAME
,
info
.
getProperty
(
PROPERTY_KEY_DBNAME
));
...
@@ -214,8 +266,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -214,8 +266,7 @@ public class TSDBDriver implements java.sql.Driver {
DriverPropertyInfo
userProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_USER
,
info
.
getProperty
(
PROPERTY_KEY_USER
));
DriverPropertyInfo
userProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_USER
,
info
.
getProperty
(
PROPERTY_KEY_USER
));
userProp
.
required
=
true
;
userProp
.
required
=
true
;
DriverPropertyInfo
passwordProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_PASSWORD
,
DriverPropertyInfo
passwordProp
=
new
DriverPropertyInfo
(
PROPERTY_KEY_PASSWORD
,
info
.
getProperty
(
PROPERTY_KEY_PASSWORD
));
info
.
getProperty
(
PROPERTY_KEY_PASSWORD
));
passwordProp
.
required
=
true
;
passwordProp
.
required
=
true
;
DriverPropertyInfo
[]
propertyInfo
=
new
DriverPropertyInfo
[
5
];
DriverPropertyInfo
[]
propertyInfo
=
new
DriverPropertyInfo
[
5
];
...
@@ -231,7 +282,6 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -231,7 +282,6 @@ public class TSDBDriver implements java.sql.Driver {
/**
/**
* example: jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_password
* example: jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_password
*/
*/
public
Properties
parseURL
(
String
url
,
Properties
defaults
)
throws
java
.
sql
.
SQLException
{
public
Properties
parseURL
(
String
url
,
Properties
defaults
)
throws
java
.
sql
.
SQLException
{
Properties
urlProps
=
(
defaults
!=
null
)
?
defaults
:
new
Properties
();
Properties
urlProps
=
(
defaults
!=
null
)
?
defaults
:
new
Properties
();
if
(
url
==
null
)
{
if
(
url
==
null
)
{
...
@@ -263,7 +313,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -263,7 +313,7 @@ public class TSDBDriver implements java.sql.Driver {
url
=
url
.
trim
().
substring
(
url
.
indexOf
(
"?"
)
+
1
);
url
=
url
.
trim
().
substring
(
url
.
indexOf
(
"?"
)
+
1
);
}
else
{
}
else
{
// without user & password so return
// without user & password so return
if
(!
url
.
trim
().
isEmpty
())
{
if
(!
url
.
trim
().
isEmpty
())
{
String
dbName
=
url
.
trim
();
String
dbName
=
url
.
trim
();
urlProps
.
setProperty
(
PROPERTY_KEY_DBNAME
,
dbName
);
urlProps
.
setProperty
(
PROPERTY_KEY_DBNAME
,
dbName
);
}
}
...
@@ -284,7 +334,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -284,7 +334,7 @@ public class TSDBDriver implements java.sql.Driver {
String
[]
queryStrings
=
url
.
trim
().
split
(
"&"
);
String
[]
queryStrings
=
url
.
trim
().
split
(
"&"
);
for
(
String
queryStr
:
queryStrings
)
{
for
(
String
queryStr
:
queryStrings
)
{
String
[]
kvPair
=
queryStr
.
trim
().
split
(
"="
);
String
[]
kvPair
=
queryStr
.
trim
().
split
(
"="
);
if
(
kvPair
.
length
<
2
)
{
if
(
kvPair
.
length
<
2
)
{
continue
;
continue
;
}
}
setPropertyValue
(
urlProps
,
kvPair
);
setPropertyValue
(
urlProps
,
kvPair
);
...
@@ -339,9 +389,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -339,9 +389,7 @@ public class TSDBDriver implements java.sql.Driver {
/**
/**
* Returns the host property
* Returns the host property
*
*
* @param props
* @param props the java.util.Properties instance to retrieve the hostname from.
* the java.util.Properties instance to retrieve the hostname from.
*
* @return the host
* @return the host
*/
*/
public
String
host
(
Properties
props
)
{
public
String
host
(
Properties
props
)
{
...
@@ -351,9 +399,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -351,9 +399,7 @@ public class TSDBDriver implements java.sql.Driver {
/**
/**
* Returns the port number property
* Returns the port number property
*
*
* @param props
* @param props the properties to get the port number from
* the properties to get the port number from
*
* @return the port number
* @return the port number
*/
*/
public
int
port
(
Properties
props
)
{
public
int
port
(
Properties
props
)
{
...
@@ -363,9 +409,7 @@ public class TSDBDriver implements java.sql.Driver {
...
@@ -363,9 +409,7 @@ public class TSDBDriver implements java.sql.Driver {
/**
/**
* Returns the database property from <code>props</code>
* Returns the database property from <code>props</code>
*
*
* @param props
* @param props the Properties to look for the database property.
* the Properties to look for the database property.
*
* @return the database name.
* @return the database name.
*/
*/
public
String
database
(
Properties
props
)
{
public
String
database
(
Properties
props
)
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/cases/CalciteTest.java
0 → 100644
浏览文件 @
99741286
package
com.taosdata.jdbc.cases
;
import
org.apache.calcite.adapter.jdbc.JdbcSchema
;
import
org.apache.calcite.jdbc.CalciteConnection
;
import
org.apache.calcite.schema.SchemaPlus
;
import
org.apache.calcite.sql.parser.SqlParseException
;
import
org.apache.commons.dbcp2.BasicDataSource
;
import
java.sql.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
public
class
CalciteTest
{
public
static
void
main
(
String
[]
args
)
throws
SqlParseException
,
ClassNotFoundException
,
SQLException
{
//创建Calcite Connection对象
Class
.
forName
(
"org.apache.calcite.jdbc.Driver"
);
Properties
info
=
new
Properties
();
info
.
setProperty
(
"caseSensitive"
,
"false"
);
Connection
connection
=
DriverManager
.
getConnection
(
"jdbc:calcite:"
,
info
);
CalciteConnection
calciteConnection
=
connection
.
unwrap
(
CalciteConnection
.
class
);
SchemaPlus
rootSchema
=
calciteConnection
.
getRootSchema
();
// JDBC adapter
Class
.
forName
(
"com.mysql.jdbc.Driver"
);
BasicDataSource
dataSource
=
new
BasicDataSource
();
dataSource
.
setUrl
(
"jdbc:mysql://192.168.56.101:3306"
);
dataSource
.
setUsername
(
"root"
);
dataSource
.
setPassword
(
"123456"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
JdbcSchema
schema
=
JdbcSchema
.
create
(
rootSchema
,
"hr"
,
dataSource
,
null
,
null
);
rootSchema
.
add
(
"hr"
,
schema
);
Statement
statement
=
calciteConnection
.
createStatement
();
ResultSet
resultSet
=
statement
.
executeQuery
(
"select * from hr.depts"
);
while
(
resultSet
.
next
())
{
ResultSetMetaData
metaData
=
resultSet
.
getMetaData
();
for
(
int
i
=
1
;
i
<=
metaData
.
getColumnCount
();
i
++)
{
String
columnLabel
=
metaData
.
getColumnLabel
(
i
);
System
.
out
.
println
(
columnLabel
+
" : "
+
resultSet
.
getString
(
i
));
}
}
resultSet
.
close
();
statement
.
close
();
connection
.
close
();
//创建TDengine的数据源schema
// Class.forName("com.taosdata.jdbc.TSDBDriver");
// String url = "jdbc:TAOS://127.0.0.1:6030/hdb";
// dataSource.setUrl(url);
// dataSource.setUsername("root");
// dataSource.setPassword("taosdata");
// Class.forName("com.mysql.jdbc.Driver");
// String url = "jdbc:mysql://localhost:3306/hdb";
// BasicDataSource dataSource = new BasicDataSource();
// dataSource.setUrl(url);
// dataSource.setUsername("root");
// dataSource.setPassword("123456");
//这里hdb是在tdengine中创建的数据库名
// JdbcSchema schema = JdbcSchema.create(rootSchema, "test", dataSource, null, "test");
// Schema schema = JdbcSchema.create(rootSchema, "test", dataSource, "hdb", null);
//创建新的schema自动映射到原来的hdb数据库
// rootSchema.add("test", schema);
// Statement stmt = calciteConnection.createStatement();
//查询schema test中的表,表名是tdengine中的表
// ResultSet rs = stmt.executeQuery("select * from test.t");
// for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
// System.out.println(rs.getMetaData().getColumnName(i));
// }
// while (rs.next()) {
// System.out.println(rs.getObject(1));
// }
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录