Hive JDBC 配置session properties

本文介绍了在使用Hive JDBC连接时如何通过Connection URL进行必要的配置,包括指定服务器实例、初始数据库、初始化脚本文件、会话变量、Hive配置变量等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在使用hive jdbc的时候,需要有一些hive session的配置,
比如说:
当前作业使用的是哪条队列
当前作业的map大小,reduce大小,map个数,reduce的个数。
等等
 
解决方案是:在jdbc url上面,进行初始化的配置。
Connection URL Format
The HiveServer2 URL is a string with the following syntax:
jdbc:hive2:// <host1>:<port1>,<host2>:<port2>/dbName;initFile=<file>;sess_var_list?hive_conf_list#hive_var_list
where
  • <host1>:<port1>,<host2>:<port2> is a server instance or a comma separated list of server instances to connect to (if dynamic service discovery is enabled). If empty, the embedded server will be used.
  • dbName is the name of the initial database.
  • <file> is the path of init script file (Hive 2.2.0 and later). This script file is written with SQL statements which will be executed automatically after connection. This option can be empty. 
  • sess_var_list is a semicolon separated list of key=value pairs of session variables (e.g., user=foo;password=bar).
  • hive_conf_list is a semicolon separated list of key=value pairs of Hive configuration variables for this session
  • hive_var_list is a semicolon separated list of key=value pairs of Hive variables for this session.
 
 
2025/08/01 11:02:41 - 执行SQL脚本.0 - ERROR (version 9.4.0.0-343, build 0.0 from 2022-11-08 07.50.27 by buildguy) : 错误初始化步骤[执行SQL脚本] 2025/08/01 11:02:41 - 执行SQL脚本.0 - ERROR (version 9.4.0.0-343, build 0.0 from 2022-11-08 07.50.27 by buildguy) : java.lang.NoSuchMethodError: org.apache.hadoop.hive.common.auth.HiveAuthUtils.getSocketTransport(Ljava/lang/String;III)Lorg/apache/hive/org/apache/thrift/transport/TTransport; 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.apache.hive.jdbc.HiveConnection.createUnderlyingTransport(HiveConnection.java:915) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.apache.hive.jdbc.HiveConnection.createBinaryTransport(HiveConnection.java:951) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:507) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:379) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:284) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:94) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at java.sql.DriverManager.getConnection(DriverManager.java:664) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at java.sql.DriverManager.getConnection(DriverManager.java:208) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:589) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.pentaho.di.core.database.Database.normalConnect(Database.java:481) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.pentaho.di.core.database.Database.connect(Database.java:389) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.pentaho.di.core.database.Database.connect(Database.java:360) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.pentaho.di.trans.steps.sql.ExecSQL.init(ExecSQL.java:297) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at org.pentaho.di.trans.step.StepInitThread.run(StepInitThread.java:69) 2025/08/01 11:02:41 - 执行SQL脚本.0 - at java.lang.Thread.run(Thread.java:748) 2025/08/01 11:02:41 - 转换 1 - ERROR (version 9.4.0.0-343, build 0.0 from 2022-11-08 07.50.27 by buildguy) : 步骤 [执行SQL脚本.0] 初始化失败!
最新发布
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值