ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Bayon <ibatis....@gmail.com>
Subject Re: Set ConnectionString per Thread/CallContext
Date Wed, 01 Feb 2006 19:46:37 GMT
It depends which version of iBTAIS you used, but there must be a method

OpenConnection(string connectionString) on the SqlMapper or the DaoManager

Remarks : In Future version, you will be able to plug a custom
DataSource (which
implement IDataSource) on the SqlMapper and so do what you want, the
method OpenConnection(string connectionString)... will certainly be removed.

The custom DataSource will build the connectionstring base on the
thread/callcontext setting, this will solve your problem.

The current version in SVN already used an IDataSource and so you could used
what I said.
I expect that I answer your question

On 2/1/06, Michael Schall <mike.schall@gmail.com> wrote:
> I need to be able to have a map switch which database server it is
> hitting for certain queries.  I have this working however it is not a
> per thread/callcontext setting.  It changes it for the map so each
> thread will start using a the changed setting.  Is there a workaround
> for this?
> My code looks like this
> --- use ---
>        Dim mapper As SqlMapper = DatabaseManager.Instance()
>        mapper.DataSource.ConnectionString =
> connectionString.ConnectionString
>        mapper.QueryWithRowDelegate(...)
> --- configure --
>        Public Sub Configure(ByVal configurationFile As FileInfo)
>                Dim builder As DomSqlMapBuilder = New DomSqlMapBuilder()
>                _mapper = builder.Configure(configurationFile)
>        End Sub
>        Friend Function Instance() As SqlMapper
>                Dim mapper As SqlMapper
>                SyncLock (_lock)
>                        mapper = _mapper
>                End SyncLock
>                Return mapper
>        End Function

View raw message