mismatched input 'ROW' expecting err

2019-07-16 04:27发布

I am trying to create a hive table using java.

Here is my code:

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.100:8023", "", "");
      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'STORED AS TEXTFILE");
      System.out.println("Table access_log4 created.");
    ResultSet res1 = stmt.executeQuery("LOAD DATA LOCAL INPATH  '/home/hadoop/access_log.txt'" + "OVERWRITE INTO TABLE access_log4;");
      System.out.println("data loaded to access_log4.");
    con.close();
   }
}

and getting following error:

Exception in thread "main" java.sql.SQLException: Query failed (#20150805_063004_00002_3dvaz): line 1:214: mismatched input 'ROW' expecting

If we remove "ROW FORMAT DELIMITED FIELDS TERMINATED BY '\b'LINES TERMINATED BY '\n'STORED AS TEXTFILE" table is creating but data is not loaded.

0条回答
登录 后发表回答