0

如何在黑莓 java 应用程序的 sqlite 数据库上插入多行(~100k)?我试过这段代码:

Database d1; Statement st;

URI dbURI1 = URI.create("file:///SDCard/xxx.db")  if (DatabaseFactory.exists(dbURI1)) {
    d1 = DatabaseFactory.open(dbURI1); } else {
    d1 = DatabaseFactory.create(dbURI1);
    st = d1.createStatement("Insert into..................(for 100 k rows)");

    st.prepare();
    st.execute();
    st.close(); }

我也试过这个

st = d1.createStatement("插入......");

    st.prepare();
    st.execute();
    st.close();

st = d1.createStatement("插入......");

    st.prepare();
    st.execute();
    st.close();

. . . 100k 行。

Eclipse 开始变得非常慢,我无法调试它。

4

1 回答 1

1

尝试这个

Public void InsertData ()
{
Database d;
try
{
URI myURI = URI.create("file:///SDCard/Databases/" +"Test.db"); 
d = DatabaseFactory.open(myURI);

Statement st = d.createStatement("INSERT INTO testtable(id,name) " + "VALUES (1,’Arun’)");
st.prepare();
st.execute();
st.close();
d.close();
add(new RichTextField("Values Inserted"));
}
catch ( Exception e ) 
{ 
System.out.println( e.getMessage() );
e.printStackTrace();
add(new RichTextField("Error: "+e.toString()));
}

}
于 2012-05-14T10:02:03.757 回答