Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel
Accepted Solution

Sqlite pendingOperation in Statement prepare

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

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Sqlite pendingOperation in Statement prepare

Hi,

Respond to my post.

 

Thanks,

 

Ankit

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sqlite pendingOperation in Statement prepare

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?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Sqlite pendingOperation in Statement prepare

Yes Mark,

I am accessing database from multiple threads. Sometimes code runs fine and sometimes it ocurs any problem.

 

Thanks,

Ankit

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sqlite pendingOperation in Statement prepare

Are you sharing statement across threads?  If so that is likely the cause.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Sqlite pendingOperation in Statement prepare

 

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

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sqlite pendingOperation in Statement prepare

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.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Sqlite pendingOperation in Statement prepare

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

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Sqlite pendingOperation in Statement prepare

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

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Sqlite pendingOperation in Statement prepare

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.
Please use plain text.