Accessing an databases in concurrent threads

jda jda at his.com
Sun Mar 20 08:37:17 CST 2005


Hi Ruslan and everyone,

I am serving Valentina databases using RB. The sockets are threaded, 
so my app can respond asynchronously.

I keep an array of folderItems  of the databases that are open (I 
doing read only), and only close a database when all queries to it 
are complete (i.e. the array is empty)

The problem I'm having is that if a database is in use and another 
request comes in, I have to get acces to that database to do a query 
(again, read only, so no locked cursor problems). However, if I try 
to open a databas that is in use of course an exception is generated. 
I wonder what the best solution is?

I have thought of:

1. polling any open socket threads and setting "myDatabase" of the 
new thread to the "myDatabase" of a thread using the same folderItem

2. using a try/catch block when trying to open the database, and if 
it's a "file is open" error trying again (for,say, 60 seconds) until 
I either open the database or it times out.

Any thoughts/suggestions?

Thanks,

Jon


More information about the Valentina-beta mailing list