[Mono-dev] IBM.Data.DB2.DB2Exception: Unable to allocate statement handle

Bartolomeo Nicolotti bnicolotti at siapcn.it
Thu Feb 12 11:12:28 EST 2009


Hi,

I think I've the same problem:

siap at LxPC54:~/src/test$ gmcs -r:/usr/lib/mono/1.0/IBM.Data.DB2.dll
-r:/usr/lib/mono/2.0/System.Data.dll helloDB2.cs
siap at LxPC54:~/src/test$ mono helloDB2.exe
You must tell me your name!
siap at LxPC54:~/src/test$ mono helloDB2.exe bart
Hello, bart

Unhandled Exception: System.DllNotFoundException: db2_36
  at (wrapper managed-to-native)
IBM.Data.DB2.DB2CLIWrapper/StaticWrapper36:SQLAllocHandle
(int16,intptr,intptr&)
  at IBM.Data.DB2.DB2CLIWrapper.SQLAllocHandle (Int16 handleType, IntPtr
inputHandle, System.IntPtr& outputHandle) [0x00000]
  at IBM.Data.DB2.DB2CLIWrapper.Initialize (System.IntPtr& pEnvHandle)
[0x00000]
  at IBM.Data.DB2.DB2Environment..ctor () [0x00000]
  at IBM.Data.DB2.DB2Environment.get_Instance () [0x00000]
  at IBM.Data.DB2.DB2ConnectionPool.FindConnectionPool (System.String
connectionString) [0x00000]
  at IBM.Data.DB2.DB2ConnectionSettings.GetConnectionSettings (System.String
connectionString) [0x00000]
  at IBM.Data.DB2.DB2Connection.SetConnectionString (System.String
connectionString) [0x00000]
  at IBM.Data.DB2.DB2Connection..ctor (System.String conString) [0x00000]
  at (wrapper remoting-invoke-with-check) IBM.Data.DB2.DB2Connection:.ctor
(string)
  at HelloWorldDb2.Main (System.String[] args) [0x00000]


Then I've tried to edit /etc/mono/config:

sudo vim /etc/mono/config

        <dllmap dll="oci" target="libclntsh.so" os="!windows"/>
        <dllmap dll="db2cli" target="libdb2_36.so" os="!windows"/>

adding this line (not target="libdb2.so", because the mono loader adds the
.so extension itself):

        <dllmap dll="db2_36" target="libdb2" os="!windows"/>

and it Loaded the right library, as you can see from below, but then I
realized that the ADO.net namespace we use is:

IBM.Data.DB2.iSeries

so we have to use unixODBC, because this namespace is not implemented in
Mono, is it?

For the connection and the data could you please tell me which namespace are
you using in you application?

Many thanks

Best regards



