首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >覆盖sprint hive jdbc中的hive属性

覆盖sprint hive jdbc中的hive属性
EN

Stack Overflow用户
提问于 2018-02-25 15:05:57
回答 1查看 640关注 0票数 0

我想要覆盖我的一些蜂巢属性值,我正在使用spring上下文连接到蜂箱。基本上,我想执行语句SET hive.auto.convert.join=false; template.execute(splitQuery);,但这不起作用。

代码语言:javascript
复制
                                       I have also tried by setting this var into jdbc url like this. `jdbc:hive2://host:port/default;hive.auto.convert.join=false` but this also did not work.

我的sprint context.xml是

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?><beans:beans xmlns="http://www.springframework.org/schema/hadoop" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
  http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">

<context:property-placeholder location="hadoop.properties,hive.properties" />

<configuration>
    fs.defaultFS=${hd.fs}
    yarn.resourcemanager.address=${hd.rm}
    mapreduce.framework.name=yarn
    mapreduce.jobhistory.address=${hd.jh}
</configuration>

<!-- This sample requires a running HiveServer2 -->
<hive-client-factory id="hiveClientFactory" hive-data-source-ref="hiveDataSource" />

<beans:bean id="hiveDriver" class="org.apache.hive.jdbc.HiveDriver" />

<beans:bean id="hiveDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <beans:constructor-arg name="driver" ref="hiveDriver" />
    <beans:constructor-arg name="url" value="${hive.url}" />
    <beans:constructor-arg name="username" value="${hive.user}" />
    <beans:constructor-arg name="password" value="${hive.password}" />
</beans:bean>

<beans:bean id="template" class="org.springframework.jdbc.core.JdbcTemplate" c:data-source-ref="hiveDataSource"/>

<!-- hive-template id="hiveTemplate"/ -->

有人能提出其他的建议吗?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-26 14:21:37

您应该能够将附加属性作为

https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDriverBasedDataSource.java

它将在driver.connect方法期间注入属性。所以你应该能够做一些类似的事情(没有测试)。

代码语言:javascript
复制
<bean id="myproperties"
      class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="properties">
    <value>
        hive.auto.convert.join=false
    </value>
  </property>
</bean>

<beans:bean id="hiveDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <beans:constructor-arg name="driver" ref="hiveDriver" />
    <beans:constructor-arg name="url" value="${hive.url}" />
    <beans:constructor-arg name="username" value="${hive.user}" />
    <beans:constructor-arg name="password" value="${hive.password}" />
    <property name="connectionProperties" ref="myproperties">
</property>
</beans:bean>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48974940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档