I am able to connect to my custom JDBC server able to handle SQL queries via source code
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class HiveConnector {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
/**
* @param args
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
try {
//replace "hive" here with the name of the user the queries should run as
Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000", "{username}", "{password}");
Statement stmt = con.createStatement();
String tableName = "`tableName`";
String sql = "select * from " + tableName;
System.out.println("Running: " + sql);
ResultSet res = stmt.executeQuery(sql);
while (res.next()) {
System.out.println(res.getString(1) + "\t" + res.getString(2));
}
} catch (Exception e) {
System.out.print(e.getMessage());
}
}
}
I followed the instruction at http://gethue.com/custom-sql-query-editors/ and have downloaded hue 3.10.0 binary and did "make install". I changed my hue.ini file for notebook hive to
[[[hive]]]
name=My Hive
interface=jdbc
options='{"url": "jdbc:hive2://localhost:10000", "driver": "org.apache.hive.jdbc.HiveDriver", "user": "{username}", "password": "{password}"}'
I logged into my hue UI and navigated to notebook "My Hive" and noticed following error. [0] I am just wondering what I am doing wrong? Here is my CLASSPATH for Java [1] which have few extra jars.
[1]: export CLASSPATH=/usr/local/lib/myCustom/hive-jdbc-1.2.1.jar:/usr/local/lib/myCustom/mysql-connector-java-5.1.38-bin.jar:/usr/local/lib/myCustom/hadoop-core-0.20.2.jar:$CLASSPATH
[0]: An error occurred while calling z:java.sql.DriverManager.getConnection. : java.sql.SQLException: No suitable driver found for jdbc:hive2://localhost:10000 at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:247) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:379) at py4j.Gateway.invoke(Gateway.java:259) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:207) at java.lang.Thread.run(Thread.java:745)