libenchao commented on code in PR #22758:
URL: https://github.com/apache/flink/pull/22758#discussion_r1229139692
##########
docs/content/docs/dev/table/overview.md:
##########
@@ -60,5 +60,6 @@ Where to go next?
* [Built-in Functions]({{< ref "docs/dev/table/functions/systemFunctions"
>}}): Supported functions in Table API and SQL.
* [SQL Client]({{< ref "docs/dev/table/sqlClient" >}}): Play around with Flink
SQL and submit a table program to a cluster without programming knowledge.
* [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}}): A service
that enables the multiple clients to execute SQL from the remote in concurrency.
+* [SQL Jdbc Driver]({{< ref "docs/dev/table/jdbcDriver" >}}): A JDBC Driver
that submits SQL statements to sql-gateway.
Review Comment:
```suggestion
* [SQL JDBC Driver]({{< ref "docs/dev/table/jdbcDriver" >}}): A JDBC Driver
that submits SQL statements to sql-gateway.
```
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
Review Comment:
There are various tools which can extend with jdbc drivers, such as Tableau,
below are only some demos for this, not the only usages of flink jdbc driver.
How about add a summary here to talk about this?
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
+### Use with Beeline
+
+Beeline is the command line tool for accessing [Apache
Hive](https://hive.apache.org/), but it also supports general JDBC drivers. To
install Hive and beeline, see [Hive
documentation](https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHiveServer2andBeeline.1).
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to
`$HIVE_HOME/lib`.
+2. Run beeline and connect to a Flink SQL gateway. As Flink SQL gateway
currently ignores user names and passwords, just leave them empty.
+ ```
+ beeline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+Beeline version 3.1.3 by Apache Hive
+beeline> !connect jdbc:flink://localhost:8083
+Connecting to jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+Connected to: Flink JDBC Driver (version 1.18-SNAPSHOT)
+Driver: org.apache.flink.table.jdbc.FlinkDriver (version 1.18-SNAPSHOT)
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . . > a INT,
+. . . . . . . . . . . . . . . > b VARCHAR(10)
+. . . . . . . . . . . . . . . > ) WITH (
+. . . . . . . . . . . . . . . > 'connector' = 'filesystem',
+. . . . . . . . . . . . . . . > 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . . > 'format' = 'csv'
+. . . . . . . . . . . . . . . > );
+No rows affected (0.108 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++-----------------------------------+
+| job id |
++-----------------------------------+
+| da22010cf1c962b377493fc4fc509527 |
++-----------------------------------+
+1 row selected (0.952 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++----+--------+
+| a | b |
++----+--------+
+| 1 | Hi |
+| 2 | Hello |
++----+--------+
+2 rows selected (1.142 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+### Use with SqlLine
+
+[SqlLine] (https://github.com/julianhyde/sqlline) is a lightweight JDBC
command line tool, it supports general JDBC drivers. You need to clone the
codes from github and compile the project with mvn first.
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to `target`
directory of SqlLine project. Notice that you need to copy
slf4j-api-{slf4j.version}.jar to `target` which will be used by flink JDBC
driver.
+2. Run SqlLine with command `bin/sqlline` and connect to a Flink SQL gateway.
As Flink SQL gateway currently ignores user names and passwords, just leave
them empty.
+ ```
+ sqlline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+sqlline version 1.12.0
+sqlline> !connect jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . .)> a INT,
+. . . . . . . . . . . . . . .)> b VARCHAR(10)
+. . . . . . . . . . . . . . .)> ) WITH (
+. . . . . . . . . . . . . . .)> 'connector' = 'filesystem',
+. . . . . . . . . . . . . . .)> 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . .)> 'format' = 'csv'
+. . . . . . . . . . . . . . .)> );
+No rows affected (0.122 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++----------------------------------+
+| job id |
++----------------------------------+
+| fbade1ab4450fc57ebd5269fdf60dcfd |
++----------------------------------+
+1 row selected (1.282 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++---+-------+
+| a | b |
++---+-------+
+| 1 | Hi |
+| 2 | Hello |
+| 1 | Hi |
+| 2 | Hello |
Review Comment:
The result is not correct. I guess you run the `insert` twice, and the data
is duplicated.
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
+### Use with Beeline
+
+Beeline is the command line tool for accessing [Apache
Hive](https://hive.apache.org/), but it also supports general JDBC drivers. To
install Hive and beeline, see [Hive
documentation](https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHiveServer2andBeeline.1).
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to
`$HIVE_HOME/lib`.
+2. Run beeline and connect to a Flink SQL gateway. As Flink SQL gateway
currently ignores user names and passwords, just leave them empty.
+ ```
+ beeline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+Beeline version 3.1.3 by Apache Hive
+beeline> !connect jdbc:flink://localhost:8083
+Connecting to jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+Connected to: Flink JDBC Driver (version 1.18-SNAPSHOT)
+Driver: org.apache.flink.table.jdbc.FlinkDriver (version 1.18-SNAPSHOT)
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . . > a INT,
+. . . . . . . . . . . . . . . > b VARCHAR(10)
+. . . . . . . . . . . . . . . > ) WITH (
+. . . . . . . . . . . . . . . > 'connector' = 'filesystem',
+. . . . . . . . . . . . . . . > 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . . > 'format' = 'csv'
+. . . . . . . . . . . . . . . > );
+No rows affected (0.108 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++-----------------------------------+
+| job id |
++-----------------------------------+
+| da22010cf1c962b377493fc4fc509527 |
++-----------------------------------+
+1 row selected (0.952 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++----+--------+
+| a | b |
++----+--------+
+| 1 | Hi |
+| 2 | Hello |
++----+--------+
+2 rows selected (1.142 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+### Use with SqlLine
+
+[SqlLine] (https://github.com/julianhyde/sqlline) is a lightweight JDBC
command line tool, it supports general JDBC drivers. You need to clone the
codes from github and compile the project with mvn first.
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to `target`
directory of SqlLine project. Notice that you need to copy
slf4j-api-{slf4j.version}.jar to `target` which will be used by flink JDBC
driver.
+2. Run SqlLine with command `bin/sqlline` and connect to a Flink SQL gateway.
As Flink SQL gateway currently ignores user names and passwords, just leave
them empty.
+ ```
+ sqlline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+sqlline version 1.12.0
+sqlline> !connect jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . .)> a INT,
+. . . . . . . . . . . . . . .)> b VARCHAR(10)
+. . . . . . . . . . . . . . .)> ) WITH (
+. . . . . . . . . . . . . . .)> 'connector' = 'filesystem',
+. . . . . . . . . . . . . . .)> 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . .)> 'format' = 'csv'
+. . . . . . . . . . . . . . .)> );
+No rows affected (0.122 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++----------------------------------+
+| job id |
++----------------------------------+
+| fbade1ab4450fc57ebd5269fdf60dcfd |
++----------------------------------+
+1 row selected (1.282 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++---+-------+
+| a | b |
++---+-------+
+| 1 | Hi |
+| 2 | Hello |
+| 1 | Hi |
+| 2 | Hello |
++---+-------+
+4 rows selected (1.955 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+## Use with Java
Review Comment:
Actually jdbc driver could be used by any JVM language
(java/scala/kotlin...), and by any dependency management systems
(maven/gradle), and in most cases, users may use this with some data acess
frameworks such as JOOQ, MyBatis, Spring Data. Similar to my above comment
about the section "Use with a JDBC Tool", how about mention something as a
summary?
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
+### Use with Beeline
+
+Beeline is the command line tool for accessing [Apache
Hive](https://hive.apache.org/), but it also supports general JDBC drivers. To
install Hive and beeline, see [Hive
documentation](https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHiveServer2andBeeline.1).
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to
`$HIVE_HOME/lib`.
+2. Run beeline and connect to a Flink SQL gateway. As Flink SQL gateway
currently ignores user names and passwords, just leave them empty.
+ ```
+ beeline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+Beeline version 3.1.3 by Apache Hive
+beeline> !connect jdbc:flink://localhost:8083
+Connecting to jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+Connected to: Flink JDBC Driver (version 1.18-SNAPSHOT)
+Driver: org.apache.flink.table.jdbc.FlinkDriver (version 1.18-SNAPSHOT)
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . . > a INT,
+. . . . . . . . . . . . . . . > b VARCHAR(10)
+. . . . . . . . . . . . . . . > ) WITH (
+. . . . . . . . . . . . . . . > 'connector' = 'filesystem',
+. . . . . . . . . . . . . . . > 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . . > 'format' = 'csv'
+. . . . . . . . . . . . . . . > );
+No rows affected (0.108 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++-----------------------------------+
+| job id |
++-----------------------------------+
+| da22010cf1c962b377493fc4fc509527 |
++-----------------------------------+
+1 row selected (0.952 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++----+--------+
+| a | b |
++----+--------+
+| 1 | Hi |
+| 2 | Hello |
++----+--------+
+2 rows selected (1.142 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+### Use with SqlLine
+
+[SqlLine] (https://github.com/julianhyde/sqlline) is a lightweight JDBC
command line tool, it supports general JDBC drivers. You need to clone the
codes from github and compile the project with mvn first.
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to `target`
directory of SqlLine project. Notice that you need to copy
slf4j-api-{slf4j.version}.jar to `target` which will be used by flink JDBC
driver.
+2. Run SqlLine with command `bin/sqlline` and connect to a Flink SQL gateway.
As Flink SQL gateway currently ignores user names and passwords, just leave
them empty.
+ ```
+ sqlline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+sqlline version 1.12.0
+sqlline> !connect jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . .)> a INT,
+. . . . . . . . . . . . . . .)> b VARCHAR(10)
+. . . . . . . . . . . . . . .)> ) WITH (
+. . . . . . . . . . . . . . .)> 'connector' = 'filesystem',
+. . . . . . . . . . . . . . .)> 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . .)> 'format' = 'csv'
+. . . . . . . . . . . . . . .)> );
+No rows affected (0.122 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++----------------------------------+
+| job id |
++----------------------------------+
+| fbade1ab4450fc57ebd5269fdf60dcfd |
++----------------------------------+
+1 row selected (1.282 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++---+-------+
+| a | b |
++---+-------+
+| 1 | Hi |
+| 2 | Hello |
+| 1 | Hi |
+| 2 | Hello |
++---+-------+
+4 rows selected (1.955 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+## Use with Java
+
+Flink JDBC driver is a library for accessing Flink clusters through the JDBC
API. For the general usage of JDBC in Java, see [JDBC
tutorial](https://docs.oracle.com/javase/tutorial/jdbc/index.html).
+
+1. Add the following dependency in pom.xml of project or download
flink-jdbc-driver-bundle-{VERSION}.jar and add it to your classpath.
+```
+ <dependency>
+ <groupId>org.apache.flink</groupId>
+ <artifactId>flink-sql-jdbc-driver-bundle</artifactId>
+ <version>{VERSION}</version>
+ </dependency>
+```
+2. Connect to a Flink SQL gateway in your Java code with specific url.
+3. Execute any statement you want.
+
+**Sample.java**
+```java
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+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()) {
Review Comment:
How about also add a demo for `DataSource` usages since we also supported it.
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
+### Use with Beeline
+
+Beeline is the command line tool for accessing [Apache
Hive](https://hive.apache.org/), but it also supports general JDBC drivers. To
install Hive and beeline, see [Hive
documentation](https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHiveServer2andBeeline.1).
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to
`$HIVE_HOME/lib`.
Review Comment:
How about add a section of downloading/dependencies like other docs such as
connectors/formats?
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
+### Use with Beeline
+
+Beeline is the command line tool for accessing [Apache
Hive](https://hive.apache.org/), but it also supports general JDBC drivers. To
install Hive and beeline, see [Hive
documentation](https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHiveServer2andBeeline.1).
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to
`$HIVE_HOME/lib`.
+2. Run beeline and connect to a Flink SQL gateway. As Flink SQL gateway
currently ignores user names and passwords, just leave them empty.
+ ```
+ beeline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+Beeline version 3.1.3 by Apache Hive
+beeline> !connect jdbc:flink://localhost:8083
+Connecting to jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+Connected to: Flink JDBC Driver (version 1.18-SNAPSHOT)
+Driver: org.apache.flink.table.jdbc.FlinkDriver (version 1.18-SNAPSHOT)
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . . > a INT,
+. . . . . . . . . . . . . . . > b VARCHAR(10)
+. . . . . . . . . . . . . . . > ) WITH (
+. . . . . . . . . . . . . . . > 'connector' = 'filesystem',
+. . . . . . . . . . . . . . . > 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . . > 'format' = 'csv'
+. . . . . . . . . . . . . . . > );
+No rows affected (0.108 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++-----------------------------------+
+| job id |
++-----------------------------------+
+| da22010cf1c962b377493fc4fc509527 |
++-----------------------------------+
+1 row selected (0.952 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++----+--------+
+| a | b |
++----+--------+
+| 1 | Hi |
+| 2 | Hello |
++----+--------+
+2 rows selected (1.142 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+### Use with SqlLine
+
+[SqlLine] (https://github.com/julianhyde/sqlline) is a lightweight JDBC
command line tool, it supports general JDBC drivers. You need to clone the
codes from github and compile the project with mvn first.
Review Comment:
```suggestion
[SqlLine](https://github.com/julianhyde/sqlline) is a lightweight JDBC
command line tool, it supports general JDBC drivers. You need to clone the
codes from github and compile the project with mvn first.
```
##########
docs/content/docs/dev/table/jdbcDriver.md:
##########
@@ -0,0 +1,179 @@
+---
+title: "SQL JDBC Driver"
+weight: 91
+type: docs
+aliases:
+- /dev/table/jdbcDriver.html
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Flink JDBC Driver
+
+Flink JDBC Driver is a Java library for connecting and submitting SQL
statements to [SQL Gateway]({{< ref "docs/dev/table/sql-gateway/overview" >}})
as the JDBC server.
+
+# Usage
+
+Before using Flink JDBC driver, you need to start a SQL Gateway as the JDBC
server and binds it with your Flink cluster. We now assume that you have a
gateway started and connected to a running Flink cluster.
+
+## Use with a JDBC Tool
+### Use with Beeline
+
+Beeline is the command line tool for accessing [Apache
Hive](https://hive.apache.org/), but it also supports general JDBC drivers. To
install Hive and beeline, see [Hive
documentation](https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-RunningHiveServer2andBeeline.1).
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to
`$HIVE_HOME/lib`.
+2. Run beeline and connect to a Flink SQL gateway. As Flink SQL gateway
currently ignores user names and passwords, just leave them empty.
+ ```
+ beeline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+Beeline version 3.1.3 by Apache Hive
+beeline> !connect jdbc:flink://localhost:8083
+Connecting to jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+Connected to: Flink JDBC Driver (version 1.18-SNAPSHOT)
+Driver: org.apache.flink.table.jdbc.FlinkDriver (version 1.18-SNAPSHOT)
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . . > a INT,
+. . . . . . . . . . . . . . . > b VARCHAR(10)
+. . . . . . . . . . . . . . . > ) WITH (
+. . . . . . . . . . . . . . . > 'connector' = 'filesystem',
+. . . . . . . . . . . . . . . > 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . . > 'format' = 'csv'
+. . . . . . . . . . . . . . . > );
+No rows affected (0.108 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++-----------------------------------+
+| job id |
++-----------------------------------+
+| da22010cf1c962b377493fc4fc509527 |
++-----------------------------------+
+1 row selected (0.952 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++----+--------+
+| a | b |
++----+--------+
+| 1 | Hi |
+| 2 | Hello |
++----+--------+
+2 rows selected (1.142 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+### Use with SqlLine
+
+[SqlLine] (https://github.com/julianhyde/sqlline) is a lightweight JDBC
command line tool, it supports general JDBC drivers. You need to clone the
codes from github and compile the project with mvn first.
+
+1. Download flink-jdbc-driver-bundle-{VERSION}.jar and add it to `target`
directory of SqlLine project. Notice that you need to copy
slf4j-api-{slf4j.version}.jar to `target` which will be used by flink JDBC
driver.
+2. Run SqlLine with command `bin/sqlline` and connect to a Flink SQL gateway.
As Flink SQL gateway currently ignores user names and passwords, just leave
them empty.
+ ```
+ sqlline> !connect jdbc:flink://localhost:8083
+ ```
+3. Execute any statement you want.
+
+**Sample Commands**
+```
+sqlline version 1.12.0
+sqlline> !connect jdbc:flink://localhost:8083
+Enter username for jdbc:flink://localhost:8083:
+Enter password for jdbc:flink://localhost:8083:
+0: jdbc:flink://localhost:8083> CREATE TABLE T(
+. . . . . . . . . . . . . . .)> a INT,
+. . . . . . . . . . . . . . .)> b VARCHAR(10)
+. . . . . . . . . . . . . . .)> ) WITH (
+. . . . . . . . . . . . . . .)> 'connector' = 'filesystem',
+. . . . . . . . . . . . . . .)> 'path' = 'file:///tmp/T.csv',
+. . . . . . . . . . . . . . .)> 'format' = 'csv'
+. . . . . . . . . . . . . . .)> );
+No rows affected (0.122 seconds)
+0: jdbc:flink://localhost:8083> INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello');
++----------------------------------+
+| job id |
++----------------------------------+
+| fbade1ab4450fc57ebd5269fdf60dcfd |
++----------------------------------+
+1 row selected (1.282 seconds)
+0: jdbc:flink://localhost:8083> SELECT * FROM T;
++---+-------+
+| a | b |
++---+-------+
+| 1 | Hi |
+| 2 | Hello |
+| 1 | Hi |
+| 2 | Hello |
++---+-------+
+4 rows selected (1.955 seconds)
+0: jdbc:flink://localhost:8083>
+```
+
+## Use with Java
+
+Flink JDBC driver is a library for accessing Flink clusters through the JDBC
API. For the general usage of JDBC in Java, see [JDBC
tutorial](https://docs.oracle.com/javase/tutorial/jdbc/index.html).
+
+1. Add the following dependency in pom.xml of project or download
flink-jdbc-driver-bundle-{VERSION}.jar and add it to your classpath.
+```
+ <dependency>
+ <groupId>org.apache.flink</groupId>
+ <artifactId>flink-sql-jdbc-driver-bundle</artifactId>
+ <version>{VERSION}</version>
+ </dependency>
+```
+2. Connect to a Flink SQL gateway in your Java code with specific url.
+3. Execute any statement you want.
+
+**Sample.java**
+```java
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+public class Sample {
+ public static void main(String[] args) throws Exception {
+ try (Connection connection =
DriverManager.getConnection("jdbc:flink://localhost:8083")) {
Review Comment:
Need to `Class.forName(...)` at first?
##########
flink-table/flink-sql-jdbc-driver/src/main/java/org/apache/flink/table/jdbc/BaseConnection.java:
##########
@@ -102,12 +101,6 @@ public int getTransactionIsolation() throws SQLException {
"FlinkConnection#getTransactionIsolation is not supported
yet.");
}
- @Override
- public SQLWarning getWarnings() throws SQLException {
Review Comment:
If these changes are not relevant with this issue, I'd suggest to move these
to another commit (if they are trivial, we can just add a hotfix commit; if
they are major changes, we should create a Jira and link to it)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]