castord wrote:
> 
> After failing trying to connect with the native driver I switched to
> unixODBC and it works fine for me. It is stable and I currently have a
> large
> program using ODBC as its connector.
> I use openSuse as my major OS. I installed the db2 express C but I was
> unable to find the required library to make IBM.DB2 dll to work. Bad for
> me.
> 
> 
> 
> 
> On Thu, Feb 12, 2009 at 4:20 AM, Bartolomeo Nicolotti
> <bnicolotti at siapcn.it>wrote:
> 
>>
>> I'd like to use the webservice "As is" so that we can switch easyly...
>>
>> if I won't be able to do it with IBM.Data.DB2 in a few days I'll consider
>> using other way to connect.
>>
>> Do you know if with these providers you can connecto to AS/400?
>>
>> Many thanks
>>
>> Best regards
>>
>>
>>
>> Bartolomeo Nicolotti wrote:
>> >
>> > Da:   Daniel Morgan <monodanmorg at yahoo.com>
>> >
>> > Have you considered using ODBC provider instead?
>> >
>> > System.Data.Odbc namespace is included in System.Data assembly.
>> >
>> > You can use iodbc or unixodbc on linux.  There's commercial odbc
>> solutions
>> > for linux too.
>> >
>> > http://mono-project.com/ODBC
>> >
>> > http://www.unixodbc.com/doc/db2.html
>> >
>> > Novell maintains System.Data.Odbc; however, I do not think anyone is
>> > maintaining IBM.Data.DB2 in Mono.
>> >
>> >
>> > --- On Wed, 2/11/09, Bartolomeo Nicolotti <bnicolotti at siapcn.it> wrote:
>> >
>> >
>> >
>> > Bartolomeo Nicolotti wrote:
>> >>
>> >> IBM.Data.DB2.DB2Exception: Unable to allocate statement handle
>> >>
>> >> by Bartolomeo Nicolotti :: Rate this Message:
>> >>
>> >> Reply | Reply to Author | View Threaded | Show Only this Message
>> >> Hello,
>> >>
>> >> I've installed mono, and xsp (not yet mod_mono) on ubuntu following
>> the
>> >> instruction here:
>> >>
>> >> http://ubuntuforums.org/showthread.php?t=803743
>> >>
>> >> in view of using mod_mono together with php on ubuntu server 8.04, to
>> >> migrate a web service that access a db2/as400 database.
>> >>
>> >> I've also installed db2exc from ubuntu repository as said here:
>> >>
>> >> http://www.ubuntu.com/partners/ibm/db2
>> >>
>> >> I can compile a test program that does a query to the db:
>> >>
>> >>  http://www.nabble.com/file/p21953488/helloDB2.cs helloDB2.cs
>> >>
>> >> siap at LxPC54:~/src/test$ gmcs -r:/usr/lib/mono/1.0/IBM.Data.DB2.dll
>> >> -r:/usr/lib/mono/2.0/System.Data.dll helloDB2.cs
>> >>
>> >> but when I execute it:
>> >>
>> >> siap at LxPC54:~/src/test$ sudo MONO_LOG_LEVEL=debug mono helloDB2.exe
>> bart
>> >>
>> >> ....
>> >>
>> >> Mono-INFO: Assembly Ref addref System.Data 0x8362e10 -> System.Xml
>> >> 0x83719d8: 2
>> >>
>> >> Hello, bart
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLAllocHandle'.
>> >> Mono-INFO: Probing 'SQLAllocHandle'.
>> >> Mono-INFO: Found as 'SQLAllocHandle'.
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLAllocHandle'.
>> >> Mono-INFO: Probing 'SQLAllocHandle'.
>> >> Mono-INFO: Found as 'SQLAllocHandle'.
>> >> Bart
>> >> not useLibCli
>> >> Bart
>> >> not useLibCli
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLDriverConnectW'.
>> >> Mono-INFO: Probing 'SQLDriverConnectWW'.
>> >> Mono-INFO: Probing 'SQLDriverConnectWW'.
>> >> Mono-INFO: Probing 'SQLDriverConnectW'.
>> >> Mono-INFO: Found as 'SQLDriverConnectW'.
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLDriverConnectW'.
>> >> Mono-INFO: Probing 'SQLDriverConnectWW'.
>> >> Mono-INFO: Probing 'SQLDriverConnectWW'.
>> >> Mono-INFO: Probing 'SQLDriverConnectW'.
>> >> Mono-INFO: Found as 'SQLDriverConnectW'.
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLGetInfoW'.
>> >> Mono-INFO: Probing 'SQLGetInfoWW'.
>> >> Mono-INFO: Probing 'SQLGetInfoWW'.
>> >> Mono-INFO: Probing 'SQLGetInfoW'.
>> >> Mono-INFO: Found as 'SQLGetInfoW'.
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLGetInfoW'.
>> >> Mono-INFO: Probing 'SQLGetInfoWW'.
>> >> Mono-INFO: Probing 'SQLGetInfoWW'.
>> >> Mono-INFO: Probing 'SQLGetInfoW'.
>> >> Mono-INFO: Found as 'SQLGetInfoW'.
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLGetDiagRec'.
>> >> Mono-INFO: Probing 'SQLGetDiagRec'.
>> >> Mono-INFO: Found as 'SQLGetDiagRec'.
>> >> Mono-INFO: DllImport attempting to load: 'libdb2'.
>> >> Mono-INFO: DllImport loading location: 'libdb2.so'.
>> >> Mono-INFO: Searching for 'SQLGetDiagRec'.
>> >> Mono-INFO: Probing 'SQLGetDiagRec'.
>> >> Mono-INFO: Found as 'SQLGetDiagRec'.
>> >> Bart
>> >> not useLibCli
>> >>
>> >> Unhandled Exception: IBM.Data.DB2.DB2Exception: ERROR [08003]
>> [IBM][CLI
>> >> Driver] CLI0106E  Connection is closed. SQLSTATE=08003
>> >> InternalExecuteNonQuery: Unable to allocate statement handle.
>> >>   at IBM.Data.DB2.DB2Command.AllocateStatement (System.String
>> location)
>> >> [0x00000]
>> >>   at IBM.Data.DB2.DB2Command.ExecuteNonQueryInternal (CommandBehavior
>> >> behavior) [0x00000]
>> >>   at IBM.Data.DB2.DB2Command.ExecuteReader (CommandBehavior behavior)
>> >> [0x00000]
>> >>   at IBM.Data.DB2.DB2Command.ExecuteReader () [0x00000]
>> >>   at (wrapper remoting-invoke-with-check)
>> >> IBM.Data.DB2.DB2Command:ExecuteReader ()
>> >>   at HelloWorldDb2.Main (System.String[] args) [0x00000]
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/IBM.Data.DB2.DB2Exception%3A-Unable-to-allocate-statement-handle-tp21953488p21971698.html
>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 

-- 
View this message in context: http://www.nabble.com/IBM.Data.DB2.DB2Exception%3A-Unable-to-allocate-statement-handle-tp21953488p21979172.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list