Hi budy,

I found a uncoved path that will raise an exception when you have dataSource section in dao.config but not defined in SqlMap.config.

public PreparedStatement Prepare()

{

_preparedStatement = new PreparedStatement();

_parameterPrefix = _session.DataSource.Provider.ParameterPrefix;  //here an exception will raise because _session.DataSource is null.

 

In IBatisNet.DataMapper.Configuration.DomSqlMapBuilder

private static SqlMapper Initialize()

{

Line 274

#region Load the DataSources

XmlNode nodeDataSource = _sqlMapConfig.SelectSingleNode("/sqlMapConfig/database/dataSource");

if (nodeDataSource == null)

{

if (_isCallFromDao == false)

{

throw new ConfigurationException("There's no dataSource tag in SqlMap.config.");

}

else  /// Uncoverd path

{

sqlMap.DataSource = _dataSource;

}

}

else

{

if (_isCallFromDao == false)

{

XmlSerializer serializer = null;

serializer = new XmlSerializer(typeof(DataSource));

DataSource dataSource = (DataSource) serializer.Deserialize(new XmlNodeReader(nodeDataSource));

dataSource.Provider = provider;

// Use Global Properties if any

dataSource.ConnectionString = Resources.ParsePropertyTokens(dataSource.ConnectionString, _properties);

sqlMap.DataSource = dataSource;

}

else

{

sqlMap.DataSource = _dataSource;

}

}

#endregion

}

Luke L.M. Yang
Software Architect/Applications Developer
Sanjel Corporation
500, 622 - 5th Ave S.W.
Calgary, Alberta, Canada T2P 0M6
Phone: (403) 269-1420
Fax: (403) 269-1433
http://www.sanjel.com

 

Reply via email to