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