Skip to content

Use JDBC support with ThriftServer

shiyuhang0 edited this page Sep 20, 2022 · 2 revisions

You can use Spark Shell or Spark SQL without JDBC support. However, JDBC support is required for tools like beeline. JDBC support is provided by Thrift server. To use Spark's Thrift server, run:

{{< copyable "shell-regular" >}}

./sbin/start-thriftserver.sh

To connect JDBC with Thrift server, you can use JDBC supported tools including beeline.

For example, to use it with beeline:

{{< copyable "shell-regular" >}}

./bin/beeline jdbc:hive2://localhost:10000

If the following message is displayed, you have enabled beeline successfully.

Beeline version 1.2.2 by Apache Hive

Then, you can run the query command:

1: jdbc:hive2://localhost:10000> use testdb;
+---------+--+
| Result  |
+---------+--+
+---------+--+
No rows selected (0.013 seconds)

select count(*) from account;
+-----------+--+
| count(1)  |
+-----------+--+
| 1000000   |
+-----------+--+
1 row selected (1.97 seconds)
Clone this wiki locally