You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Jess Nielsen <je...@ementor.dk> on 2005/09/28 16:32:53 UTC

URGENT - Connecting to both Oracle and SqlServer - PLEASE HELP

Hi there

I'm trying to configure ibatis so it wil be using two different
databases (oracle and sqlserver) concurrently. I have been using several
hours on this without success and hope that some of you guys in here can
help me. The error I keep getting is the usual:
Spring.Objects.Factory.ObjectCreationException

The connection to the SQL Server is working out of the box, when the
Oracle configuration hasn't been added. As soon as I add the
configuration for the Oracle it will fail. Does anyone know how to
configure ibatis so the setup will work?

I hope for a soon reply on this.

Thanks in regards,
Jess

--- error ---
Error creating object with name 'ForbrugService' defined in 'file
[C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Presentation\ENST.ENSP
OP.Web\Spring\Forbrug.xml]' : Can't resolve reference to object
'DataAccessProvider' while setting property 'constructor argument'. 
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code. 

Exception Details: Spring.Objects.Factory.ObjectCreationException: Error
creating object with name 'ForbrugService' defined in 'file
[C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Presentation\ENST.ENSP
OP.Web\Spring\Forbrug.xml]' : Can't resolve reference to object
'DataAccessProvider' while setting property 'constructor argument'.

Source Error: 


Line 85: 			try
Line 86: 			{
Line 87: 				return
Ementor.ApplicationBlocks.ComponentFramework.ServiceLocator.GetObject(na
me);
Line 88: 			}
Line 89: 			catch (Exception ex)
 

Source File:
C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Framework\ENST.ENSPOP.F
ramework\ServiceLocator.cs    Line: 87 

Stack Trace: 


[ObjectCreationException: Error creating object with name
'ForbrugService' defined in 'file
[C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Presentation\ENST.ENSP
OP.Web\Spring\Forbrug.xml]' : Can't resolve reference to object
'DataAccessProvider' while setting property 'constructor argument'.]
 
Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantia
teSingletons()
   Spring.Context.Support.AbstractApplicationContext.Refresh()
   Spring.Context.Support.XmlApplicationContext..ctor(String[]
configurationLocations)
 
Ementor.ApplicationBlocks.ComponentFramework.ServiceConfig.GetInstance()
 
Ementor.ApplicationBlocks.ComponentFramework.ServiceLocator.GetObject(St
ring name)

[ApplicationException: Error getting object
'AuthenticationManagerService']
 
Ementor.ApplicationBlocks.ComponentFramework.ServiceLocator.GetObject(St
ring name)
   ENST.ENSPOP.Framework.ServiceLocator.GetFacadeObject(String name) in
C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Framework\ENST.ENSPOP.F
ramework\ServiceLocator.cs:87

[SystemErrorException: Error getting object
'AuthenticationManagerService']
   ENST.ENSPOP.Framework.ServiceLocator.GetFacadeObject(String name) in
C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Framework\ENST.ENSPOP.F
ramework\ServiceLocator.cs:91
   ENST.ENSPOP.Framework.ServiceLocator.AuthenticationManagerService()
in
C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Framework\ENST.ENSPOP.F
ramework\ServiceLocator.cs:74
   ENST.ENSPOP.Web.Global.Application_AuthenticateRequest(Object sender,
EventArgs e) in
C:\Projects\ENSPOP\Source\Assemblies\ENST.ENSPOP\Presentation\ENST.ENSPO
P.Web\Global.asax.cs:54
 
System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionS
tep.Execute()
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)
--- error ---
 

For the setup I'm using the following configuration files, where each
file has its own snippet below.


--- dao.config ---
<?xml version="1.0" encoding="utf-8"?>
<daoConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DaoConfig.xsd">
		
	<context id="SqlMapDao" default="true">
	
		<daoSessionHandler id="SqlMap">
			<property name="sqlMapConfigFile"
value="SqlMap.config"/>
			<property name="oracleMapConfigFile"
value="OracleMap.config"/>
		</daoSessionHandler>
	
		<database>
			<provider name="sqlServer1.1"/>	
			<dataSource name="SqlServer"
connectionString="data source=HOST;database=DB;user
id=USER;password=PASS;"/>
		</database>	
		
		<database>
			<provider name="oracleClient1.0"/>	
			<dataSource name="OracleServer"
connectionString="Data Source=SERVICE;User
Id=USER;Password=PASS;Integrated Security=no;" />
		</database>	
			
		<daoFactory/>
	</context>
	
</daoConfig>
--- dao.config ---

--- providers.config ---
<?xml version="1.0" encoding="utf-8" ?> 
<providers>
	<clear/>
	
	<provider
		name="sqlServer1.1"
		default="true"
		assemblyName="System.Data, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
		connectionClass="System.Data.SqlClient.SqlConnection"
		commandClass="System.Data.SqlClient.SqlCommand"
		parameterClass="System.Data.SqlClient.SqlParameter"
		parameterDbTypeClass="System.Data.SqlDbType"
		parameterDbTypeProperty="SqlDbType"
		dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
	
