---
title: "impala jdbc方式连接报java.sql.SQLException: Error: Error: could not match input解决方法"
author: "daizj"
date: "2015-09-14T15:56:56Z"
tags: ["JDBC", "分号"]
categories: ["开源软件"]
slug: "impala-jdbc-java-sql-sqlexception-error-error-could-not-match-input"
draft: false
lastmod: "2015-09-14T15:58:16Z"
id: 2243266
url: "https://daizj.iteye.com/blog/2243266"
---

今天写了个程序通过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;之后的分号即可正常执行

 

特此记录，给所有遇到同样问题的同学解决思路！