是否可以将一百万条记录(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 方法
公共静态无效 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();
}
}