Discussion:
getting mismatched input 'ROW' expecting <EOF> error in hive creation
Sateesh Karuturi
2015-08-04 15:22:09 UTC
Permalink
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>
gabriel balan
2015-08-04 16:26:17 UTC
Permalink
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
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.
Loading...