Geo j
Geo j

Reputation: 191

Getting socket connection error while trying to connect to hive from eclipse spring xml file

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hiveServer': Invocation of init method failed; nested exception is org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:10000.

Upvotes: 1

Views: 713

Answers (1)

deepakmodak
deepakmodak

Reputation: 1339

May be improper bean declaration in config file.

You can follow below mentioned steps :

  1. create hive-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. create hive.properties

    hive.url=jdbc:hive://localhost:10000/default
    
  3. add spring-jdbc jar

  4. get connection in java code.

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

and start firing your queries to hiveServer

Upvotes: 1

Related Questions