Hi,

I'm using Hive 0.11 in local mode on a VM and I'm executing a dumb query :

select count(1) from hive_dates;

When I execute the above query on Hive CLI, I get 6 as the output(the row 
count) at the end of the triggered MR job.

I'm starting the HiveServer2 using hive --service hiveserver2.

But when I execute the same query from the JDBC code, the MR job executes 
smoothly, I get OK but now row count !

The PARTIAL Java code is :

public static void main(String[] args) throws SQLException {
            // TODO Auto-generated method stub

            Connection hiveConnection = DBUtils.getHiveConnection();
            DatabaseMetaData dbMetaData = hiveConnection.getMetaData();

            System.out.println("DB Product Name : "
                        + dbMetaData.getDatabaseProductName() + " Driver Name : 
"
                        + dbMetaData.getDriverName());

            Statement stmt = hiveConnection.createStatement();
            int cnt = stmt.executeUpdate("select count(1) from hive_dates");

            System.out.println("The count is " + cnt);

            DBUtils.closeStatement(stmt);
            DBUtils.closeConnection(hiveConnection);
      }


public static Connection getHiveConnection() {

            String url = "jdbc:hive2://172.25.37.135:10000/default";
            String driver = "org.apache.hive.jdbc.HiveDriver";
            Connection con = null;

            try {

                  Class.forName(driver);
                  con = DriverManager.getConnection(url, "hduser", "");
                  System.out.println("connected started-----------------");
            } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            } catch (ClassNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

            return con;

      }

The output is :

log4j:WARN No appenders could be found for logger 
(org.apache.thrift.transport.TSaslTransport).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more 
info.
connected started-----------------
DB Product Name : Hive Driver Name : Hive
The count is 0

Regards,
Omkar Joshi

________________________________
The contents of this e-mail and any attachment(s) may contain confidential or 
privileged information for the intended recipient(s). Unintended recipients are 
prohibited from taking action on the basis of information in this e-mail and 
using or disseminating the information, and must notify the sender and delete 
it from their system. L&T Infotech will not accept responsibility or liability 
for the accuracy or completeness of, or the presence of any virus or disabling 
code in this e-mail"

Reply via email to