我有一个工具可以读取 CSV 文件,使用 HSQLDB 从中选择,并将结果另存为另一个 CSV 文件。更多信息:http: //ondra.zizka.cz/stranky/programovani/java/apps/CsvCruncher-csv-manipulation-sql.texy
现在,当我将它用于某些任务时,我得到了:
java -jar CsvCruncher-1.0.jar result.csv foo.csv 'SELECT * FROM indata'
INFO: SQL: CREATE TEXT TABLE indata ( xrelease VARCHAR(255), xtype VARCHAR(255), xartifact VARCHAR(255), xversion VARCHAR(255) )
INFO: SQL: CREATE TEXT TABLE output ( XRELEASE VARCHAR(255), XTYPE VARCHAR(255), XARTIFACT VARCHAR(255), XVERSION VARCHAR(255) )
INFO: User's SQL: INSERT INTO output (SELECT * FROM indata)
INFO: Database closed
Exception in thread "main" java.sql.SQLException: integrity constraint violation: unique constraint or index violation: SYS_IDX_10027
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source)
at org.jboss.qa.cvscruncher.Cruncher.crunch(Cruncher.java:187)
at org.jboss.qa.cvscruncher.App.main(App.java:26)
at Crunch.main(Crunch.java:9)
Caused by: org.hsqldb.HsqlException: integrity constraint violation: unique constraint or index violation: SYS_IDX_10027
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.index.IndexAVL.insert(Unknown Source)
at org.hsqldb.persist.RowStoreAVLDiskData.indexRow(Unknown Source)
at org.hsqldb.Table.insertSingleRow(Unknown Source)
at org.hsqldb.StatementDML.insertRowSet(Unknown Source)
at org.hsqldb.StatementInsert.getResult(Unknown Source)
at org.hsqldb.StatementDMQL.execute(Unknown Source)
at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 5 more
从日志中可以看出,没有创建索引,至少没有明确创建。我试图在 HSQLDB 的手册中找到一些自动创建的约束,但没有找到。
当我只做SELECT 1 FROM indata
时,没关系。所以我想这与数据本身有关。对于这种情况,它们是: http: //pastebin.com/8QiY2HXx(x
以防止关键字冲突)。
更新:
当我转储从 CSV 读取的数据时,有点奇怪:
-------
XRELEASE: 5.1.0-SNAPSHOT
XTYPE: DEP
XARTIFACT: org.apache.maven:maven-ant-tasks
5XVERSION: 2.0.9
-------
XRELEASE: 5.1.0-SNAPSHOT
XTYPE: DEP
XARTIFACT: org.jboss.seam.integration:jboss-seam-int-microcontainer
5XVERSION: 5.1.0.CR1
-------
XRELEASE: 5.1.0-SNAPSHOT
XTYPE: DEP
XARTIFACT: org.jboss.seam.integration:jboss-seam-int-jbossas
5XVERSION: 5.1.0.CR1
-------
...
似乎该xversion
列以某种方式进行了修改。代码很简单System.out.println(" "+ metaData.getColumnLabel(i) + ": "+ rs.getObject(i) );
知道什么会导致这种情况吗?
谢谢, 翁德拉