Skip to content

Commit 53074ec

Browse files
committed
[KYUUBI #7238] [DOC] Replace 'Getting Started with Hive JDBC' markdown with rst
### Why are the changes needed? This change fixes version value of JDBC driver by using `release` variable instead of hardcoded `1.7.0` value. ### How was this patch tested? Check the doc page looks the same except JDBC driver version value. <img width="1289" height="891" alt="Screenshot 2025-11-02 at 18 53 27" src="https://github.com/user-attachments/assets/e16561db-a873-4808-b8ce-24e06ff439e8" /> ### Was this patch authored or co-authored using generative AI tooling? No Closes #7238 from dnskr/Replace-'Getting-Started-with-Hive-JDBC'-markdown-with-rst. Closes #7238 1e19251 [dnskr] [DOC] Replace 'Getting Started with Hive JDBC' markdown with rst Authored-by: dnskr <[email protected]> Signed-off-by: dnskr <[email protected]>
1 parent ba248b1 commit 53074ec

File tree

2 files changed

+97
-94
lines changed

2 files changed

+97
-94
lines changed

docs/quick_start/quick_start_with_jdbc.md

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one or more
2+
contributor license agreements. See the NOTICE file distributed with
3+
this work for additional information regarding copyright ownership.
4+
The ASF licenses this file to You under the Apache License, Version 2.0
5+
(the "License"); you may not use this file except in compliance with
6+
the License. You may obtain a copy of the License at
7+
8+
.. http://www.apache.org/licenses/LICENSE-2.0
9+
10+
.. Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
17+
Getting Started with Hive JDBC
18+
==============================
19+
20+
How to get the Kyuubi JDBC driver
21+
---------------------------------
22+
23+
Kyuubi Thrift API is fully compatible with HiveServer2, so technically, it allows to use any Hive JDBC driver to connect
24+
Kyuubi Server. But it's recommended to use :doc:`../client/jdbc/kyuubi_jdbc`, which is forked from
25+
Hive 3.1.x JDBC driver, aims to support some missing functionalities of the original Hive JDBC driver.
26+
27+
The driver is available from Maven Central:
28+
29+
.. parsed-literal::
30+
31+
<dependency>
32+
<groupId>org.apache.kyuubi</groupId>
33+
<artifactId>kyuubi-hive-jdbc-shaded</artifactId>
34+
<version>\ |release|\</version>
35+
</dependency>
36+
37+
38+
Connect to non-kerberized Kyuubi Server
39+
---------------------------------------
40+
41+
The following java code connects directly to the Kyuubi Server by JDBC without using kerberos authentication.
42+
43+
.. code-block:: java
44+
45+
package org.apache.kyuubi.examples;
46+
47+
import java.sql.*;
48+
49+
public class KyuubiJDBC {
50+
51+
private static String driverName = "org.apache.kyuubi.jdbc.KyuubiHiveDriver";
52+
private static String kyuubiJdbcUrl = "jdbc:kyuubi://localhost:10009/default;";
53+
54+
public static void main(String[] args) throws SQLException {
55+
try (
56+
Connection conn = DriverManager.getConnection(kyuubiJdbcUrl);
57+
Statement stmt = conn.createStatement();
58+
ResultSet rs = stmt.executeQuery("show databases")) {
59+
while (rs.next()) {
60+
System.out.println(rs.getString(1));
61+
}
62+
}
63+
}
64+
}
65+
66+
Connect to Kerberized Kyuubi Server
67+
-----------------------------------
68+
69+
The following Java code uses a keytab file to login and connect to Kyuubi Server by JDBC.
70+
71+
.. code-block:: java
72+
73+
package org.apache.kyuubi.examples;
74+
75+
import java.sql.*;
76+
77+
public class KyuubiJDBCDemo {
78+
79+
private static String driverName = "org.apache.kyuubi.jdbc.KyuubiHiveDriver";
80+
private static String kyuubiJdbcUrlTemplate = "jdbc:kyuubi://localhost:10009/default;" +
81+
"kyuubiClientPrincipal=%s;kyuubiClientKeytab=%s;kyuubiServerPrincipal=%s";
82+
83+
public static void main(String[] args) throws SQLException {
84+
String clientPrincipal = args[0]; // Kerberos principal
85+
String clientKeytab = args[1]; // Keytab file location
86+
String serverPrincipal = args[2]; // Kerberos principal used by Kyuubi Server
87+
String kyuubiJdbcUrl = String.format(kyuubiJdbcUrlTemplate, clientPrincipal, clientKeytab, serverPrincipal);
88+
try (
89+
Connection conn = DriverManager.getConnection(kyuubiJdbcUrl);
90+
Statement stmt = conn.createStatement();
91+
ResultSet rs = stmt.executeQuery("show databases")) {
92+
while (rs.next()) {
93+
System.out.println(rs.getString(1));
94+
}
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)