我正在尝试连接到我的Impala群集。但它被卡住(没有停止运行)并且没有显示错误,也没有结果。
这是我的代码:
public class testJDBC {
static final String JDBC_IMPALA_URL = "jdbc:impala://192.168.70.14:21050;AuthMech=3;UID=root;PWD=P13Ak!ix;UseSasl=0;UseNativeQuery=1;LogLevel=6;LogPath=f:\\Users\\joaquin\\Desktop\\Libros\\logs-driver";
static final String JDBC_DRIVER_IMPALA ="com.cloudera.impala.jdbc4.Driver";
public static void main(String[] args) throws Exception {
System.out.println(getDolarFromImpala("2016-12-26"));
}
public static double getDolarFromImpala(String date) {
double dolar = 0.0;
try {
Class.forName(JDBC_DRIVER_IMPALA);
String sql = "SELECT valor FROM asigra.dolar where date ='"+date+"'";
System.out.println("start");
Connection con = DriverManager.getConnection(JDBC_IMPALA_URL);//,IMPALA_USER,IMPALA_PASSWORD);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
dolar = rs.getDouble("valor");
}
stmt.close();
con.close();
System.out.println("end");
}
catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}
catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}
System.out.println(dolar);
return dolar;
}}
因为它没有显示任何错误我将日志设置为DEBUG,结果如下: ImpalaJDBC_diver.log
dic 28 11:54:49.861 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIDriver.getProperty(20): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIEnvironment.DSIEnvironment(com.cloudera.impala.impala.core.ImpalaJDBCDriver@300ffa5d): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.hivecommon.core.HiveJDBCEnvironment.HiveJDBCEnvironment(com.cloudera.impala.impala.core.ImpalaJDBCDriver@300ffa5d): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.hivecommon.core.HiveJDBCEnvironment.createConnection(): +++++ enter +++++
impala_connection_0.log
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.DSIConnection(com.cloudera.impala.hivecommon.core.HiveJDBCEnvironment@254989ff): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(101, Variant[type: TYPE_WSTRING, value: ImpalaJDBC]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(139, Variant[type: TYPE_WSTRING, value: User]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(22, Variant[type: TYPE_WSTRING, value: Impala]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(58, Variant[type: TYPE_WSTRING, value: `]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(66, Variant[type: TYPE_UINT16, value: -1]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(68, Variant[type: TYPE_UINT16, value: -1]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(76, Variant[type: TYPE_UINT16, value: -1]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(81, Variant[type: TYPE_UINT16, value: -1]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(83, Variant[type: TYPE_UINT16, value: -1]): +++++ enter +++++
dic 28 11:54:49.876 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.setProperty(80, Variant[type: TYPE_WSTRING, value: N]): +++++ enter +++++
dic 28 11:54:49.908 TRACE 1 com.cloudera.impala.dsi.core.impl.DSIConnection.registerWarningListener(com.cloudera.impala.jdbc.common.SWarningListener@446cdf90): +++++ enter +++++
dic 28 11:54:49.908 TRACE 1 com.cloudera.impala.hivecommon.core.HiveJDBCConnection.updateConnectionSettings(): +++++ enter +++++
dic 28 11:54:49.908 TRACE 1 com.cloudera.impala.jdbc.common.CommonCoreUtils.logConnectionFunctionEntrance({AuthMech=Variant[type: TYPE_WSTRING, value: 3], ConnSchema=Variant[type: TYPE_WSTRING, value: NULL], DatabaseType=Variant[type: TYPE_WSTRING, value: Impala], HiveServerType=Variant[type: TYPE_WSTRING, value: 2], Host=Variant[type: TYPE_WSTRING, value: 192.168.70.14], LogLevel=Variant[type: TYPE_WSTRING, value: 6], LogPath=Variant[type: TYPE_WSTRING, value: f:\Users\joaquin\Desktop\Libros\logs-driver], Port=Variant[type: TYPE_WSTRING, value: 21050], PWD=Variant[type: TYPE_WSTRING, value: P13Ak!ix], UID=Variant[type: TYPE_WSTRING, value: root], UseNativeQuery=Variant[type: TYPE_WSTRING, value: 1], UseSasl=Variant[type: TYPE_WSTRING, value: 0]}, "Major Version: 2", "Minor Version: 5", "Hot Fix Version: 16", "Build Number: 1018", "java.vendor:Oracle Corporation", "java.version:1.8.0_45", "os.arch:amd64", "os.name:Windows 8", "os.version:6.2", "Runtime.totalMemory:126877696", "Runtime.maxMemory:1879048192", "Runtime.avaialableProcessors:4", URLClassLoader.getURLs(): /F:/Users/joaquin/Documents/New_folder/test%20impala%20jdbc/bin/, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/ImpalaJDBC4.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/hive_metastore.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/hive_service.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/ql.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/TCLIServiceClient.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/libfb303-0.9.0.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/libthrift-0.9.0.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/log4j-1.2.14.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/slf4j-api-1.5.11.jar, /F:/Users/joaquin/Documents/impala_jdbc_2.5.16.1018/2.5.16.1018/Cloudera_ImpalaJDBC4_2.5.16.1018/ImpalaJDBC4/slf4j-log4j12-1.5.11.jar): +++++ enter +++++
我没有找到任何这些东西,所以我不知道错误是什么。
请帮忙!
此致 华金