title: "Invalid method name: 'execute'" error with Hive Client in Java
body: <p>I am using CDH 4.2.1-1.cdh4.2.1.p0.5 in a cluster set-up with Cloudera Manager and I am trying to get the Hive example working using the Hive API in Java.
  The hive version I am using is 0.10 (hive-hwi-0.10.0-cdh4.2.1.jar) and I am trying to setup a simple example following the instructions in this url: <a href="https://cwiki.apache.org/confluence/display/Hive/HiveClient" rel="nofollow noreferrer">https://cwiki.apache.org/confluence/display/Hive/HiveClient</a></p>
  <p>When running my code (the source code at the end of the post), I am getting the following error:</p>
  <pre><code>Exception in thread &quot;main&quot; java.sql.SQLException: org.apache.thrift.TApplicationException: Invalid method name: 'execute'
      at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:191)
      at org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:127)
      at org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:126)
      at org.apache.hadoop.hive.jdbc.HiveConnection.&lt;init&gt;(HiveConnection.java:121)
      at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
      at java.sql.DriverManager.getConnection(DriverManager.java:579)
      at java.sql.DriverManager.getConnection(DriverManager.java:221)
  </code></pre>
  <p>I've been searching in Google for a while now and I cannot find any solution to this problem.
  Anyone can give me a hint what could be causing the issue?</p>
  <p>Thanks in advance,</p>
  <p>Robbbie</p>
  <br>
  <br>
  <p><strong>Code causing the error:</strong></p>
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import org.apache.log4j.Logger;
  
  public class HiveJob {
  
  private static Logger mLogger = Logger.getLogger(HiveJob.class);
  private static String driverName = &quot;org.apache.hadoop.hive.jdbc.HiveDriver&quot;;
  
  public static void main(String[] args) throws SQLException {
      HiveJob myJob = new HiveJob();
      myJob.execute();
  }
  
  public void execute() throws SQLException {
      mLogger.info(&quot;Start HiveJob&quot;);
      try {
          Class.forName(driverName);
      } catch (ClassNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          System.exit(1);
      }
      Connection con = DriverManager.getConnection(&quot;jdbc:hive://myHiveServer:9083/default&quot;, &quot;&quot;, &quot;&quot;);
      Statement stmt = con.createStatement();
      String sql = &quot;SHOW TABLES&quot;;
      System.out.println(&quot;Running: &quot; + sql);
      ResultSet res = stmt.executeQuery(sql);
      while (res.next()) {
          System.out.println(res.getString(1));
      }
      mLogger.info(&quot;HiveJob executed!&quot;);
  }
  </code></pre>
  <p>}</p>