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

Native Development

Reply
Developer
i68040
Posts: 59
Registered: ‎02-05-2012
My Device: Q10
My Carrier: T-Mobile
Accepted Solution

SqlDataAccess Threading

I've been using SqlDataAccess to insert into / query from an SQLite database. Everything was working fine until I added Threads into the mix. Does anyone know if SqlDataAccess is threadsafe?

 

I see messages indicating that removeDatabase is being run when none of my code calls that:

 

Jan 9 09:54:14.352 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  QSqlDatabasePrivate::removeDatabase: connection '/accounts/1000/appdata/com.rubion.NetScanner.testDev__NetScanner8e1fec
79/app/native/assets/Databases/NetScanner.sq3' is still in use, all queries will cease to work.
Jan 09 09:54:14.352 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  QSqlDatabasePrivate::addDatabase: duplicate connection name '/accounts/1000/appdata/com.rubion.NetScanner.testDev__NetS
canner8e1fec79/app/native/assets/Databases/NetScanner.sq3', old connection removed.
Jan 09 09:54:14.411 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  Unsupported query type: 0
Jan 09 09:54:14.439 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  Unsupported query type: 0
Jan 09 09:54:14.524 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  Unsupported query type: 0
Jan 09 09:54:14.612 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  QSqlDatabasePrivate::removeDatabase: connection '/accounts/1000/appdata/com.rubion.NetScanner.testDev__NetScanner8e1fec
79/app/native/assets/Databases/NetScanner.sq3' is still in use, all queries will cease to work.
Jan 09 09:54:14.612 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  QSqlDatabasePrivate::addDatabase: duplicate connection name '/accounts/1000/appdata/com.rubion.NetScanner.testDev__NetS
canner8e1fec79/app/native/assets/Databases/NetScanner.sq3', old connection removed.
Jan 09 09:54:32.515 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default      0  LGM - The call to counters_register in LGMon failed at time = 786795746110662 ns with error -5.
Jan 09 09:54:44.845 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  QSqlDatabasePrivate::removeDatabase: connection '/accounts/1000/appdata/com.rubion.NetScanner.testDev__NetScanner8e1fec
79/app/native/assets/Databases/NetScanner.sq3' is still in use, all queries will cease to work.
Jan 09 09:54:44.845 com.rubion.NetScanner.testDev__NetScanner8e1fec79.387170505              default   9000  QSqlDatabasePrivate::addDatabase: duplicate connection name '/accounts/1000/appdata/com.rubion.NetScanner.testDev__NetS
canner8e1fec79/app/native/assets/Databases/NetScanner.sq3', old connection removed.

 

The App hangs for a few seconds, then I see this in the console tab:

 

Process 387170505 (NetScanner) terminated SIGSEGV code=1 fltno=11 ip=781d71be(/base/usr/lib/qt4/lib/libQtSql.so.4.8.4@_ZN10QSqlResult19detachFromResultSetEv+0x9) mapaddr=000171be. ref=00000000 bdslot=1

 

Any ideas?

Please use plain text.
Developer
hakimrie
Posts: 82
Registered: ‎07-23-2009
My Device: 9900
My Carrier: XL

Re: SqlDataAccess Threading

afaik, it is not threadsafe; as workaround you can use sqlworker to query database, ie. 

m_pSqlWorker = new SqlWorker(databasepath, mConnectionName, this);
m_pSqlConnection = new SqlConnection(m_pSqlWorker, this);

 with different connection name for every different operation. 

 

cmiiw

Please use plain text.
Developer
i68040
Posts: 59
Registered: ‎02-05-2012
My Device: Q10
My Carrier: T-Mobile

Re: SqlDataAccess Threading

Thanks for the tip!

Please use plain text.