[Mono-list] System.Data.OracleClient on z/Linux - 64-bit - Big-endian
Daniel Morgan
monodanmorg at yahoo.com
Thu Feb 14 22:45:51 EST 2008
After some discussion on IRC, this what some helpful
people gave me.
Marshal an IntPtr since it is the size of a native
pointer. I believe an IntPtr can be casted to an int
or long and vice-versa.
http://www.mono-project.com/Interop_with_Native_Libraries
--- Daniel Morgan <monodanmorg at yahoo.com> wrote:
> Date: Thu, 14 Feb 2008 17:28:41 -0800 (PST)
> From: Daniel Morgan <monodanmorg at yahoo.com>
> To: Edwin Kim <EKIM at transitchicago.com>,
> mono-list at lists.ximian.com
> Subject: Re: [Mono-list] System.Data.OracleClient on
> z/Linux
>
> Go to Mono's web site and go to the download page.
> Download the source code to mono if you have not
> already. Unarchive it somewhere. I assume you know
> how to ungzip and untar a file.
>
> In the source, go to
>
mono_source/mcs/class/System.Data.OracleClient/System.Data.OracleClient.cs
>
> And look in file OciStatementHandle.cs at function
> Prepare. You should see it calling the function
> OCIUnicodeToCharSet. You need to see what the
> function is actually passing returning via
> Console.Error.WriteLine calls.
>
> Oracle Call Interface Programmer's Guide
>
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/toc.htm
>
> Documentation for all Oracle products can be found
> here:
> http://tahiti.oracle.com/
>
> sword OCIUnicodeToCharSet ( dvoid *hndl,
> OraText *dst,
> size_t dstlen,
> CONST ub2 *src,
> size_t srclen,
> size_t *rsize );
>
> The docs says these are the possible values that can
> be returned: OCI_SUCCESS, OCI_INVALID_HANDLE. or
> OCI_ERROR. I'm not sure the proper way to marshal a
> size_t that will work on 32-bit and 64-bits systems.
>
> Perhaps someone reading this can shed some light.
>
> Also, take a look at OciCalls.cs and see how to
> enable
> tracing. You may need to re-build
> System.Data.OracleClient to enable tracing. And I
> think you would also need to set OCI_TRACE to point
> to
> the file to log tracing.
>
> --- Edwin Kim <EKIM at transitchicago.com> wrote:
>
> > Thanks much!!!
> >
> > I'm new to Mono, OCI, and C#.
> > I guess z/Linux running on the IBM z/800
> (mainframe)
> > is big endian.
> >
> > I was able to display some information using
> > environment variables:
> > export MONO_LOG_LEVEL=info
> > export MONO_LOG_MASK=dll
> >
> > Console output:
> >
> > Mono-INFO: Searching for 'OCISessionBegin'.
> > Mono-INFO: Probing 'OCISessionBegin'.
> > Mono-INFO: Found as 'OCISessionBegin'.
> > Mono-INFO: DllImport attempting to load:
> > 'libclntsh.so'.
> > Mono-INFO: DllImport loading location:
> > 'libclntsh.so'.
> > Mono-INFO: Searching for 'OCIServerVersion'.
> > Mono-INFO: Probing 'OCIServerVersion'.
> > Mono-INFO: Found as 'OCIServerVersion'.
> > Mono-INFO: DllImport attempting to load:
> > 'libclntsh.so'.
> > Mono-INFO: DllImport loading location:
> > 'libclntsh.so'.
> > Mono-INFO: Searching for 'OCICharSetToUnicode'.
> > Mono-INFO: Probing 'OCICharSetToUnicode'.
> > Mono-INFO: Found as 'OCICharSetToUnicode'.
> > ServerVersion: Oracle Database
> > DataSource: wpsdb
> > Mono-INFO: DllImport attempting to load:
> > 'libclntsh.so'.
> > Mono-INFO: DllImport loading location:
> > 'libclntsh.so'.
> > Mono-INFO: Searching for 'OCIUnicodeToCharSet'.
> > Mono-INFO: Probing 'OCIUnicodeToCharSet'.
> > Mono-INFO: Found as 'OCIUnicodeToCharSet'.
> > Unhandled Exception:
> System.NullReferenceException:
> > Object reference not set to an instance of an
> object
> > at
> >
>
System.Data.OracleClient.Oci.OciStatementHandle.Prepare
> > (System.String commandText) [0x00000]
> > at
> >
>
System.Data.OracleClient.OracleCommand.PrepareStatement
> > (System.Data.OracleClient.Oci.OciStatementHandle
> > statement) [0x00000]
> > at
> >
> System.Data.OracleClient.OracleCommand.ExecuteReader
> > (CommandBehavior behavior) [0x00000]
> > at
> >
> System.Data.OracleClient.OracleCommand.ExecuteReader
> > () [0x00000]
> > at (wrapper remoting-invoke-with-check)
> >
> System.Data.OracleClient.OracleCommand:ExecuteReader
> > ()
> > at Test.Main (System.String[] args) [0x00000]
> > Mono-INFO: DllImport attempting to load:
> > 'libclntsh.so'.
> > Mono-INFO: DllImport loading location:
> > 'libclntsh.so'.
> > Mono-INFO: Searching for 'OCIHandleFree'.
> > Mono-INFO: Probing 'OCIHandleFree'.
> > Mono-INFO: Found as 'OCIHandleFree'.
> >
> > and source code:
> > using System;
> > using System.Data;
> > using System.Data.OracleClient;
> > public class Test
> > {
> > public static void Main (string[] args)
> > {
> > string connectionString =
> > "Data Source=wpsdb;" +
> > "User ID=test;" +
> > "Password=test;";
> > OracleConnection dbcon = null;
> > dbcon = new OracleConnection
> > (connectionString);
> > dbcon.Open ();
> > Console.WriteLine("ServerVersion: " +
> > dbcon.ServerVersion + "\nDataSource: " +
> > dbcon.DataSource);
> >
> > OracleCommand dbcmd = dbcon.CreateCommand
> ();
> > string sql = "SELECT * FROM dual";
> > dbcmd.CommandText = sql;
> > OracleDataReader reader =
> dbcmd.ExecuteReader
> > ();
> > while (reader.Read ()) {
> > System.Console.WriteLine( "." );
> > }
> > // clean up
> > reader.Close ();
> > reader = null;
> > dbcmd.CommandText = sql;
> > dbcmd.ExecuteNonQuery ();
> > dbcmd.Dispose ();
> > dbcmd = null;
> > dbcon.Close ();
> > dbcon = null;
> > }
> > }
> >
> >
> > ________________________________________
> > From: Daniel Morgan [monodanmorg at yahoo.com]
> > Sent: Tuesday, February 12, 2008 9:08 PM
> > To: Edwin Kim
> > Subject: Re: [Mono-list] System.Data.OracleClient
> on
> > z/Linux
> >
> > I'm sorry. It does look that way. You could use
> > ODBC
> > instead. Or you could use a fully managed oracle
> > provider, such as, one from DataDirect.
> >
> > It looks like Mono's OracleClient fails trying to
> > call
> > the Prepare function. Maybe OCI did not create an
> > OCI
> > statement handle.
> >
> > If you look in source in OciStatementHandle, it
> may
> > give you a clue where it is failing. You could
> turn
> > tracing on.
> >
> > Or you could put a bunch of
> > Console.Error.WriteLine's
> > checking the output of function calls to see what
> is
> > being returned.
> >
> > dbcmd.commandText fails to compile because you
> were
> > trying to access a member of OracleCommand that is
> > private, protected, or internal. C# is case
> > sesitive.
> > If you need to access the CommandText property of
> > OracleCommand, you have to spell it with the
> correct
> > capitalization.
> >
> > Is z/Linux running on the IBM z/800 big endian or
> > little endian? I assume big endian.
> >
> > Mono's OracleClient was mainly developed on
> Windows
> > and Linux on 32-bit x86. So, there could be a
> > problem
> > with marshalling integers and unicode strings.
> Does
> > the IBM z/800 require alignment of integers?
> >
> > --- Edwin Kim <ekim at transitchicago.com> wrote:
> >
> > > Do you mean I can't use the OracleClient
> provider
> > > yet?
> > > z/linux is 64-bit running on IBM z/800
> processor.
> > >
> > >
> > > I was able to display the connection state and
> > > dbcmd.CommandText on the screen:
> > >
> > > Code:
> > > using System;
> > > using System.Data;
> > > using System.Data.OracleClient;
> > >
> > > public class Test
> > > {
> > > public static void Main (string[] args)
> > > {
> > > string connectionString =
> > > "Data Source=wpsdb;" +
> > > "User ID=test;" +
> > > "Password=test;";
> > > OracleConnection dbcon = null;
> > > dbcon = new OracleConnection
> > > (connectionString);
> > > dbcon.Open ();
> > > Console.WriteLine("Connection State: " +
> > > dbcon.State);
> > > Console.WriteLine("ServerVersion: " +
> > > dbcon.ServerVersion + "\nDataSource: " +
> > > dbcon.DataSource);
> > > string commandText = "SELECT * FROM
> dual";
> > > OracleCommand dbcmd = new OracleCommand
> > > (commandText, dbcon);
> > > Console.WriteLine("commandText: " +
> > > dbcmd.CommandText);
> > >
> > > OracleDataReader reader =
> > dbcmd.ExecuteReader
> > > ();
> > > // clean up
> > > reader.Close ();
> > > reader = null;
> > > dbcmd.Dispose ();
> > > dbcmd = null;
> > > dbcon.Close ();
> > > dbcon = null;
> > > }
> > > }
> >
> === message truncated ===
>
>
>
>
>
____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
More information about the Mono-list
mailing list