简体   繁体   中英

No suitable driver found for jdbc:hive2

Trying to connect to hive using JDBC.

Url: jdbc:hive2://...

Driver: org.apache.hive.jdbc.HiveDriver

I have on the classpath:

  • /usr/hdp/current/hive-client/lib/hive-jdbc.jar (3.1.0)
  • /usr/hdp/current/hive-client/lib/hive-common.jar (3.1.0)
  • /usr/hdp/current/hive-client/lib/hive-service.jar (3.1.0)
  • /usr/hdp/current/hadoop-client/hadoop-common.jar (3.1.1)
  • /usr/hdp/current/hive-client/lib/hive-service.jar (3.1.0)
  • /usr/hdp/current/hive-client/lib/libthrift-0.9.3-1.jar
  • /usr/hdp/current/hive-client/lib/libfb303-0.9.3.jar
  • /usr/hdp/current/hive-client/lib/hive-exec.jar (3.1.0)
  • /usr/hdp/current/hive-client/lib/hive-jdbc-handler.jar (3.1.0)

And I get an error "No suitable driver found for jdbc:hive2". What am I doing wrong?

Apache Hive (version 3.1.0.3.1.4.0-315)

  def configure(hiveConfig: HiveSettings): Either[String, Unit] =
for {
  _ <- Either
    .catchNonFatal(Class.forName("org.apache.hive.jdbc.HiveDriver"))
    .leftMap(_.getMessage)
  _ <- Either.right(ConnectionPool.singleton(hiveConfig.url, null, null))
} yield {
  Logger.debug(s"Hive URL: [${hiveConfig.url}]")
}

Try loading the Hive Driver explicitly before opening up the connection. It seems like your version is not JDBC4 compliant, ie will not get loaded automatically.

try {
      Class.forName("org.apache.hive.jdbc.HiveDriver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM