Why does not HiveConnection support getHoldability

2019-08-21 07:17发布

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条回答
何必那么认真
2楼-- · 2019-08-21 08:12

( 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

查看更多
登录 后发表回答