View Full Version : DB2 provider config anyone?
CNemo7539
06-23-2007, 02:54 AM
I will really appreciate if somebody can share DB2 provider xml.
Basically I've created one myself and it's fine for the moment, but I don't know which codes to map and how. So, I'm mostly interested in this part.
Thanks before hand!
Bruno Baia
06-25-2007, 12:32 AM
Hi,
You should post your provider.xml to share with us.
Thanks,
Bruno
CNemo7539
06-25-2007, 03:15 PM
Here you go!
I've included link to the IBM page with codes, so it will be easy to add them if nesessary.
Present codes are taken from PostrgreSQL config, because they are the same, but DB2 has a lot more.
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns='http://www.springframework.net'>
<object id="DB2Provider" type="Spring.Data.Common.DbProvider, Spring.Data" singleton="false">
<constructor-arg name="DbMetaData">
<object type="Spring.Data.Common.DbMetadata, Spring.Data">
<constructor-arg name="productName" value="IBM.Data.DB2"/>
<constructor-arg name="assemblyName" value="IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="connectionType" value="IBM.Data.DB2.DB2Connection, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="commandType" value="IBM.Data.DB2.DB2Command, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="parameterType" value="IBM.Data.DB2.DB2Parameter, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="dataAdapterType" value="IBM.Data.DB2.DB2DataAdapter, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="commandBuilderType" value="IBM.Data.DB2.DB2CommandBuilder, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="commandBuilderDeriveParametersMethod" value="DeriveParameters"/>
<constructor-arg name="parameterDbType" value="IBM.Data.DB2.DB2Type, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="parameterDbTypeProperty" value="DB2Type"/>
<constructor-arg name="parameterIsNullableProperty" value="IsNullable"/>
<constructor-arg name="parameterNamePrefix" value="@"/>
<constructor-arg name="exceptionType" value="IBM.Data.DB2.DB2Exception, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="useParameterNamePrefixInParameterCollection" value="true"/>
<constructor-arg name="bindByName" value="true"/>
<!-- this is only true for .net 1.1 kept it here just in case we want to revert back to this strategy for
obtaining error codes-->
<constructor-arg name="errorCodeExceptionExpression" value="Errors[0].SQLState"/>
<!-- error codes taken from http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzala/rzalaco.htm -->
<!-- error codes taken from http://www.postgresql.org/docs/8.1/static/errcodes-appendix.html -->
<property name="ErrorCodes.badSqlGrammarCodes">
<value>42000,42601,42602,42622,42804</value>
</property>
<property name="ErrorCodes.DataAccessResourceFailureCodes">
<value>53000,53100,53200,53300</value>
</property>
<property name="ErrorCodes.DataIntegrityViolationCodes">
<value>23000,23502,23503,23505,23514</value>
</property>
<property name="ErrorCodes.CannotAcquireLockCodes">
<value>55005,55006,55007,55018,55050</value>
</property>
<property name="ErrorCodes.DeadlockLoserCodes">
<value>57033</value>
</property>
</object>
</constructor-arg>
</object>
<alias name="DB2Provider" alias="IBM.Data.DB2"/>
</objects>
Mark Pollack
06-26-2007, 04:29 PM
Hi,
Thanks for this contribution, it is greatly appreciated. I made a few changes, notably using Errors[0].NativeError instead of SQLState since it can be more vendor specific/detailed. (This corresponds to the documented SQLCODE afaik). The error codes listed are those found in the Spring Java file sql-error-codes.xml.
I've added 4 provider names, they are the following
IBM.Data.DB2-9.0.0.1 - DB 9.0.0 .NET 1.1
IBM.Data.DB2-9.0.0.2 - DB 9.0.0 .NET 2.0
IBM.Data.DB2-9.1.0.1 - DB 9.1.0 .NET 1.1
IBM.Data.DB2-9.1.0.2 - DB 9.1.0 .NET 2.0
I don't have DB2 installed so if you could try it out from the latest build, I'd appreciate it. I've attached the latest file in anycase.
Cheers,
Mark
CNemo7539
07-02-2007, 02:46 PM
Mark,
I cannot see attached file.
Mark Pollack
07-02-2007, 02:51 PM
Hi,
I forgot to attach it, 2nd attempt... ;) You can also download the latest builds to pick it up.
I've renamed them a bit, you can find the names on the updated doc (http://www.springframework.net/doc-latest/reference/html/dbprovider.html) page.
Cheers,
Mark
CNemo7539
07-02-2007, 09:00 PM
Seems working to me, though I didn't perform any testing.
That will be great if doc explain all naming schemas for aliases and error codes conversion in a little bit more details.
Thanks to great work guys!
sureshn
07-31-2007, 04:53 PM
I downloaded the latest version on Sprint.NET 1.1M2. And trying to connect to DB2 database using DB2-9.0.0-2.0 in my XML configuration. And i am getting following error. Am i missing something? Do i need any other file? Please Help.
Error occured System.Configuration.ConfigurationErrorsException: Error instantiating context 'spring.root'.
---> Spring.Objects.FatalObjectException: Cannot instantiate Type [Spring.Context.Support.XmlApplicationContext] using ctor [Void .ctor(System.String, Boolean, System.String[])] :
'Exception has been thrown by the target of an invocation.' ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Spring.Objects.Factory.ObjectCreationException: Error creating object with name '' : IFactoryObject threw exception on object creation. ---> Spring.Objects.Factory.UnsatisfiedDependencyExcept ion: Error thrown by a dependency of object 'DB2-9.0.0-2.0' definedin 'assembly [Spring.Data, Version=1.1.0.2, Culture=neutral, PublicKeyToken=65e4
74d141e25e07], resource [Spring.Data.Common.dbproviders.xml]' : Unsatisfied dependency expressed through constructor argument with index 2 of type [System.Type]
: Could not convert constructor argument value [IBM.Data.DB2.DB2Connection, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208] to required type [System.Type] : Cannot convert property value of type [System.String] to required type [System.Type] for property ''.
while resolving 'constructor argument with name dbmetadata' to '(inner object)' defined in 'assembly [Spring.Data, Version=1.1.0.2, Culture=neutral, PublicKeyToken=65e474d141e25e07], resource [Spring.Data.Common.dbproviders.xml]'
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ResolveInnerObjectDefinition(Str ing name, String innerObjectName, String argumentName, IObjectDefinition definition, Boolean singletonOwner)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ResolveValueIfNecessary(String name, RootObjectDefinition definition, String argumentName, Object argumentValue)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ResolveConstructorArguments(Stri ng name, RootObjectDefinition definition, ConstructorArgumentValues resolvedValues)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.AutowireConstructor(String name, RootObjectDefinition definition, ConstructorArgumentValues argumentValues)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.AutowireConstructor(String name, RootObjectDefinition definition)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.CreateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.CreateObject(String name, RootObjectDefinition definition, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Type requiredType, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Type requiredType)
at Spring.Context.Support.AbstractApplicationContext. GetObject(String name, Type requiredType)
at Spring.Data.Common.DbProviderFactory.GetDbProvider (String providerInvariantName)
at Spring.Data.Common.DbProviderFactoryObject.GetObje ct()
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObjectForSharedInstance(String name, Object instance)
--- End of inner exception stack trace ---
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObjectForSharedInstance(String name, Object instance)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Type requiredType, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name)
at Spring.Objects.Factory.Support.DefaultListableObje ctFactory.PreInstantiateSingletons()
at Spring.Context.Support.AbstractApplicationContext. Refresh()
at Spring.Context.Support.XmlApplicationContext..ctor (Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations)
at Spring.Context.Support.XmlApplicationContext..ctor (String name, Boolean caseSensitive, String[] configurationLocations)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeConstructor(Obje ct[] args, SignatureStruct& signature, IntPtr declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(Objec t[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(Bi ndingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Object[] arguments)
--- End of inner exception stack trace ---
at Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Object[] arguments)
at Spring.Context.Support.ContextHandler.RootContextI nstantiator.InvokeContextConstructor(ConstructorIn fo ctor)
at Spring.Context.Support.ContextHandler.ContextInsta ntiator.InstantiateContext()
--- End of inner exception stack trace ---
at System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecordsectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey,Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey)
at System.Configuration.ClientConfigurationSystem.Sys tem.Configuration.Internal.IInternalConfigSystem.G etSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSecti on(String sectionName)
at Spring.Util.ConfigurationUtils.GetSection(String sectionName)
at Spring.Context.Support.ContextRegistry.InitializeC ontextIfNeeded()
at Spring.Context.Support.ContextRegistry.GetContext( )
Mark Pollack
07-31-2007, 08:37 PM
Hi,
I belive this maybe as simple as including the DB2 assembly in the runtime directory, should be named IBM.Data.DB2.9.0.0.dll (IDBM.Data.DB@.9.0.0.dll) based on the naming scheme I see for the 9.1 version which is what I tested with.
Cheers,
Mark
sureshn
08-02-2007, 06:35 PM
I tried that and now i am getting following error. Is the name in App.Config should exactly match the dll name? I tried both DB2-9.1.0.2 and DB2-9.0.0-2.0
target of an invocation.' ---> System.Reflection.TargetInvocationException: Ex
ception has been thrown by the target of an invocation. ---> Spring.Objects.Factory.ObjectCreationException: Error creating object with name '' : IFactoryObject
threw exception on object creation. ---> Spring.Objects.Factory.NoSuchObjectDefinitionExcep tion: No object named 'DB2-9.0.0-2.0' is defined : Cannot find definition for object [DB2-9.0.0-2.0]
Mark Pollack
08-02-2007, 07:31 PM
Hi,
I just tried it with DB2-9.0.0-2.0 and it worked fine with M2. Here is my simple config
<objects xmlns='http://www.springframework.net'
xmlns:db="http://www.springframework.net/database">
<db:dbProvider id="Db2Provider" provider="DB2-9.0.0-2.0" connectionString=""/>
</objects>
and added this code to the TxQuickStart example AccountManagerTests.cs
[Test]
public void Db2()
{
IDbProvider dbProvider = ctx["Db2Provider"] as IDbProvider;
Assert.IsNotNull(dbProvider);
Console.Out.WriteLine("Provider name = " + dbProvider.DbMetadata.ProductName);
}
and I get the the context created and the product name = IBM.Data.DB2
Can you post your configuration xml?
I almost feel like you don't have M2 or something. Very strange. With logging set to INFO level, you should see a line like this
2007/08/02 14:15:51:828 [INFO] Spring.Data.Common.DbProviderFactory - 17 DbProviders Available. [SqlServer-1.1,SqlServer-2.0,SqlServerCe-3.1,OleDb-1.1,OleDb-2.0,OracleClient-2.0,OracleODP-2.0,MySql,MySql-1.0.9,MySql-5.0,MySql-5.1,Npgsql-1.0,DB2-9.0.0-1.1,DB2-9.0.0-2.0,DB2-9.1.0-1.1,DB2-9.1.0.2,SQLite-1.0.43]
Can you make sure you are using M2? Take a look in the distribution directory under src\Spring\Spring.Data\Data\Common for the file dbproviders.xml and check inside. You can also look at the embedded resource directly using resharper.
Hope this helps.
Cheers,
Mark
sureshn
08-03-2007, 01:33 PM
Sorry, i was using M1. Changed to M2. And now i am getting a different error. I tried adding IBM.Data.DB2.ISeries to the reference. Also tried renaming. But nothing is working.
Here is the trace of the error.
Error occured System.Configuration.ConfigurationErrorsException: Error instantia
ting context 'spring.root'. ---> Spring.Objects.FatalObjectException: Cannot ins
tantiate Type [Spring.Context.Support.XmlApplicationContext] using ctor [Void .c
tor(System.String, Boolean, System.String[])] : 'Exception has been thrown by th
e target of an invocation.' ---> System.Reflection.TargetInvocationException: Ex
ception has been thrown by the target of an invocation. ---> Spring.Objects.Fact
ory.ObjectCreationException: Error creating object with name '' : IFactoryObject
threw exception on object creation. ---> Spring.Objects.Factory.UnsatisfiedDepe
ndencyException: Error thrown by a dependency of object 'IBM.Data.DB2' defined i
n 'assembly [Spring.Data, Version=1.1.0.2, Culture=neutral, PublicKeyToken=65e47
4d141e25e07], resource [Spring.Data.Common.dbproviders.xml]' : Unsatisfied depen
dency expressed through constructor argument with index 2 of type [System.Type]
: Could not convert constructor argument value [IBM.Data.DB2.DB2Connection, IBM.
Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208] to
required type [System.Type] : Cannot convert property value of type [System.Stri
ng] to required type [System.Type] for property ''.
while resolving 'constructor argument with name dbmetadata' to '(inner object)'
defined in 'assembly [Spring.Data, Version=1.1.0.2, Culture=neutral, PublicKey
Token=65e474d141e25e07], resource [Spring.Data.Common.dbproviders.xml]'
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Resolv
eInnerObjectDefinition(String name, String innerObjectName, String argumentName,
IObjectDefinition definition, Boolean singletonOwner)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Resolv
eValueIfNecessary(String name, RootObjectDefinition definition, String argumentN
ame, Object argumentValue)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Resolv
eConstructorArguments(String name, RootObjectDefinition definition, ConstructorA
rgumentValues resolvedValues)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Autowi
reConstructor(String name, RootObjectDefinition definition, ConstructorArgumentV
alues argumentValues)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Autowi
reConstructor(String name, RootObjectDefinition definition)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Create
Object(String name, RootObjectDefinition definition, Object[] arguments, Boolean
allowEagerCaching)
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.Create
Object(String name, RootObjectDefinition definition, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name
, Type requiredType, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name
, Type requiredType)
at Spring.Context.Support.AbstractApplicationContext. GetObject(String name, T
ype requiredType)
at Spring.Data.Common.DbProviderFactory.GetDbProvider (String providerInvarian
tName)
at Spring.Data.Common.DbProviderFactoryObject.GetObje ct()
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObjectForSharedIns
tance(String name, Object instance)
--- End of inner exception stack trace ---
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObjectForSharedIns
tance(String name, Object instance)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name
, Type requiredType, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name
, Object[] arguments)
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String name
)
at Spring.Objects.Factory.Support.DefaultListableObje ctFactory.PreInstantiate
Singletons()
at Spring.Context.Support.AbstractApplicationContext. Refresh()
at Spring.Context.Support.XmlApplicationContext..ctor (Boolean refresh, String
name, Boolean caseSensitive, IApplicationContext parentContext, String[] config
urationLocations)
at Spring.Context.Support.XmlApplicationContext..ctor (String name, Boolean ca
seSensitive, String[] configurationLocations)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeConstructor(Obje ct[] args, SignatureStru
ct& signature, IntPtr declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(Objec t[] args, SignatureStruc
t signature, RuntimeTypeHandle declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(Bi ndingFlags invokeAttr, B
inder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Ob
ject[] arguments)
--- End of inner exception stack trace ---
at Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Ob
ject[] arguments)
at Spring.Context.Support.ContextHandler.RootContextI nstantiator.InvokeContex
tConstructor(ConstructorInfo ctor)
at Spring.Context.Support.ContextHandler.ContextInsta ntiator.InstantiateConte
xt()
--- End of inner exception stack trace ---
at System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[] keys, Se
ctionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord
sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord factor
yRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boole
an getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String co
nfigKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Bool
ean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String co
nfigKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Bool
ean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String co
nfigKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Bool
ean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey,
Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey)
at System.Configuration.ClientConfigurationSystem.Sys tem.Configuration.Intern
al.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSecti on(String sectionName)
at Spring.Util.ConfigurationUtils.GetSection(String sectionName)
at Spring.Context.Support.ContextRegistry.InitializeC ontextIfNeeded()
at Spring.Context.Support.ContextRegistry.GetContext( )
Mark Pollack
08-03-2007, 02:57 PM
Hi,
It looks like that the type listed in the error message can not be resolved.
Can you run the following code before you create your context.
Console.WriteLine(typeof (DB2Connection).Assembly.FullName);
I get
IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208
which is the same as from creating the DbProviderFactory's application context with the code.
IDbProvider db2Provider = DbProviderFactory.ApplicationContext.GetObject("DB2-9.0.0-2.0") asIDbProvider;
Console.WriteLine(db2Provider.DbMetadata.Connectio nType.Assembly.FullName);
The above code is the minimum needed to resolve this problem. I hope we can get to the bottom of this soon. Thanks for your patience.
Mark
sureshn
08-03-2007, 05:19 PM
Thanks Mark,
I think the issue is that i am using 10.0.0.0 version of IBM.Data.DB2.ISeries.dll
It has only iDB2Connection class. Do you think this is the issue? If so, is there way to make this work with Version 10.0.0.0? I am unable to get the version 9 dll.
Suresh.
Mark Pollack
08-03-2007, 05:48 PM
Hi,
Yes it certainly is the issue, the assembly name is different, and possibly other things as well. I didn't see a place to easily download that .dll. Can you email it to me at mpollack at interface21 dot com? I can make a first cut at it the configuration file. It should quite likely be just a matter of placing values such as
<constructor-arg name="connectionType" value="IBM.Data.DB2.DB2Connection, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
with
<constructor-argname="connectionType"value="IBM.Data.DB2.DB2Connection, IBM.Data.DB2.ISeries, Version=10.0.0.0, Culture=neutral, PublicKeyToken=insert-here"/>
assuming the class names are the same.
If you want to try it yourself, you can either modify dbProviders.xml directly and rebuild spring using the supplied solution.
Alternatively, if you don't want to rebuild you can specify your own additional provider configuration by setting the public static property DBPROVIDER_ADDITIONAL_RESOURCE_NAME in DbProviderFactory to a Spring resource location, the default value is file://dbProviders.xml, so something like file:///C:/iSeries/iSeriesProvider.xml and make changes as needed following what is listed above. I generally find Reflector to be useful for 'cracking open' a .dll to see the public key token and all the classes at a glance.
Cheers,
Mark
Mark Pollack
08-03-2007, 06:37 PM
Hi Suresh,
From the iSeries documentation (http://www.redbooks.ibm.com/redbooks/SG246440/wwhelp/wwhimpl/java/html/wwhelp.htm)I was able to construct a first cut at the configuration. I've attached the file. If you could replace the version of dbprovider.xml in your distribution and recompile this one (or use the mechanism i listed before), it should work.
Cheers,
Mark
sureshn
08-06-2007, 12:14 PM
I am unable to download the file. Can you send it again?
Thanks
Suresh.
Mark Pollack
08-06-2007, 04:19 PM
Hi,
I think my install of 7zip got corrupted.... here is a link (http://fisheye1.cenqua.com/browse/~raw,r=1.18/springnet/Spring.Net/src/Spring/Spring.Data/Data/Common/dbproviders.xml)from Fisheye. Thanks for the .dll Suresh, I'll verify that it looks correct a little later an post back here. Any feedback is greatly appreciated.
Cheers,
Mark
sureshn
08-06-2007, 05:18 PM
Hi Mark,
Thank you very much. I made some progress. Now i am getting following error.
Error occured System.InvalidCastException: Unable to cast object of type 'IBM.Data.DB2.iSeries.iDB2Command' to type 'System.Data.Common.DbCommand'.
at Spring.Data.Generic.AdoTemplate.Execute[T](CommandDelegate`1 del)
Mark Pollack
08-06-2007, 07:32 PM
Hi,
Since iDB2Command does not inherit from DbCommand you need to use the Execute callbacks that refer to IDbCommand instead of DbCommand. Namely,
T Execute<T>(IDbCommandCallback<T> action);
and
T Execute<T>(IDbCommandDelegate<T> del);
The docs have some additional info, at the moment near the end of Section 18.6.2. I've updated them in CVS a bit as well.
Before M2 these alternative callback interfaces did not exist, I introduced them specifically for this case, which is common to Oracle 10 and Postgress. The other generic methods within AdoTemplate, for example QueryWithRowMapper<T>, QueryForObject<T>, all call the interface (IDbCommand) version, so this is only an issue when selecting which overload of Execute<T> to use.
I also changed the implementation of the DbCommand Execute methods to throw a InvalidDataAccessApiUsageException with the message, "
Providers implementation of IDbCommand does not inherit from System.Data.Common.DbCommand. Use the alternative overloaded Execute method that specifies IDbCommandCallback as a parameter."
Cheers,
Mark
sureshn
08-08-2007, 02:11 PM
Thank you very much. It is working now.
Suresh.
avidgoffer
02-15-2008, 07:16 PM
We are having problems with the DB/2 9 configurations in the dbproviders.xml file. It appears the codes listed are incorrect as well as the segment of code listed below in DbProvider.cs. We have changed the code below from a cast to calling the ToString() method and this seems to work. I have also included our version of the DB/2 provider config.
Before:
public string ExtractError(Exception e)
{
if (!StringUtils.IsNullOrEmpty(dbMetadata.ErrorCodeEx ceptionExpression))
{
return (string) ExpressionEvaluator.GetValue(e, dbMetadata.ErrorCodeExceptionExpression);
}
else
{
return "Could not extract error code exception type." + e.GetType();
}
}
After:
public string ExtractError(Exception e)
{
if (!StringUtils.IsNullOrEmpty(dbMetadata.ErrorCodeEx ceptionExpression))
{
return ExpressionEvaluator.GetValue(e, dbMetadata.ErrorCodeExceptionExpression).ToString( );
}
else
{
return "Could not extract error code exception type." + e.GetType();
}
}
[InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.]
Spring.Data.Common.DbProvider.ExtractError(Excepti on e) +125
Spring.Data.Support.ErrorCodeExceptionTranslator.E xtractErrorCode(Exception exception) +35
Spring.Data.Support.ErrorCodeExceptionTranslator.T ranslate(String task, String sql, Exception exception) +115
Spring.Data.Core.AdoTemplate.Execute(ICommandCallb ack action) +415
Spring.Data.Core.AdoTemplate.ExecuteScalar(Command Type cmdType, String cmdText, IDbParameters parameters) +64
The DB/2 configuration as we believe it should look:
<!-- DB2 9.1.0 for .NET 2.0 -->
<object id="DB2-9.1.0.2" type="Spring.Data.Common.DbProvider, Spring.Data" singleton="false">
<constructor-arg name="DbMetaData">
<object type="Spring.Data.Common.DbMetadata, Spring.Data">
<constructor-arg name="productName" value="IBM.Data.DB2"/>
<constructor-arg name="assemblyName" value="IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="connectionType" value="IBM.Data.DB2.DB2Connection, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="commandType" value="IBM.Data.DB2.DB2Command, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="parameterType" value="IBM.Data.DB2.DB2Parameter, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="dataAdapterType" value="IBM.Data.DB2.DB2DataAdapter, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="commandBuilderType" value="IBM.Data.DB2.DB2CommandBuilder, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="commandBuilderDeriveParametersMethod" value="DeriveParameters"/>
<constructor-arg name="parameterDbType" value="IBM.Data.DB2.DB2Type, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="parameterDbTypeProperty" value="DB2Type"/>
<constructor-arg name="parameterIsNullableProperty" value="IsNullable"/>
<constructor-arg name="parameterNamePrefix" value="@"/>
<constructor-arg name="exceptionType" value="IBM.Data.DB2.DB2Exception, IBM.Data.DB2, Version=9.1.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>
<constructor-arg name="useParameterNamePrefixInParameterCollection" value="true"/>
<constructor-arg name="useParameterPrefixInSql" value="true"/>
<constructor-arg name="bindByName" value="true"/>
<!-- this is only true for .net 1.1 kept it here just in case we want to revert back to this strategy for
obtaining error codes-->
<constructor-arg name="errorCodeExceptionExpression" value="Errors[0].NativeError"/>
<!-- error codes taken from http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzala/rzalaco.htm and
from Spring.Java sql-error-codes.xml -->
<property name="ErrorCodes.badSqlGrammarCodes">
<value>-007, -029, -097, -104, -109, -115, -128, -199, -441, -491</value>
</property>
<property name="ErrorCodes.DataAccessResourceFailureCodes">
<value>-904,-971</value>
</property>
<property name="ErrorCodes.DataIntegrityViolationCodes">
<value>-407,-530,-531, -532,-543,-544,-545,-603,-667,-803</value>
</property>
<property name="ErrorCodes.DeadlockLoserCodes">
<value>-911,-913</value>
</property>
</object>
</constructor-arg>
</object>
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.