是否可以将一百万条记录(xml 文件)存储到 Basex 数据库中?
for(int j=1;j<1000000;j++) {
String id=String.valueOf(j);
String[] elems={"firstname","lastname","nickname","salary","permanentAddress","currentAddress","contactNo","email","alternateMail","FacebookName","Color"};
String[] childs = {id,"yong"+id,"mook kim"+id,"mkyong"+id,"100000"+id,"Bhopal"+id,"pune"+id,"999999999"+id ,"test"+id+"@basex.com","testA"+id+"@basex.com","Tom"+id,"grey"+id};
try {
xmlFile= x.CreateXMLDoc("test","transperfect",elems,childs);
} catch (TransformerConfigurationException exception) {
exception.printStackTrace();
}
storeIntoBaseXDB(j,id,xmlFile);
}
//StoreIntoBaseXDB方法
public static void storeIntoBaseXDB(int i,String id,String xmlFile) 抛出 BaseXException {
if(i==1)
{
System.out.println("=========================Store into Database=========================");
//System.out.println("Check database existence");
con.getDatabaseConnection(dbNmae);
con.executeInsertQuery(dbNmae,id,xmlFile);
}
else
{
con.executeInsertQuery(dbNmae,id,xmlFile);
}
}
//执行InsertQuery()方法
public long executeInsertQuery(String dbname,String id,String xmlFile) throws BaseXException
{
//System.out.println(path);
new Open(dbname).execute(context);
try
{
/* String query = "db:add('db','C:/Users/manish/Desktop/BaseX65/xml/books.xml')";
QueryProcessor proc = new QueryProcessor(query, context);
proc.execute();
proc.close();
context.close();*/
new Add(id,xmlFile).execute(context);
//System.out.println(new Find(id));
}
catch (Exception e)
{
System.out.println("ERROR executing query: ");
e.printStackTrace();
}
最佳答案
是的,这是可能的。为什么不是(一百万是一个相对较小的数字)?
限制为 2^29 即 546,870,912
(存储的 XML 文档的数量)。
XML 元素的限制是 2^31,即 2,147,483,648
(尽管这包括所有节点,包括属性、文本等)。
这是一个关于现有数据库示例的 BaseX 统计网页,表格的第一行也包含限制(#Files
表示存储的 XML 文档的数量,#Nodes
表示元素、属性、文本等 XML 节点的数量):
关于java - 将数百万个 xml 文件插入 basex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25113900/