Hive jdbc 驱动程序以非描述性消息响应
Hive jdbc driver respond with non descriptive message
我准备了 java 使用 hive jdbc 客户端调用 Hadoop DB 的应用程序。
当我尝试执行像 'select * from students' 这样的简单查询时,它工作正常。
但是一旦我添加了一些条件语句(例如, age > 10 ),它就会开始响应以下异常:
Caused by: java.sql.SQLException: Query returned non-zero code: 2, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:194)
at org.springframework.jdbc.core.JdbcTemplateQueryStatementCallback.doInStatement(JdbcTemplate.java:441)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)
... 29 more
唯一可能的原因是我在 google 中发现它缺少库。但对我来说,我需要额外的库来进行更复杂的查询,这看起来很奇怪。
以防万一这里是 build.gradle
的依赖项列表
compile "org.springframework:spring-core:"+spring_version
compile "org.springframework:spring-beans:"+spring_version
compile "org.springframework:spring-context:"+spring_version
compile "org.springframework:spring-jdbc:"+spring_version
compile "commons-io:commons-io:2.1"
compile 'org.apache.hadoop:hadoop-core:1.0.0'
compile 'org.apache.hive:hive-jdbc:0.13.0'
compile 'org.apache.hive:hive-exec:0.13.0'
compile 'org.apache.hive:hive-service:0.13.0'
compile 'org.apache.hive:hive-metastore:0.13.0'
compile 'org.apache.thrift:libfb303:0.9.2'
compile 'org.apache.thrift:libthrift:0.9.2'
compile 'log4j:log4j:1.2.15'
compile 'org.antlr:antlr-runtime:3.5'
compile 'org.apache.derby:derby:10.10.1.1'
compile 'javax.jdo:jdo2-api:2.3-eb'
compile 'jpox:jpox:1.1.9'
compile 'jpox:jpox:1.1.9'
和 spring 配置 jdbc 模板
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:spring/application.properties</value>
</property>
</bean>
<context:component-scan base-package="com.sample" />
<!-- basic Hive driver bean -->
<bean id="hive-driver" class="org.apache.hadoop.hive.jdbc.HiveDriver" />
<bean id="hiveSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource"
c:driver-ref="hive-driver" c:url="${hadoop.jdbc.driver.path}"
c:username="${hadoop.login}" c:password="${hadoop.password}" />
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
c:data-source-ref="hiveSource" />
<bean id="hiveDao" class="com.sample.dao.HiveDao">
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
<bean id="hiveClient" class=" com.sample.client.HiveClient">
<property name="hiveDao" ref="hiveDao" />
</bean>
</beans>
请提供建议或分享工作示例。
此致,
亚历克斯
使用,
<bean id="hive-driver" class="org.apache.hive.jdbc.HiveDriver"
/> 而不是 <bean id="hive-driver" class="org.apache.hadoop.hive.jdbc.HiveDriver" />
我准备了 java 使用 hive jdbc 客户端调用 Hadoop DB 的应用程序。 当我尝试执行像 'select * from students' 这样的简单查询时,它工作正常。 但是一旦我添加了一些条件语句(例如, age > 10 ),它就会开始响应以下异常:
Caused by: java.sql.SQLException: Query returned non-zero code: 2, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:194)
at org.springframework.jdbc.core.JdbcTemplateQueryStatementCallback.doInStatement(JdbcTemplate.java:441)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)
... 29 more
唯一可能的原因是我在 google 中发现它缺少库。但对我来说,我需要额外的库来进行更复杂的查询,这看起来很奇怪。
以防万一这里是 build.gradle
的依赖项列表compile "org.springframework:spring-core:"+spring_version
compile "org.springframework:spring-beans:"+spring_version
compile "org.springframework:spring-context:"+spring_version
compile "org.springframework:spring-jdbc:"+spring_version
compile "commons-io:commons-io:2.1"
compile 'org.apache.hadoop:hadoop-core:1.0.0'
compile 'org.apache.hive:hive-jdbc:0.13.0'
compile 'org.apache.hive:hive-exec:0.13.0'
compile 'org.apache.hive:hive-service:0.13.0'
compile 'org.apache.hive:hive-metastore:0.13.0'
compile 'org.apache.thrift:libfb303:0.9.2'
compile 'org.apache.thrift:libthrift:0.9.2'
compile 'log4j:log4j:1.2.15'
compile 'org.antlr:antlr-runtime:3.5'
compile 'org.apache.derby:derby:10.10.1.1'
compile 'javax.jdo:jdo2-api:2.3-eb'
compile 'jpox:jpox:1.1.9'
compile 'jpox:jpox:1.1.9'
和 spring 配置 jdbc 模板
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:spring/application.properties</value>
</property>
</bean>
<context:component-scan base-package="com.sample" />
<!-- basic Hive driver bean -->
<bean id="hive-driver" class="org.apache.hadoop.hive.jdbc.HiveDriver" />
<bean id="hiveSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource"
c:driver-ref="hive-driver" c:url="${hadoop.jdbc.driver.path}"
c:username="${hadoop.login}" c:password="${hadoop.password}" />
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
c:data-source-ref="hiveSource" />
<bean id="hiveDao" class="com.sample.dao.HiveDao">
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
<bean id="hiveClient" class=" com.sample.client.HiveClient">
<property name="hiveDao" ref="hiveDao" />
</bean>
</beans>
请提供建议或分享工作示例。
此致, 亚历克斯
使用,
<bean id="hive-driver" class="org.apache.hive.jdbc.HiveDriver"
/> 而不是 <bean id="hive-driver" class="org.apache.hadoop.hive.jdbc.HiveDriver" />