当前位置:网站首页>Flinksql read / write PgSQL
Flinksql read / write PgSQL
2022-07-07 05:44:00 【zs_ bigdata】
One . Code
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env, EnvironmentSettings.inStreamingMode());
AbstractJdbcCatalog catalog = JdbcCatalogUtils.createCatalog(
"myPgsql",
"staging",
"username",
"password",
"jdbc:postgresql://xxx:port"
);
tableEnv.registerCatalog("myPgsql", catalog);
tableEnv.useCatalog("myPgsql");
tableEnv.useDatabase("staging");
boolean staging = catalog.tableExists(new ObjectPath("staging", "medical.hospital_department"));
System.out.println(staging);
System.out.println(Arrays.toString(tableEnv.listCatalogs()));
System.out.println(Arrays.toString(tableEnv.listDatabases()));
//System.out.println(Arrays.toString(tableEnv.listTables()));
tableEnv.executeSql("select id,name from `medical.hospital_department`").print();
//sql api
tableEnv.executeSql(
"CREATE TABLE hospital_position (\n" +
" id string,\n" +
" department_id string,\n" +
" waypoint_id STRING,\n" +
" zone_id STRING,\n" +
" PRIMARY KEY (id) NOT ENFORCED\n" +
") WITH (\n" +
" 'connector' = 'jdbc',\n" +
" 'url' = 'jdbc:postgresql://xxxxx:port/ database ',\n" +
" 'username' = 'xx', " +
" 'password' = 'xxxx', " +
" 'table-name' = 'schema name . Table name '\n" +
")"
);
2 Step on the pit
If pgsql Used schema,name At this time, the table name needs `` escape , Otherwise, we will not find medical object
// `medical.hospital_department` Must escape
tableEnv.executeSql("select id,name from `medical.hospital_department`").print();
边栏推荐
- ForkJoin最全详解(从原理设计到使用图解)
- Lombok plug-in
- JSP setting header information export to excel
- How digitalization affects workflow automation
- JVM the truth you need to know
- 微信小程序蓝牙连接硬件设备并进行通讯,小程序蓝牙因距离异常断开自动重连,js实现crc校验位
- 数据中心为什么需要一套基础设施可视化管理系统
- Flink SQL 实现读写redis,并动态生成Hset key
- Leakage relay jd1-100
- CVE-2021-3156 漏洞复现笔记
猜你喜欢
拼多多商品详情接口、拼多多商品基本信息、拼多多商品属性接口
Flink SQL 实现读写redis,并动态生成Hset key
基于NCF的多模块协同实例
ssm框架的简单案例
TCC of distributed transaction solutions
Leetcode: maximum number of "balloons"
Introduction to distributed transactions
Reading the paper [sensor enlarged egocentric video captioning with dynamic modal attention]
什么是消息队列?
R语言【逻辑控制】【数学运算】
随机推荐
Paper reading [MM21 pre training for video understanding challenge:video captioning with pre training techniqu]
DOM node object + time node comprehensive case
zabbix_get测试数据库失败
The 2022 China low / no code Market Research and model selection evaluation report was released
Preliminary practice of niuke.com (9)
Educational Codeforces Round 22 B. The Golden Age
【Shell】清理nohup.out文件
[binary tree] binary tree path finding
Unity让摄像机一直跟随在玩家后上方
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
Go 語言的 Context 詳解
bat 批示处理详解
sql查询:将下一行减去上一行,并做相应的计算
Go 语言的 Context 详解
JD commodity details page API interface, JD commodity sales API interface, JD commodity list API interface, JD app details API interface, JD details API interface, JD SKU information interface
English grammar_ Noun possessive
Web architecture design process
Hcip seventh operation
Flink SQL 实现读写redis,并动态生成Hset key
Mapbox Chinese map address