大家好我有一个多插入语句的问题,我需要插入很多records.i已经用这种方式写入,但记录没有插入到“userbill”表中。帮我??sqlite中的多个插入语句android
..这里是代码:
SQLiteDatabase db = mySQLiteHelper.getWritableDatabase();
String sql = "insert into userbill (billid, userid, date, amount, bill_status) values (?, ?, ?, ?, ?)";
db.beginTransaction();
SQLiteStatement st = db.compileStatement(sql);
try{
for(int i=0;i<Userid.length;i++)
{
st.bindLong(1, billid);
st.bindString(2, Userid[i]);
st.bindString(3, due_date);
st.bindDouble(4, amount/Userid.length);
st.bindString(5, "Due");
long entryID = st.executeInsert();
st.clearBindings();
}
db.setTransactionSuccessful();
}
catch(Exception e)
{
//e.printStackTrace();
Log.e("MYAPP", "exception", e);
}
finally
{
db.endTransaction();
}
db.close();
logcat的:
09-05 13:12:48.610:d/dalvikvm(7982):GC_FOR_ALLOC释放314K,10%的游离5030K/5568K中,暂停17MS,总时间18ms
09-05 13:12:48.610:I/dalvikvm堆(7982):生长堆(FRAG情况下),以用于6.181MB 1127532字节分配
09-05 13 :12:48.614:D/dalvikvm(7982):GC_FOR_ALLOC免费d 2K,9%的游离6129K/6672K,暂停5ms的,总5ms的
09-05 13:12:48.710:W/EGL_genymotion(7982):eglSurfaceAttrib没有实现
09-05 13:12:57.014 :I/SQLiteConnectionPool(7982):/data/data/com.perfect12.app2maintain/databases/AMTDB的连接池已关闭,但仍有1个连接正在使用。他们将被释放回泳池后关闭。
09-05 13:12:57.286:W/EGL_genymotion(7982):eglSurfaceAttrib没有实现
任何类型的错误消息?你可以发布logcat吗? – Opiatefuchs 2014-09-05 13:54:36
感谢您的回复,但没有收到任何错误。 – Anil 2014-09-05 14:04:50
尝试删除“;”在声明字符串中的声明中,并确保UserId不是0 .. – Opiatefuchs 2014-09-05 14:14:24