Why does not HiveConnection support getHoldability()? Using C3P0 with HiveDriver

╄→尐↘猪︶ㄣ 提交于 2019-12-11 16:14:16

问题


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.


回答1:


( 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



来源:https://stackoverflow.com/questions/47312944/why-does-not-hiveconnection-support-getholdability-using-c3p0-with-hivedriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!