我能够连接到我的自定义jdbc服务器,能够通过源代码处理sql查询
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());
}
}
}
我在家里照指示做http://gethue.com/custom-sql-query-editors/ 下载了hue3.10.0二进制文件并进行了“makeinstall”。我将笔记本配置单元的hue.ini文件更改为 [[[hive]]] name=My Hive interface=jdbc options='{"url": "jdbc:hive2://localhost:10000", "driver": "org.apache.hive.jdbc.HiveDriver", "user": "{username}", "password": "{password}"}'
我登录到我的色调界面,导航到笔记本“我的Hive”,并注意到以下错误[0]我只是想知道我做错了什么?下面是我的java[1]类路径,它几乎没有额外的jar。
[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]:调用z:java.sql.drivermanager.getconnection时出错:java.sql.sqlexception:找不到适合的驱动程序jdbc:hive2://localhost:10000 at java.sql.drivermanager.getconnection(驱动管理器)。java:689)在java.sql.drivermanager.getconnection(drivermanager。java:247)位于sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl。java:62)在sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.lang.reflect.method.invoke(方法。java:497)在py4j.reflection.methodinvoker.invoke(methodinvoker。java:231)在py4j.reflection.reflectionengine.invoke(reflectionengine。java:379)在py4j.gateway.invoke(gateway。java:259)在py4j.commands.abstractcommand.invokemethod(abstractcommand。java:133)在py4j.commands.callcommand.execute(callcommand。java:79)在py4j.gatewayconnection.run(网关连接。java:207)在java.lang.thread.run(线程。java:745)
暂无答案!
目前还没有任何答案,快来回答吧!