03-28-2012 08:01 AM
Hi All,
My snippet is:
Statement mstatement = null;
URI uri = URI.create(DBPath);
sqliteDb = DatabaseFactory.openOrCreate(uri);
mStatement = sqliteDb.createStatement(strQuery);
mStatement.prepare();
My problem is, I am getting error as "Sqlite pendingOperation" at mstatement.prepare();.
Please tell me why I am getting this and how to remove it.
Thanks
Ankit
Solved! Go to Solution.
03-30-2012 12:13 AM
Hi,
Respond to my post.
Thanks,
Ankit
04-10-2012 11:13 AM
I don't see an issue with the code snippet above. Are you access the database concurrently in multiple threads and/or preparing the statement in multiple locations simultaneously?
04-11-2012 12:12 AM
Yes Mark,
I am accessing database from multiple threads. Sometimes code runs fine and sometimes it ocurs any problem.
Thanks,
Ankit
04-11-2012 10:15 AM
Are you sharing statement across threads? If so that is likely the cause.
04-12-2012 03:01 AM
Yes, but please tell me any solution to solve it.
One more thing, I am using synchronized lock of global object for each block where I am opening and closing database.
Thank,
Ankit
04-12-2012 11:26 AM
How frequently are you opening and closing the database? Is it happening in rapid succession? It may be better to open/close once when you application starts and ends.
04-12-2012 11:48 PM
No, I think you are not right. It is not an efficient method to open or close at once only.
Because it is creating 1 journal file at the location of db file, and we are not able to access anything from database.
ankit
04-18-2012 12:25 AM
Hi, Please give me appropriate so that I can apply it to my application.
I am using synchronized blocks at each and every database handling methods. This is happening while multiple threads are running.
Thanks,
Ankit
04-20-2012 09:21 AM
Hi,
I got answer by myself.:Rockon::Rockon: Cursor c =null;
DBHelper.mStatement =null;
Vector followups =newVector();
**boolean runFlag =true;**
synchronized(GlobalVariables.lockObject){
try{
**while(runFlag)**
SELECT EventId,OldTitle,OrderNumber,Status,Title,Type,UpdateDateTime,Id FROM Questions WHERE EventId=5 AND Type=1 AND (Status=0 OR Status=1 OR Status=2) ORDER BY OrderNumber
DBHelper.CreateAndOpenSqliteDBConnection();
DBHelper.mStatement =DBHelper.sqliteDb.createStatement(strQuery);
DBHelper.mStatement.prepare();
**if(DBHelper.mStatement ==null)
{
DBHelper.CloseSqliteDBConnection();
runFlag =true;
continue;
}
else
{
runFlag =false;
}**
c =DBHelper.mStatement.getCursor();
while(c.next()){
followups.addElement(Followup.getFromCursor(c));
}
}
**}**
catch(Exception ex){
System.out.print(ERRORSTRING +"getUploadFollowupsFromDB: "
+ ex);
}finally{
DBHelper.CloseSqliteDBConnection();
}
GlobalVariables.lockObject.notifyAll();
}
return followups;
Added stared code in all methods.