2013-03-15 92 views

回答

1

可能是配置文件中不正確的bean聲明。

您可以按照以下提到的步驟:

  1. 創建蜂巢-config.xml中

    <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.xsd 
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> 
    
    <context:property-placeholder location="hive.properties"/> 
    <bean id="hive-driver" class="org.apache.hadoop.hive.jdbc.HiveDriver"/> 
    <bean id="hive-ds" class="org.springframework.jdbc.datasource.SimpleDriverDataSource" 
    c:driver-ref="hive-driver" c:url="${hive.url}"/> 
    </beans> 
    
  2. 創建hive.properties

    hive.url=jdbc:hive://localhost:10000/default 
    
  3. 增加了Spring的JDBC JAR

  4. 在java代碼中獲取連接。

    ApplicationContext ac = new FileSystemXmlApplicationContext("hive-config.xml"); 
    DataSource dataSource = (DataSource) ac.getBean("hive-ds"); 
    Connection con =dataSource.getConnection(); 
    

,並開始射擊您的查詢hiveServer

相關問題