ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kaushal Chandrashekar" <kaus...@vcasel.com>
Subject Problem using SqlMapper.OpenConnection(string connectionstring)
Date Wed, 06 Sep 2006 19:08:44 GMT
Hi All,
    I'm using the .NET Ibatis 1.3.0.0 DLL where I can open a connection
using a connection string not from the SqlMap.config ( Brilliant
improvement, by the way!) . The code that I'm using is as follows:

       		using (IDalSession session =
Mapper.Instance().OpenConnection(connectionString))
			{
				result =
Mapper.Instance().QueryForList("SelectNextStaffPersonal",
staffPersonalCombo);
			}
This section of code is called periodically within a method that returns
staff personal information from the DB. I also have other methods that
use regular ADO.NET to perform SQL queries. 
I was running a test where once I run my software, and turn off the SQL
Server. As expected, I get exceptions, but I keep the service running
after logging errors as I want to not kill the service on database
failures, but keep retrying. Once I turn the database back on, the
regular SQL queries return data but the Ibatis queries return the
following error:
IBatisNet.DataMapper.Exceptions.DataMapperException: SqlMap could not
invoke OpenConnection(). A connection is already started. Call
CloseConnection first.
   at IBatisNet.DataMapper.SqlMapper.OpenConnection(String
connectionString)
<Rest of stack trace within my application>

I took a look at the DLL disassembled using .NET reflector and the
problem is at the following:

      if (this._sessionHolder.LocalSession != null)
      {
            throw new DataMapperException("SqlMap could not invoke
OpenConnection(). A connection is already started. Call CloseConnection
first.");
      }
      SqlMapSession session1 = new SqlMapSession(this);
      this._sessionHolder.Store(session1);
      session1.OpenConnection(connectionString);
      return session1;

The LocalSession does not seem to become null, if there is a
communication failure with the server. Am I doing something wrong? Is
there a way to make the localsession null? Please help.  
Thanks in advance,
Kaushal


Mime
View raw message