You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Bhavesh Shah (Created) (JIRA)" <ji...@apache.org> on 2012/03/20 12:23:37 UTC

[jira] [Created] (HIVE-2882) Problem with Hive using JDBC

Problem with Hive using JDBC
----------------------------

                 Key: HIVE-2882
                 URL: https://issues.apache.org/jira/browse/HIVE-2882
             Project: Hive
          Issue Type: Bug
          Components: JDBC
    Affects Versions: 0.7.1
         Environment: Operating System - Ubuntu 11.10
Softwares - Hadoop-0.20.2, Hive-0.7.1
            Reporter: Bhavesh Shah
            Priority: Critical


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????

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HIVE-2882) Problem with Hive using JDBC

Posted by "alex gemini (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-2882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13261399#comment-13261399 ] 

alex gemini commented on HIVE-2882:
-----------------------------------

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.
                
> Problem with Hive using JDBC
> ----------------------------
>
>                 Key: HIVE-2882
>                 URL: https://issues.apache.org/jira/browse/HIVE-2882
>             Project: Hive
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 0.7.1
>         Environment: Operating System - Ubuntu 11.10
> Softwares - Hadoop-0.20.2, Hive-0.7.1
>            Reporter: Bhavesh Shah
>            Priority: Critical
>              Labels: hadoop, hive
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> 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????

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira