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
New Developer
Posts: 5
Registered: ‎05-07-2012
My Device: 9780
My Carrier: vodafone

DatabaseException: Attempt to writ read only database in syncing application

Hi

     I am writing a syncing application. where we are auto syncing from centralised db, Recently we got " Attempt to writ read only database in syncing application".Rarely we are getting this error.Not able to get exact scenario. I went through following link but not able to find the reason.

"http://supportforums.blackberry.com/t5/Java-Development/DatabaseException-attempt-to-write-a-readonl...". Bellow I am giving my code snippet.

Could any body help me out..

 

 

 

 FileSystemUtil.createDBFile(dbname + DBUtil.DB_FILENAME_EXTENSION);
            fc = (FileConnection) Connector.open(getFullDBLocation(dbname));

if (fc.exists() && fc.fileSize() == 0) {

  writeData();

}else{

 

 db = DatabaseFactory.open(DBUtil.getURI(dbname));
                            db.beginTransaction();

 st = db.createStatement(sql);
            st.prepare();
            st.execute();

db.commitTransaction();

}

 

finally{

fc.close();

    DBUtil.closeStatement(st);
            DBUtil.closeDatabase(db);

}

 

BlackBerry Development Advisor
Posts: 15,089
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: DatabaseException: Attempt to writ read only database in syncing application

Where is the database stored?  It's recommended to close connections in the opposite order they were opened, with proper exception handling.  Refer to this article:  Close connections

 

Is the database being used by multiple applications and/or threads?

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
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: DatabaseException: Attempt to writ read only database in syncing application

Hi

 

Try this one:

 

/****************************************************************************************************************/

(FileConnection)Connector.open(getFullDBLocation(dbname),Connector.READ_WRITE);

 

/****************************************************************************************************************/

Excute this line after creating your statment. Use thise for statment simultaneously. 

 

str.prepare();

st.execute();
st.close();
db.close();

This may be the reason: So. let try it.