ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Separate Database Connections on Different Threads
Date Mon, 13 Feb 2006 23:46:33 GMT
Have you tried creating two SqlMapper objects and using each one in a
seperate thread?

 // first thread
 SqlMapper sqlMap1 = createSqlMap("SqlMap1.config");
 IDataImporterDao dataImporterDao = new DataImporterDao(sqlMap1);

 // second thread
 SqlMapper sqlMap2 = createSqlMap("SqlMap2.config");
 IDataImporterDao dataImporterDao = new DataImporterDao(sqlMap2);

Maybe you could use DataAccess' DaoManager to define two context and
use each context on its own thread:

 // first thread 
 DataManager thread1Manager = DaoManager.GetContext("Thread1"); 
 IDataImporterDao dataImportDao = thread1Manager.GetDao(
  typeof(IDataImporterDao)) as IDataImporterDao;

 // second thread
 DataManager thread2Manager = DaoManager.GetContext("Thread2");
 IDataImporterDao dataImportDao = thread2Manager.GetDao(
  typeof(IDataImporterDao)) as IDataImporterDao;

--- Shawn Smiley <ssmiley483@yahoo.com> wrote:

> Is it possible to have one set of iBatis objects use different
> database connections on different threads?
> My specific case is that I have a data import app running as a
> Windows Service.  I have one thread that handles the actual data
> import of around 4000 records (within a single transaction) that
> periodically raises events to the main service thread that
> periodically updates a job queue table with the current status of the
> import process.
> What's currently happening is that I get an initial status message
> written to the database and then no other status messages make it to
> the DB until the import transaction completes.  I'm not sure if the
> status updates are being included in the transaction or not.  I need
> them to be completely independent of the import Transaction.  
> I know that the status messages are being picked up by the service
> from the logging I'm doing (I see every status event in the logs).
> Is what I'm trying to do possible and if so, what can I do to make
> this work?
> Thanks,
> Shawn
> ---------------------------------
> Relax. Yahoo! Mail virus scanning helps detect nasty viruses!

View raw message