I have hadoop env ,the hive metasotre is mysql.
I can connect to mysql with configured username/passwd use jdbc in java successfully.
But I have some hive sql ,like
[CREATE EXTERNAL TABLE IF NOT EXISTS]
[SELECT PERCENTILE_APPROX(LOG.QUERY_LATENCY,0.9) FROM Table],this is not supported in mysql.
So ,how can I connect hive env and execute hive sql when metastore is mysql?
If you are using the HiveServer2 then try using below code snippet:
private static String driver = "org.apache.hive.jdbc.HiveDriver";
.
.
.
Connection connect = DriverManager.getConnection("jdbc:hive2://<host>:port/default","","");
Statement state = connect.createStatement();
// Query to show tables
String show = "show tables";
ResultSet res = state.executeQuery(show);
I am using Hive Version 0.13 with that I am using Hive Driver version 1.1.0 My POM Dependency for Hive Driver: org.apache.hive hive-jdbc 1.1.0
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.