impala jdbc方式连接报java.sql.SQLException: Error: Error: could not match input解决办法
今天写了个程序通过jdbc的方式去连接impala,访问库里的数据时遇到如下错误:
java.sql.SQLException: Error: Error: could not match input
at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:159)
at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:147)
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:182)
at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:246)
at org.apache.jsp.index_jsp.getDimDayList(index_jsp.java:29)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:166)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
java查询代码:
Class.forName("org.apache.hive.jdbc.HiveDriver");
impalaConnection = DriverManager.getConnection("jdbc:hive2://" + IMPALAD_HOST + ':' + IMPALAD_JDBC_PORT + "/;auth=noSasl");
Statement statement = impalaConnection.createStatement();
StringBuffer sql = new StringBuffer();
sql.append("select id,year,month,week,day from dim_test limit 10;");
ResultSet rs = statement.executeQuery(sql.toString());
错误原因:sql语句多了一个分号
解决方法:去掉select id,year,month,week,day from dim_test limit 10;之后的分号即可正常执行
特此记录,给所有遇到同样问题的同学解决思路!