<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question hive jdbc Statement.getUpdateCount() always returning -1 in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177260#M58358</link>
    <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;hive jdbc Statement.getUpdateCount() always  returning  -1, instead it should return number of rows inserted/updated/deleted.&lt;/P&gt;&lt;P&gt;Here is the sample code.&lt;/P&gt;&lt;P&gt;---------------------------------&lt;/P&gt;&lt;P&gt; Class.forName("org.apache.hive.jdbc.HiveDriver");
 String url = "jdbc:hive2://XXXX:10000/default";
 Connection con = DriverManager.getConnection(url, "XXX", "XXX");&lt;/P&gt;&lt;P&gt; Statement stmt = con.createStatement();
 //HiveStatement stmt = (HiveStatement)con.createStatement();&lt;/P&gt;&lt;P&gt; String sql = "INSERT INTO TAB_CNT_2 select * from TAB_CNT_1";  
 //String sql = "LOAD DATA INPATH '/user/XXXXXX.txt' INTO TABLE TAB_CNT_2"
 
 stmt.execute(sql); 
 System.out.println("update row count="+stmt.getUpdateCount());
 
 stmt.close();
 con.close();&lt;/P&gt;&lt;P&gt;----------------------------------&lt;/P&gt;&lt;P&gt;Looks like there are hive specific statement classes (HiveStatement, HivePreparedStatement) not sure how to instanciate these classes and also not sure if they return correct updateCount .&lt;/P&gt;Appreciate any help.</description>
    <pubDate>Tue, 28 Mar 2017 22:27:50 GMT</pubDate>
    <dc:creator>schemarla</dc:creator>
    <dc:date>2017-03-28T22:27:50Z</dc:date>
    <item>
      <title>hive jdbc Statement.getUpdateCount() always returning -1</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177260#M58358</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;hive jdbc Statement.getUpdateCount() always  returning  -1, instead it should return number of rows inserted/updated/deleted.&lt;/P&gt;&lt;P&gt;Here is the sample code.&lt;/P&gt;&lt;P&gt;---------------------------------&lt;/P&gt;&lt;P&gt; Class.forName("org.apache.hive.jdbc.HiveDriver");
 String url = "jdbc:hive2://XXXX:10000/default";
 Connection con = DriverManager.getConnection(url, "XXX", "XXX");&lt;/P&gt;&lt;P&gt; Statement stmt = con.createStatement();
 //HiveStatement stmt = (HiveStatement)con.createStatement();&lt;/P&gt;&lt;P&gt; String sql = "INSERT INTO TAB_CNT_2 select * from TAB_CNT_1";  
 //String sql = "LOAD DATA INPATH '/user/XXXXXX.txt' INTO TABLE TAB_CNT_2"
 
 stmt.execute(sql); 
 System.out.println("update row count="+stmt.getUpdateCount());
 
 stmt.close();
 con.close();&lt;/P&gt;&lt;P&gt;----------------------------------&lt;/P&gt;&lt;P&gt;Looks like there are hive specific statement classes (HiveStatement, HivePreparedStatement) not sure how to instanciate these classes and also not sure if they return correct updateCount .&lt;/P&gt;Appreciate any help.</description>
      <pubDate>Tue, 28 Mar 2017 22:27:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177260#M58358</guid>
      <dc:creator>schemarla</dc:creator>
      <dc:date>2017-03-28T22:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: hive jdbc Statement.getUpdateCount() always returning -1</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177261#M58359</link>
      <description>&lt;P&gt;This is not supported yet&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 23:10:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177261#M58359</guid>
      <dc:creator>ekoifman</dc:creator>
      <dc:date>2017-03-28T23:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: hive jdbc Statement.getUpdateCount() always returning -1</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177262#M58360</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/16664/schemarla.html" nodeid="16664"&gt;@san ch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It is hardcoded to return "-1" and work as designed so far. &lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/apache/hive/blob/master/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java#L681-L690" target="_blank"&gt;https://github.com/apache/hive/blob/master/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java#L681-L690&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;  public int getUpdateCount() throws SQLException {
    checkConnection("getUpdateCount");
    /**
     * Poll on the operation status, till the operation is complete. We want to ensure that since a
     * client might end up using executeAsync and then call this to check if the query run is
     * finished.
     */
    waitForOperationToComplete();
    return -1;
  }
&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 23:33:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/hive-jdbc-Statement-getUpdateCount-always-returning-1/m-p/177262#M58360</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-03-28T23:33:59Z</dc:date>
    </item>
  </channel>
</rss>

