Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

jdbc - Why does not HiveConnection support getHoldability()? Using C3P0 with 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)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

( 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...