为什么 HiveConnection 不支持 getHoldability()?将 C3P0 与 HiveDriver 一起使用 [英] Why does not HiveConnection support getHoldability()? Using C3P0 with HiveDriver

查看:34
本文介绍了为什么 HiveConnection 不支持 getHoldability()?将 C3P0 与 HiveDriver 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 C3P0 (com.mchange.v2.c3p0.ComboPooledDataSource) 与 HiveDriver (org.apache.hive.jdbc.HiveDriver).我有一个例外:

I am trying to use C3P0 (com.mchange.v2.c3p0.ComboPooledDataSource) with HiveDriver (org.apache.hive.jdbc.HiveDriver). I got an exception of this:

java.sql.SQLException: Method not supported
at org.apache.hive.jdbc.HiveConnection.getHoldability(HiveConnection.java:924)
at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:106)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:159)

我找到了HiveConnection的源代码(这里)

/*
 * (non-Javadoc)
 *
 * @see java.sql.Connection#getHoldability()
 */

@Override
public int getHoldability() throws SQLException {
    // TODO Auto-generated method stub
    throw new SQLFeatureNotSupportedException("Method not supported");
}   

我的问题:为什么 HiveConnection 选择抛出一个SQLFeatureNotSupportedException ?而不是只返回其中一个?

My questions: Why does HiveConnection choose to throw an SQLFeatureNotSupportedException ? Instead of just returning one of these?

ResultSet.HOLD_CURSORS_OVER_COMMIT
ResultSet.CLOSE_CURSORS_AT_COMMIT

这是一个错误吗?

一般来说,是否可以使用连接池,例如作为 C3P0Hive(我实际上使用的是 Spark SQL)?

In general, is it possible to use a connection pool such as C3P0 with Hive (I am actually using Spark SQL)?

更新 1 (2017-11-15)

我刚刚尝试了 dbcp2 (org.apache.commons.dbcp2.BasicDataSource) 并且成功了.我想不知何故 dbcp2 没有调用 Connection#getHoldability() 方法.

I just tried dbcp2 (org.apache.commons.dbcp2.BasicDataSource) and it worked. I guess somehow dbcp2 does not invoke the Connection#getHoldability() method.

推荐答案

(我在这里回答我自己的问题.)

( I am answering my own question here. )

感谢 Mark Rotteveel 的建议,我现在也认为问题确实是一个错误.我已向 Apache 提交了错误报告 HIVE-18082(此处).

Thanks for the suggestion by Mark Rotteveel, I now also think the problem is indeed a bug. I have filed a bug report HIVE-18082 (here) with Apache.

在修复错误之前,一种临时解决方法是使用不同的连接池——DBCP2 而不是 C3P0.由于某种原因,前者没有调用 Connection#getHoldability(),因此不受 HiveConnection

Before the bug is fixed, one temporary workaround is to use a different connection pool -- DBCP2 instead of C3P0. For some reason the former does not make the call of Connection#getHoldability() and is thus not affected by this bug in HiveConnection

这篇关于为什么 HiveConnection 不支持 getHoldability()?将 C3P0 与 HiveDriver 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