我正在同时在数据库中插入多条记录
这是代码:-
public synchronized boolean execute_Batch_Query(final JSONArray accObj)
{
boolean value = false;
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
String sqlStatement = "INSERT INTO Records_Table(id ,name ,description) " +"VALUES (?,?,?)";
try
{
JSONArray jsonArray = accObj;
int size = jsonArray.length();
Statement st = db.createStatement(sqlStatement);
st.prepare();
for(int i =0 ; i<size ; i++)
{
JSONObject jsonObj = (JSONObject)jsonArray.getJSONObject(i);
String id = Global.EMPTY;
String name = Global.EMPTY;
String description = Global.EMPTY;
id = jsonObj.getString("id");
name = jsonObj.getString("name");
description = jsonObj.getString("description");
st.bind(1,id);
st.bind(2,name);
st.bind(3,description);
st.execute();
st.reset();
}
st.close();
Log.d("SQL", sqlStatement);
}
catch ( Exception e )
{
Log.e(e.getMessage());
} finally {
// close();
}
}
});
return value;
}
此代码一次插入 10-15 条记录,但之后我收到磁盘 I/O 错误。请让我知道为什么我会收到 I/O 错误。