MS访问数据库中的插入记录

时间:2017-01-29 14:28:14

标签: java ms-access inverted-index

我试图在我的倒排索引中插入大量记录,该索引在MS访问数据库中构建为表。这是表格设计(ID,term,doc,send是复合主键): image1

这是代码:

Connection conn = DriverManager.getConnection("jdbc:ucanaccess://myDB.accdb");
        Statement s = conn.createStatement();
        s.execute("DELETE FROM invertedIndex");

for(String o : POSoutputs) //while (Tokenizer.hasMoreTokens())
                    {
                        String word = o;

                        s.execute("insert into invertedIndex (term,doc,sent) values ('"+ o + "','" + listOfFiles[i].getAbsolutePath() + "','" + fileText + "')");

                        conn.commit();// i do commit to empty the stack because i will insert thousands of records, by scanning hundreds of documents. 
                    }

这是错误:

java.lang.StackOverflowError
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:297)
at java.nio.ByteBuffer.put(ByteBuffer.java:832)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:379)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:342)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.FileChannelImpl.writeInternal(FileChannelImpl.java:778)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:761)
at com.healthmarketscience.jackcess.impl.PageChannel.allocateNewPage(PageChannel.java:350)
at com.healthmarketscience.jackcess.impl.TempPageHolder.setNewPage(TempPageHolder.java:115)
at com.healthmarketscience.jackcess.impl.UsageMap$ReferenceHandler.createNewUsageMapPage(UsageMap.java:763)
at com.healthmarketscience.jackcess.impl.UsageMap$ReferenceHandler.addOrRemovePageNumber(UsageMap.java:747)
at com.healthmarketscience.jackcess.impl.UsageMap.removePageNumber(UsageMap.java:337)
at com.healthmarketscience.jackcess.impl.PageChannel.allocateNewPage(PageChannel.java:354)
at com.healthmarketscience.jackcess.impl.TempPageHolder.setNewPage(TempPageHolder.java:115)
at com.healthmarketscience.jackcess.impl.UsageMap$ReferenceHandler.createNewUsageMapPage(UsageMap.java:763)
at com.healthmarketscience.jackcess.impl.UsageMap$ReferenceHandler.addOrRemovePageNumber(UsageMap.java:747)
at com.healthmarketscience.jackcess.impl.UsageMap.removePageNumber(UsageMap.java:337)
at com.healthmarketscience.jackcess.impl.PageChannel.allocateNewPage(PageChannel.java:354)
at com.healthmarketscience.jackcess.impl.TempPageHolder.setNewPage(TempPageHolder.java:115) 
........ ERROR RECORDS ARE DUPLICATED .. etc

问题是什么?

2 个答案:

答案 0 :(得分:0)

错误很明显:ERROR RECORDS被重复

因此,您在一个或多个字段上拥有唯一索引。删除此项或删除具有重复字段值的记录。

答案 1 :(得分:0)

数据库已损坏,我创建了另一个具有相同表格的数据库。 我认为原因是因为这个问题的回答查询:How to restart counting from 1 after erasing table in MS Access?,它破坏了数据库的结构索引。 类似的问题出现在:deleting row with BigIndex UsageMap exception