Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

hive jdbc Statement.getUpdateCount() always returning -1

Solved Go to solution

hive jdbc Statement.getUpdateCount() always returning -1

New Contributor

hive jdbc Statement.getUpdateCount() always returning -1, instead it should return number of rows inserted/updated/deleted.

Here is the sample code.

---------------------------------

Class.forName("org.apache.hive.jdbc.HiveDriver"); String url = "jdbc:hive2://XXXX:10000/default"; Connection con = DriverManager.getConnection(url, "XXX", "XXX");

Statement stmt = con.createStatement(); //HiveStatement stmt = (HiveStatement)con.createStatement();

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();

----------------------------------

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 .

Appreciate any help.
1 ACCEPTED SOLUTION

Accepted Solutions

Re: hive jdbc Statement.getUpdateCount() always returning -1

Expert Contributor

This is not supported yet

2 REPLIES 2

Re: hive jdbc Statement.getUpdateCount() always returning -1

Expert Contributor

This is not supported yet

Re: hive jdbc Statement.getUpdateCount() always returning -1

Super Mentor

@san ch

It is hardcoded to return "-1" and work as designed so far.

https://github.com/apache/hive/blob/master/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java#L68...

  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;
  }

.