jdbc访问hive出现java.sql.SQLException: No suitable driver found for jdbc:hive的错误

使用hive的版本是apache-hive-0.13.1-bin.tar

private static String driver = "org.apache.hive.jdbc.HiveDriver";
private static String url = "jdbc:hive://192.168.1.204:10002/default  ";


static {
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}


public static Connection getConection() {
try {
return DriverManager.getConnection(url, "", "");
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

调用getConection()时出现错误:java.sql.SQLException: No suitable driver found for jdbc:hive

查了很多资料,最终发现是驱动名称不对:将driver改为“org.apache.hadoop.hive.jdbc.HiveDriver”就好了,说明hive的不同版本对应不同的驱动。

你可能感兴趣的:(jdbc访问hive出现java.sql.SQLException: No suitable driver found for jdbc:hive的错误)