简体   繁体   English

原因:org.hsqldb.HsqlException:无效的statemnet-导入CSV数据时需要文本表

[英]Caused by: org.hsqldb.HsqlException: invalid statemnet - text table required when importing CSV data

I am trying to import CSV data to HSSQL database using java and this SQL sentence: 我正在尝试使用java和以下SQL语句将CSV数据导入HSSQL数据库:

statement.execute("set TABLE data_source source 'data.csv;ignore_first=true;fs=\\semi'");

But I am getting this error: 但我收到此错误:

Exception in thread "main" java.sql.SQLException: invalid statemnet - text table required in statement [set TABLE data_source source 'data.csv;ignore_first=true;fs=\semi']
    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.execute(Unknown Source)
    at com.test.Application.main(Application.java:53)
Caused by: org.hsqldb.HsqlException: invalid statemnet - text table required
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.StatementCommand.getResult(Unknown Source)
    at org.hsqldb.StatementCommand.execute(Unknown Source)
    at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
    at org.hsqldb.Session.executeDirectStatement(Unknown Source)
    at org.hsqldb.Session.execute(Unknown Source)
    ... 3 more

PS using this in HSSQL client works fine: PS在HSSQL客户端中使用此功能的效果很好:

set TABLE data_source source 'data.csv;ignore_first=true;fs=\semi'

You need to escape the backslash twice. 您需要两次转义反斜杠。 The following code doesn't show any exceptions. 以下代码未显示任何异常。

public static void main(String[] args) throws Exception {
    Connection connection = DriverManager.getConnection("jdbc:hsqldb:file:~/swdev/hsqldb/testdb", "SA", "");
    PreparedStatement statement = connection.prepareCall("create text TABLE data_source (id INTEGER)");
    statement.execute();
    statement.close();
    statement = connection.prepareCall("set TABLE data_source source 'data.csv;ignore_first=true;fs=\\\\semi'");
    statement.execute();
    statement.close();
    connection.close();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起原因:org.hsqldb.HsqlException:违反基数 - Caused by: org.hsqldb.HsqlException: cardinality violation org.hsqldb.HsqlException:数据异常:转换的字符值无效 - org.hsqldb.HsqlException: data exception: invalid character value for cast HSQLDB函数创建原因:org.hsqldb.HsqlException: - HSQLDB function creating Caused by: org.hsqldb.HsqlException: HSQL org.hsqldb.HsqlException:模式名称无效 - HSQL org.hsqldb.HsqlException: invalid schema name HSQLDB:REPLACE INTO 表抛出 org.hsqldb.HsqlException:违反完整性约束: - HSQLDB: REPLACE INTO table throws org.hsqldb.HsqlException: integrity constraint violation: Maven和Hsqldb:org.hsqldb.HsqlException:需要客户端驱动程序版本大于'2.1.0.0'。 HSQLDB服务器版本为'2.3.4'(在Mac上) - Maven and Hsqldb: org.hsqldb.HsqlException: Client driver version greater than '2.1.0.0' is required. HSQLDB server version is '2.3.4' (on mac) 升级到HSQL 2.0.1.rc3后-大量的org.hsqldb.HsqlException:数据异常:…进行投诉 - After upgrade to HSQL 2.0.1.rc3 - Lots of org.hsqldb.HsqlException: data exception: … cast complaints org.hsqldb.HsqlException: 升级 spring boot 版本时用户缺少权限或找不到对象 - org.hsqldb.HsqlException: user lacks privilege or object not found when upgrading spring boot version HSQL错误:org.hsqldb.HsqlException:主键已经存在 - HSQL Error: org.hsqldb.HsqlException: primary key already exist Java SQL,一般错误org.hsqldb.HsqlException - Java SQL, General error org.hsqldb.HsqlException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM