我可以在 shell 中执行 SQL:
LOAD DATA LOCAL INPATH '/tmp/sql.txt' INTO TABLE files;
这是 sql.txt 中的内容:
4e6c924a-1fa2-4326-86eb-975d1007f0a6 FileScoreConverterTest.java /home/xiehaozhe/Development/Kloud-Document-Analyzer/kda/src/test/java/com/kda/filescore/type/FileScoreConverterTest.java
ab6ee610-c980-4ff7-b472-8546766e0f89 FileWordCountConverterTest.java /home/xiehaozhe/Development/Kloud-Document-Analyzer/kda/src/test/java/com/kda/filescore/type/FileWordCountConverterTest.java
表的结构(命名文件)是
guid STRING
filename STRING
filepath STRING
如果我在 Java 中执行 sql,则会出现异常:
Exception in thread "main" java.sql.SQLException: Query returned non-zero code: 40000, cause: FAILED: ParseException line 1:54 mismatched input ';' expecting EOF near 'files'
这是代码:
Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
String sql = "LOAD DATA LOCAL INPATH '" + sqlFilePath + "' INTO TABLE files;";
Connection connection = DriverManager.getConnection(databaseAddress, databaseUsername, databasePassword);
Statement statement = connection.createStatement();
statement.executeQuery(sql);
我应该怎么办?