This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 0b4b5cabc4 [KYUUBI #7160] Use single try-with-resources blocks in docs
example
0b4b5cabc4 is described below
commit 0b4b5cabc468dde2bc92d3ca3c560fd2b77e6dc2
Author: Jan Willem <[email protected]>
AuthorDate: Mon Aug 4 11:26:20 2025 +0800
[KYUUBI #7160] Use single try-with-resources blocks in docs example
Gets rid of the nested try-with-resources blocks. Improves legibility
slightly.
### Why are the changes needed?
Make the example code just a bit nicer.
### How was this patch tested?
It still compiles. I created a simple (maven) project using only these two
java files.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #7160 from jagij/patch-1.
Closes #7160
9d9624841 [Jan Willem] single try-with-resources blocks
Authored-by: Jan Willem <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
docs/quick_start/quick_start_with_jdbc.md | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/docs/quick_start/quick_start_with_jdbc.md
b/docs/quick_start/quick_start_with_jdbc.md
index abd4fbec4b..c0344db223 100644
--- a/docs/quick_start/quick_start_with_jdbc.md
+++ b/docs/quick_start/quick_start_with_jdbc.md
@@ -48,13 +48,12 @@ public class KyuubiJDBC {
private static String kyuubiJdbcUrl =
"jdbc:kyuubi://localhost:10009/default;";
public static void main(String[] args) throws SQLException {
- try (Connection conn = DriverManager.getConnection(kyuubiJdbcUrl)) {
- try (Statement stmt = conn.createStatement()) {
- try (ResultSet rs = stmt.executeQuery("show databases")) {
- while (rs.next()) {
- System.out.println(rs.getString(1));
- }
- }
+ try (
+ Connection conn = DriverManager.getConnection(kyuubiJdbcUrl);
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("show databases")) {
+ while (rs.next()) {
+ System.out.println(rs.getString(1));
}
}
}
@@ -81,13 +80,12 @@ public class KyuubiJDBCDemo {
String clientKeytab = args[1]; // Keytab file location
String serverPrincipal = args[2]; // Kerberos principal used by Kyuubi
Server
String kyuubiJdbcUrl = String.format(kyuubiJdbcUrlTemplate,
clientPrincipal, clientKeytab, serverPrincipal);
- try (Connection conn = DriverManager.getConnection(kyuubiJdbcUrl)) {
- try (Statement stmt = conn.createStatement()) {
- try (ResultSet rs = stmt.executeQuery("show databases")) {
- while (rs.next()) {
- System.out.println(rs.getString(1));
- }
- }
+ try (
+ Connection conn = DriverManager.getConnection(kyuubiJdbcUrl);
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("show databases")) {
+ while (rs.next()) {
+ System.out.println(rs.getString(1));
}
}
}