25
2021
11

JDBC 连接 Hive 库遇到的一些问题

最近在配置Hive 数据源的时候,遇到一些报错,总算解决了,记录一下备忘

下面这个报错,是把Hive依赖版本升级到 3.1.2 时的报错,没有找到API 来设置  client_protocol 

 Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default})
        at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:256)
        at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)


如果还是用之前 1.0.0 的版本,由于新的数据源是采用 Zookeeper 方式连接,则又会报错。

Could not open client transport for any of the Server URI's in ZooKeeper: Unable to read HiveServer2 uri from ZooKeeper

最终将 Hive 的版本升级为 2.0.0 ,问题解决。

                 <dependency>
		      <groupId>org.apache.hive</groupId>
		      <artifactId>hive-jdbc</artifactId>
		      <version>2.0.0</version>
		      <exclusions>
		      	<exclusion>
					<groupId>javax.servlet.jsp</groupId>
					<artifactId>jsp-api</artifactId>
				</exclusion>
		      	<exclusion>
					<groupId>javax.servlet</groupId>
					<artifactId>servlet-api</artifactId>
			  	</exclusion>
			  	<exclusion>
					<groupId>tomcat</groupId>
					<artifactId>jasper-runtime</artifactId>
				 </exclusion>
		      	<exclusion>
		      		<groupId>tomcat</groupId>
		      		<artifactId>jasper-compiler</artifactId>
		      	</exclusion>
			  </exclusions>
		  </dependency>
		  
		  <dependency>
			<groupId>org.apache.curator</groupId>
			<artifactId>curator-client</artifactId>
			<version>3.3.0</version>
			<exclusions>
		      	<exclusion>
					<groupId>javax.servlet.jsp</groupId>
					<artifactId>jsp-api</artifactId>
				</exclusion>
		      	<exclusion>
					<groupId>javax.servlet</groupId>
					<artifactId>servlet-api</artifactId>
			  	</exclusion>
			  	<exclusion>
					<groupId>tomcat</groupId>
					<artifactId>jasper-runtime</artifactId>
				 </exclusion>
		      	<exclusion>
		      		<groupId>tomcat</groupId>
		      		<artifactId>jasper-compiler</artifactId>
		      	</exclusion>
			</exclusions>
		</dependency>
		
		
		<dependency>
			<groupId>com.fasterxml.woodstox</groupId>
			<artifactId>woodstox-core</artifactId>
			<version>5.3.0</version>
			<exclusions>
		      	<exclusion>
					<groupId>javax.servlet.jsp</groupId>
					<artifactId>jsp-api</artifactId>
				</exclusion>
		      	<exclusion>
					<groupId>javax.servlet</groupId>
					<artifactId>servlet-api</artifactId>
			  	</exclusion>
			  	<exclusion>
					<groupId>tomcat</groupId>
					<artifactId>jasper-runtime</artifactId>
				 </exclusion>
		      	<exclusion>
		      		<groupId>tomcat</groupId>
		      		<artifactId>jasper-compiler</artifactId>
		      	</exclusion>
			</exclusions>
		</dependency>



« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。