Support Questions
Find answers, ask questions, and share your expertise

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.


{ "timestamp": 1540455764143, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.dao.DataAccessResourceFailureException", "message": "StatementCallback; SQL [select * from Test]; org.apache.thrift.transport.TTransportException: Broken pipe (Write failed); nested exception is java.sql.SQLException: org.apache.thrift.transport.TTransportException: 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")
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);}

New Contributor

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