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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…