如何将文件中的数据加载到hsqldb表中? 我有这个声明在mysql中正常工作,我想改变它以适用于hsqldb。
String sqlLoadkey ="load data local infile " +"'E:/Thesis/ThesisWork/outdata/keywords.txt'"+ " \n" +
" into table "+ "keywordsTable" +"(keywords)";
stmt1.executeUpdate(sqlLoadkey);
这是我得到的例外
java.sql.SQLSyntaxErrorException: unexpected token: LOAD
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source)
at ThesisCode.ReductionTry.main(ReductionTry.java:67)
Exception in thread "main" java.lang.NullPointerException
at ThesisCode.ReductionTry.main(ReductionTry.java:138)
任何想法 感谢
答案 0 :(得分:0)
LOAD DATA
是一个对hsqldb无效的MySQL命令,但您可以使用临时表并更改源:
-- remporary table
create table yourdb.tmp_textfiletable (col1 varchar(250));
set table yourdb.tmp_textfiletable
source "'E:/Thesis/ThesisWork/outdata/keywords.txt';ignore_first=false";
-- And insert it in your normal table:
INSERT INTO yourdb.keywordsTable (keywords)
select Col1 from yourdb.tmp_textfiletable;
-- after that you can drop it
drop table yourdb.tmp_textfiletable