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

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

问题描述

我尝试使用 C3P0 com.mchange.v2.c3p0.ComboPooledDataSource )和 HiveDriver org.apache.hive.jdbc.HiveDriver )。我收到了一个例外:

  java.sql.SQLException:方法不支持
在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

  / * 
*(非商业用途) Javadoc)
*
* @see java.sql.Connection#getHoldability()
* /
$ b @Override
public int getHoldability()throws SQLException {
// TODO自动生成的方法存根
抛出新的SQLFeatureNotSupportedException(Method not supported);
}

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

  ResultSet.HOLD_CURSORS_OVER_COMMIT 
ResultSet.CLOSE_CURSORS_AT_COMMIT



这是一个错误吗?



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



更新1(2017-11-15)



我只是试过 dbcp2 org.apache.commons.dbcp2.BasicDataSource ),它工作正常。我想不知何故 dbcp2 不会调用 Connection#getHoldability()方法。
<我在这里回答我自己的问题。



感谢Mark Rotteveel的建议,我现在也认为这个问题确实是一个错误。我用Apache提交了一个bug报告HIVE-18082( here )。



在bug修复之前,一个临时解决方法是使用不同的连接池 - DBCP2 而不是 C3P0 。由于某些原因,前者不会调用 Connection#getHoldability(),因此不会受到 HiveConnection


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)

I found the source code of HiveConnection (here)

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

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

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

Is this a bug?

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

Update 1 (2017-11-15)

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. )

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.

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()?与HiveDriver一起使用C3P0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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