Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 0.7.1
    • Fix Version/s: None
    • Component/s: JDBC
    • Labels:
    • Environment:

      Operating System - Ubuntu 11.10
      Softwares - Hadoop-0.20.2, Hive-0.7.1

      Description

      I am trying to implement a task in Hive (Similar to Stored Procedure in SQL (Block of queries)).
      In SQL, when we write cursor, first we execute select query and then fetching the records we perform some actions.

      Likely I have fired a select query in Hive as:

      String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
      Class.forName(driverName);
      Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
      String sql=null;
      Statement stmt = con.createStatement();
      Statement stmt1 = con.createStatement();
      ResultSet res=null;
      ResultSet rs1=null;

      sql="select a,c,b from tbl_name";
      res=stmt.executeQuery(); -----------> CONTAINS 30 RECORDS
      while(res.next())

      { sql="select d,e,f, from t1"; rs1=stmt1.executeQuery(); like wise many queries are there..... . . . .. }

      But the problem is that while loop executes only once instead of 30 times when the inner query (inside while) gets execute.

      And If I create two different connection for both the queries then all works fine.
      Like:
      String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
      Class.forName(driverName);
      Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
      Connection con1 = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
      String sql=null;
      Statement stmt = con.createStatement();
      Statement stmt1 = con1.createStatement();
      ResultSet res=null;
      ResultSet rs1=null;

      To sum up, when I iterate through a result set do I need to use a different connection(and statement object) to
      execute other queries????

        Activity

        Hide
        alex gemini added a comment -

        hive didn't support cursor in JDBC world.if you intend iterate through a result set,maybe you should first execute the query and store it,and using your client logic to generate second query .this maybe a more PIG GENERATE case.I suggest close this.

        Show
        alex gemini added a comment - hive didn't support cursor in JDBC world.if you intend iterate through a result set,maybe you should first execute the query and store it,and using your client logic to generate second query .this maybe a more PIG GENERATE case.I suggest close this.

          People

          • Assignee:
            Unassigned
            Reporter:
            Bhavesh Shah
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 168h
              168h
              Remaining:
              Remaining Estimate - 168h
              168h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development