Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C506718DE5 for ; Tue, 4 Aug 2015 16:26:38 +0000 (UTC) Received: (qmail 64844 invoked by uid 500); 4 Aug 2015 16:26:37 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 64767 invoked by uid 500); 4 Aug 2015 16:26:37 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 64757 invoked by uid 99); 4 Aug 2015 16:26:37 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2015 16:26:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 885D1DA51A for ; Tue, 4 Aug 2015 16:26:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.85 X-Spam-Level: ** X-Spam-Status: No, score=2.85 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, RP_MATCHES_RCVD=-0.149, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id BXXX11LCCWLE for ; Tue, 4 Aug 2015 16:26:27 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id C1DAF20773 for ; Tue, 4 Aug 2015 16:26:26 +0000 (UTC) Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t74GQJTY014628 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Aug 2015 16:26:19 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t74GQImj017756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 4 Aug 2015 16:26:19 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t74GQI6b006017 for ; Tue, 4 Aug 2015 16:26:18 GMT Received: from [10.149.251.27] (/10.149.251.27) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Aug 2015 09:26:18 -0700 Message-ID: <55C0E7A9.6030504@oracle.com> Date: Tue, 04 Aug 2015 12:26:17 -0400 From: gabriel balan Organization: Oracle Corporation User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: user@hive.apache.org Subject: Re: getting mismatched input 'ROW' expecting error in hive creation References: In-Reply-To: Content-Type: multipart/alternative; boundary="------------070204050106060906040509" X-Source-IP: userv0022.oracle.com [156.151.31.74] This is a multi-part message in MIME format. --------------070204050106060906040509 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi > + "ROW FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'"); Shouldn't you escape the backslashes ('\\n' instead of '\n'), so they're not interpreted by java? hth GB On 8/4/2015 11:22 AM, Sateesh Karuturi wrote: > i want create a hive table using java code. my code is > package com.inndata.services;/ > /import java.sql.ResultSet; > import java.sql.SQLException; > import java.sql.Connection; > import java.sql.Statement; > import java.sql.DriverManager;/ > /public class HiveCreateTable { > private static String driverName = "com.facebook.presto.jdbc.PrestoDriver"; > > public static void main(String[] args) throws SQLException { > > // Register driver and create driver instance > try { > Class.forName(driverName); > } catch (ClassNotFoundException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > System.out.println("haiiiiii"); > Connection con = DriverManager.getConnection("jdbc:presto://192.168.1.118:8023", "hadoop", "cassandra"); > con.setCatalog("hive"); > con.setSchema("log"); > Statement stmt = con.createStatement(); > ResultSet res = stmt.executeQuery("create table access_log (c_ip varchar," > + "cs_username varchar," > + "cs_computername varchar," > + "cs_date varchar," > + "cs_code varchar," > + "cs_method varchar," > + "cs_uri_stem varchar," > + "cs_uri_query varchar," > + "cs_status_code varchar," > + "cs_bytes varchar)" > + "ROW FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'"); > System.out.println("Table access_log created."); > con.close(); > } > } > and getting > Exception in thread "main" java.sql.SQLException: Query failed (#20150804_152058_00004_r8ehs): line 1:214: mismatched input 'ROW' expecting -- The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation. --------------070204050106060906040509 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hi
 + "ROW  FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'");
Shouldn't you escape the backslashes ('\\n' instead of '\n'), so they're not interpreted by java?

hth
GB


On 8/4/2015 11:22 AM, Sateesh Karuturi wrote:
i want create a hive table using java code. my code is 
package com.inndata.services;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
public class HiveCreateTable {
  private static String driverName = "com.facebook.presto.jdbc.PrestoDriver";
  
  public static void main(String[] args) throws SQLException {
  
     // Register driver and create driver instance
     try {
        Class.forName(driverName);
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
     System.out.println("haiiiiii");
     Connection con = DriverManager.getConnection("jdbc:presto://192.168.1.118:8023", "hadoop", "cassandra");
     con.setCatalog("hive");
     con.setSchema("log");
     Statement stmt = con.createStatement();
     ResultSet res = stmt.executeQuery("create table access_log (c_ip varchar,"
                                                                 + "cs_username varchar,"
                                                                 + "cs_computername varchar,"
                                                                 + "cs_date varchar,"
                                                                 + "cs_code varchar,"
                                                                 + "cs_method varchar,"
                                                                 + "cs_uri_stem varchar,"
                                                                 + "cs_uri_query varchar,"
                                                                 + "cs_status_code varchar,"
                                                                 + "cs_bytes varchar)"
                                                                 + "ROW  FORMAT DELIMITED FIELDS TERMINATED BY '\b' LINES TERMINATED BY '\n'");
     System.out.println("Table access_log created.");
     con.close();
  }
}
and getting 
Exception in thread "main" java.sql.SQLException: Query failed (#20150804_152058_00004_r8ehs): line 1:214: mismatched input 'ROW' expecting <EOF>

-- 
The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation.
--------------070204050106060906040509--