Flink SQL 数据类型

Flink JDBC Driver | Apache Flink https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/jdbcdriver/

 

Sample.java

public class Sample {
	public static void main(String[] args) throws Exception {
		try (Connection connection = DriverManager.getConnection("jdbc:flink://localhost:8083")) {
			try (Statement statement = connection.createStatement()) {
				statement.execute("CREATE TABLE T(\n" +
						"  a INT,\n" +
						"  b VARCHAR(10)\n" +
						") WITH (\n" +
						"  'connector' = 'filesystem',\n" +
						"  'path' = 'file:///tmp/T.csv',\n" +
						"  'format' = 'csv'\n" +
						")");
				statement.execute("INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello')");
				try (ResultSet rs = statement.executeQuery("SELECT * FROM T")) {
					while (rs.next()) {
						System.out.println(rs.getInt(1) + ", " + rs.getString(2));
					}
				}
			}
		}
	}
}

Output

1, Hi
2, Hello

Besides DriverManager, Flink JDBC driver supports DataSource and you can also create connection from it.

 

 

 

Flink SQL 为用户提供了一系列丰富的原始数据类型。

数据类型 | Apache Flink https://nightlies.apache.org/flink/flink-docs-master/zh/docs/dev/table/types/

 

 

 

posted @   papering  阅读(54)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2022-08-30 windows系统启动服务一直不成功,查看windows日志方法
2022-08-30 A Guide to the Go Garbage Collector
2019-08-30 tmp
2018-08-30 Failed to load http://wantTOgo.com/get_sts_token/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fromHere.com' is therefore not allowed access.
2018-08-30 formData.append("username", "Groucho"); input 文件大小
2018-08-30 t
2018-08-30 dom 显示 与否 的对 ecmascript 变量的 监听
点击右上角即可分享
微信分享提示