Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive JDBC Connection is going down again and again in Spring Boot rest API and starts working properly with API restart.

Hive JDBC Connection is going down again and again in Spring Boot rest API and starts working properly with API restart.

New Contributor

I am using Hive-JDBC connection for connecting with Hive using Spring Boot in my Rest application.Though i am able to connect and query on HIVE but connection goes down in some time and start giving error.Once i restart my API, things start working properly. Below is the code snippet and error log. Could any one please help me with the same.

error:

{ "timestamp": 1540455764143, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.dao.DataAccessResourceFailureException", "message": "StatementCallback; SQL [select * from Test]; org.apache.thrift.transport.TTransportException: java.net.SocketException: Broken pipe (Write failed); nested exception is java.sql.SQLException: org.apache.thrift.transport.TTransportException: java.net.SocketException: Broken pipe (Write failed)", "path": "/hive/getalldata" }

Code snippet:

@Configurationpublic class HiveConfig {

private static final Logger logger = LoggerFactory.getLogger(HiveConfig.class);@Autowiredprivate Environment env;@Bean(name = "hiveJdbcDataSource")
@Qualifier("hiveJdbcDataSource")
public DataSource dataSource() {
DataSource dataSource = new DataSource();dataSource.setUrl(env.getProperty("hive.url"));dataSource.setDriverClassName(env.getProperty("hive.driver-class-name"));// dataSource.setUsername(env.getProperty("hive.username")); // dataSource.setPassword(env.getProperty("hive.password"));logger.debug("Hive DataSource"); return dataSource;}

@Bean(name = "hiveJdbcTemplate")
public JdbcTemplate hiveJdbcTemplate(@Qualifier("hiveJdbcDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);}
1 REPLY 1
Highlighted

Re: Hive JDBC Connection is going down again and again in Spring Boot rest API and starts working properly with API restart.

New Contributor

I am facing exactly the same issue, Did you find any resolution for this?