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