commandBuilderClass="System.Data.SqlClient.SqlCommandBuilder"	
		usePositionalParameters = "false"	
		useParameterPrefixInSql = "true"
		useParameterPrefixInParameter = "true"

		parameterPrefix="@"
	/>

	<provider 
		name="oracleClient1.0" 
		description="MS Oracle provider V1.0.5"
		enabled="true" 
		default="true"
		assemblyName="System.Data.OracleClient,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
	
connectionClass="System.Data.OracleClient.OracleConnection"  
		commandClass="System.Data.OracleClient.OracleCommand" 
	
parameterClass="System.Data.OracleClient.OracleParameter" 
	
parameterDbTypeClass="System.Data.OracleClient.OracleType" 
		parameterDbTypeProperty="OracleType" 
	
dataAdapterClass="System.Data.OracleClient.OracleDataAdapter" 
	
commandBuilderClass="System.Data.OracleClient.OracleCommandBuilder" 
		usePositionalParameters = "false" 
		useParameterPrefixInSql = "true" 
		useParameterPrefixInParameter = "false" 
		parameterPrefix=":" 
	/>

</providers>
--- providers.config ---	

--- OracleMap.config ---
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">

	<settings>
		<setting useStatementNamespaces="false"/>
		<setting cacheModelsEnabled="false"/>
	</settings> 

	<database>
		<provider name="oracleClient1.0"/>	
		<dataSource name="OracleServer" connectionString="not in
use, see dao.config for connectionstring" />
	</database>	
	

	<sqlMaps>
		<sqlMap resource="DBMaps/ScantidMap.xml" />
	</sqlMaps>
	
</sqlMapConfig>
--- OracleMap.config ---


--- ScantidMap.xml ---
<?xml version="1.0" encoding="utf-8" ?> 

<sqlMap namespace="Import"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="SqlMap.xsd">

	<alias>
		<typeAlias alias="ForbrugtTimer"
assembly="ENST.ENSPOP.Import.Domain.dll"
type="ENST.ENSPOP.Import.Domain.ForbrugtTimer" />		
	</alias>	

	<statements>
			<select id="SletAlleTable1">
				DELETE FROM TABLE1 
			</select>		
	</statements>

</sqlMap>
--- ScantidMap.xml ---


Re: URGENT - Connecting to both Oracle and SqlServer - PLEASE HELP

Posted by Ron Grabowski <ro...@yahoo.com>.
Your dao.config file should look more like this:

<?xml version="1.0" encoding="utf-8"?>
<daoConfig
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DaoConfig.xsd">
 <context id="SqlServer">
  <daoSessionHandler id="SqlMap">
   <property name="sqlMapConfigFile" value="SqlMap.config"/>
  </daoSessionHandler>
  <database>
   <provider name="sqlServer1.1"/>	
   <dataSource name="SqlServer"
connectionString="data source=HOST;database=DB;user
id=USER;password=PASS;"/>
   </database>	
   <daoFactory>
    <!-- you need add dao nodes to map interfaces with implementations
-->
   </daoFactory>
 </context>
 <context id="Oracle">
  <daoSessionHandler id="SqlMap">
   <property name="sqlMapConfigFile" value="OracleMap.config"/>
  </daoSessionHandler>
  <database>
   <provider name="oracleClient1.0"/>	
   <dataSource name="OracleServer"
connectionString="Data Source=SERVICE;User
Id=USER;Password=PASS;Integrated Security=no;" />
  </database>	
  <daoFactory>
   <!-- you need add dao nodes to map interfaces with implementations
-->
  </daoFactory>
 </context>
</daoConfig>

You request a specific dao using its context id:

 DaoManager sqlServerDaoManager = DaoManager.GetInstance("SqlServer");
 DaoManager oracleDaoManager = DaoManager.GetInstance("Oracle");

You need to add dao nodes to your daoFactory nodes so you can request
interfaces from the dao manager object:

 IUserDao userDao = (IUserDao)oracleDaoManager[typeof(IUserDao)];
 IList users = userDao.GetMany();

In your provider.config file, having two provider nodes each marked
with:

 default="true"

may cause problems.

In OracleMap.config, the database node:

 <database>
  <provider name="oracleClient1.0"/>	
  <dataSource name="OracleServer" connectionString="..." />
 </database>	

is ignored when using dao objects so you can comment it out or remove
it.

I would verify that IBatisNet is working the way you want before trying
to integrate it with Spring.
	
--- Jess Nielsen <je...@ementor.dk> wrote:

> Hi there
> 
> I'm trying to configure ibatis so it wil be using two different
> databases (oracle and sqlserver) concurrently. I have been using
> several
> hours on this without success and hope that some of you guys in here
> can
> help me. The error I keep getting is the usual:
> Spring.Objects.Factory.ObjectCreationException
> 
> The connection to the SQL Server is working out of the box, when the
> Oracle configuration hasn't been added. As soon as I add the
> configuration for the Oracle it will fail. Does anyone know how to
> configure ibatis so the setup will work?
> 
> I hope for a soon reply on this.
> 
> Thanks in regards,
> Jess