Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a763cb48
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a763cb48
编写于
1月 27, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
3e588cff
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
0 addition
and
126 deletion
+0
-126
tests/examples/JDBC/calciteDemo/pom.xml
tests/examples/JDBC/calciteDemo/pom.xml
+0
-53
tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java
...c/main/java/com/taosdata/example/calcite/CalciteDemo.java
+0
-67
tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties
...ples/JDBC/calciteDemo/src/main/resources/log4j.properties
+0
-6
未找到文件。
tests/examples/JDBC/calciteDemo/pom.xml
已删除
100644 → 0
浏览文件 @
3e588cff
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.taosdata.example.calcite
</groupId>
<artifactId>
calciteDemo
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<!-- slf4j -->
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-simple
</artifactId>
<version>
1.7.25
</version>
<scope>
compile
</scope>
</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>
<!-- mysql -->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.47
</version>
</dependency>
<!-- tdengine -->
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.8
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java
已删除
100644 → 0
浏览文件 @
3e588cff
package
com.taosdata.example.calcite
;
import
org.apache.calcite.adapter.jdbc.JdbcSchema
;
import
org.apache.calcite.jdbc.CalciteConnection
;
import
org.apache.calcite.schema.Schema
;
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.Properties
;
public
class
CalciteDemo
{
private
static
String
url_taos
=
"jdbc:TAOS://192.168.236.135:6030/test"
;
private
static
String
url_mysql
=
"jdbc:mysql://master:3306/test?useSSL=false&useUnicode=true&characterEncoding=UTF-8"
;
public
static
void
main
(
String
[]
args
)
throws
SqlParseException
,
ClassNotFoundException
,
SQLException
{
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
();
//这里hdb是在tdengine中创建的数据库名
Schema
schema
=
mysqlTest
(
rootSchema
);
// Schema schema = tdengineTest(rootSchema);
//创建新的schema自动映射到原来的hdb数据库
rootSchema
.
add
(
"test"
,
schema
);
Statement
stmt
=
calciteConnection
.
createStatement
();
//查询schema test中的表,表名是tdengine中的表
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from test.t"
);
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
metaData
.
getColumnCount
();
i
++)
{
System
.
out
.
println
(
metaData
.
getColumnLabel
(
i
)
+
" : "
+
rs
.
getString
(
i
));
}
}
}
private
static
Schema
tdengineTest
(
SchemaPlus
rootSchema
)
throws
ClassNotFoundException
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
BasicDataSource
dataSource
=
new
BasicDataSource
();
dataSource
.
setUrl
(
url_taos
);
dataSource
.
setUsername
(
"root"
);
dataSource
.
setPassword
(
"taosdata"
);
return
JdbcSchema
.
create
(
rootSchema
,
"test"
,
dataSource
,
"hdb"
,
null
);
}
private
static
Schema
mysqlTest
(
SchemaPlus
rootSchema
)
throws
ClassNotFoundException
{
Class
.
forName
(
"com.mysql.jdbc.Driver"
);
BasicDataSource
dataSource
=
new
BasicDataSource
();
dataSource
.
setUrl
(
url_mysql
);
dataSource
.
setUsername
(
"root"
);
dataSource
.
setPassword
(
"123456"
);
//Schema schema = JdbcSchema.create(rootSchema, "test", dataSource, "hdb", null);
return
JdbcSchema
.
create
(
rootSchema
,
"test"
,
dataSource
,
"test"
,
null
);
}
}
tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties
已删除
100644 → 0
浏览文件 @
3e588cff
log4j.rootLogger
=
info,stdout
#console
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
[%d{yyyy-MM-dd HH:mm:ss a}]:%p %l%m%n
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录