I use hive 0.6 version, I use JDBC to execute one search sql, for example below code: public static void query() { Connection hiveConnection = null; Statement statement = null;
try { Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver"); hiveConnection = DriverManager.getConnection("jdbc:hive://" , "", ""); statement = hiveConnection.createStatement(); String sql = "select a.id, b.name, a.age from test1 a join test2 b on(a.id=b.id)"; ResultSet result = statement.executeQuery(sql); while(result.next()) { System.out.println(result.getString(1) + " " +result.getString(2) + " " +result.getString(3)); } statement.close(); } catch(Exception e) { e.printStackTrace(); } finally { try { hiveConnection.close(); } catch (SQLException e) { e.printStackTrace(); } } } When the sql is executing, hive create one /tmp/hive-root/scratch/hive_2011-01-25_10-13-31_275_912012219404735792 directory in HDFS, after I colse the JDBC connection, the hive don't delete the directory. Thanks, LiuLei