@@ -0,0 +1,2374 @@
+import org.apache.hadoop.fs.Path;%0Aimport org.omg.PortableInterceptor.SYSTEM_EXCEPTION;%0A%0Aimport java.sql.*;%0A%0Apublic class HiveJdbcClient %7B%0A%0A    private static String driverName = %22org.apache.hive.jdbc.HiveDriver%22;%0A%0A    public static void main(String%5B%5D args) throws SQLException %7B%0A        try %7B%0A            Class.forName(driverName);%0A        %7D catch (ClassNotFoundException e) %7B%0A            e.printStackTrace();%0A            System.exit(1);%0A        %7D%0A        Connection con = DriverManager.getConnection(%22jdbc:hive2://localhost:10000/default%22,%22%22,%22%22);%0A        Statement stmt = con.createStatement();%0A        String tableName = %22testHiveDriverTable%22;%0A//        stmt.executeQuery(%22drop table if exists %22 + tableName);%0A%0A        String sql = %22create table if not exists %22 + tableName + %22 (key int, value string) row format delimited fields terminated by ','%22;%0A        stmt.execute(sql);%0A        //show tables%0A        sql = %22show tables '%22 + tableName + %22'%22;%0A        System.out.println(%22Running: %22 + sql);%0A        ResultSet res = stmt.executeQuery(sql);%0A        if(res.next())%7B%0A            System.out.println(res.getString(1));%0A        %7D%0A        //describe table%0A        sql = %22describe %22 + tableName;%0A        System.out.println(%22Running: %22 + sql);%0A        res = stmt.executeQuery(sql);%0A        while(res.next())%7B%0A            System.out.println(res.getString(1) + %22%5Ct%22 + res.getString(2));%0A        %7D%0A%0A        //load data into table%0A        //Note: filePath has to be local to hive server%0A        String filePath = System.getProperty(%22user.dir%22) + %22/a.txt%22;%0A        sql = %22load data local inpath '%22 + filePath + %22' into table %22 + tableName;%0A        System.out.println(%22Running: %22 + sql);%0A        stmt.execute(sql);%0A%0A        //select * query%0A        sql = %22select * from %22 + tableName;%0A        System.out.println(%22Running: %22 + sql);%0A        res = stmt.executeQuery(sql);%0A        while(res.next())%7B%0A            System.out.println(String.valueOf(res.getInt(1)) + %22%5Ct%22 + res.getString(2));%0A        %7D%0A%0A        //regular hive query%0A        sql = %22select count(1) from %22 + tableName;%0A        System.out.println(%22Running: %22 + sql);%0A        res = stmt.executeQuery(sql);%0A        while(res.next())%7B%0A            System.out.println(res.getString(1));%0A        %7D%0A%0A        sql = %22drop table if exists %22 + tableName;%0A        System.out.println(%22Running: %22 + sql);%0A        stmt.execute(sql);%0A%0A    %7D%0A%7D%0A

Create HiveJdbcClient.java