Page 1 of 1

unidirect oracle blob reading crash when using direct

Posted: Fri 11 Sep 2009 10:14
by marc.vanhoecke
When reading blobs with Oracle several times, this gives a

CoreLab.Oracle.OracleException was unhandled
Message="Network error: 204"
Source="CoreLab.UniDirect.Oracle"
ErrorCode=-2147467259
Code=204
Offset=0
StackTrace:
at CoreLab.Oracle.au.Close()
at CoreLab.Oracle.au.Finalize()
InnerException:

This happens when using a direct connection. When using oracle client (not direct) it works.

To test:

CREATE TABLE delme
(id NUMBER ,
bigfield BLOB)
/
-- Constraints for DELME
ALTER TABLE delme
ADD CONSTRAINT pk_delme PRIMARY KEY (id)
/


App Config

Code: Select all


  
    
    
  

And here the console program:



Code: Select all

using System;
using System.Configuration;
using System.Text;
using CoreLab.UniDirect;

namespace ConsoleTestUniLong
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string connectString = ConfigurationManager.ConnectionStrings["UNIDB"].ConnectionString;
            using (UniConnection conn = new UniConnection(connectString))
            {
                conn.Open();
                UniTransaction trans = conn.BeginTransaction();
                try
                {
                    //Lest run the test cycle a few times
                    int maxCycle = 2;
                    for (int cycle = 1; cycle <= maxCycle; cycle++)
                    {
                        Console.WriteLine("**** Cycle {0}/{1}", cycle, maxCycle);

                        //Delete all the record
                        UniCommand cmdDelete = new UniCommand("DELETE FROM DELME", conn);
                        int recordsAffected = cmdDelete.ExecuteNonQuery();
                        Console.WriteLine("{0} returns {1}", cmdDelete.CommandText, recordsAffected);

                        Console.WriteLine("Inserting big fields...");
                        for (int i = 1; i <= 100; i++)
                        {
                            int maxLen = 1000*i;
                            string longText = new string('X', maxLen);
                            UniCommand cmd = new UniCommand("INSERT INTO DELME (ID,BIGFIELD) VALUES (:pID, :pBIGFIELD)", conn);
                            cmd.Parameters.Add("pID", i);
                            UniParameter param = new UniParameter("pBIGFIELD", UniDbType.Blob);
                            param.Value = CreateBlob(conn, longText);
                            cmd.Parameters.Add(param);
                            recordsAffected = cmd.ExecuteNonQuery();
                            Console.WriteLine("Inserting {0} characters returned {1}", maxLen, recordsAffected);
                        }

                        Console.WriteLine("Verifying big fields...");
                        for (int i = 1; i <= 100; i++)
                        {
                            int maxLen = 1000*i;
                            string longText = string.Empty;
                            UniCommand cmd = new UniCommand("SELECT ID,BIGFIELD FROM DELME WHERE ID = :pID", conn);
                            cmd.Parameters.Add("pID", i);
                            UniDataReader rdr = cmd.ExecuteReader();
                            if (rdr.Read())
                                longText = ReadBlob(rdr, 1);
                            if (longText.Length != maxLen)
                                throw new ApplicationException("Unexpected length");
                            Console.WriteLine("Verified length {0} characters", maxLen);
                        }
                    }
                    //Commit
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
                finally
                {
                    conn.Close();
                }
            }

            Console.WriteLine("End. Press a key to terminate the program");
            Console.ReadKey();
        }

        private static UniBlob CreateBlob(UniConnection uniConnection, string value)
        {
            UniBlob uniBlob = new UniBlob(uniConnection, UniDbType.Blob);
            byte[] chars = Encoding.Default.GetBytes(value);
            uniBlob.Write(chars, 0, chars.Length);
            return uniBlob;
        }

        private static string ReadBlob(UniDataReader dataReader, int fieldNo)
        {
            int length = (int) dataReader.GetBytes(fieldNo, 0, null, 0, 0);
            byte[] buffer = new Byte[length];
            length = (int) dataReader.GetBytes(fieldNo, 0, buffer, 0, length);
            return Encoding.Default.GetString(buffer);
        }
    }
}

Posted: Fri 11 Sep 2009 14:28
by Shalex
We have reproduced the problem. We will investigate it and notify you about the results as soon as possible.

Posted: Thu 22 Oct 2009 07:52
by marc.vanhoecke
Shalex wrote:We have reproduced the problem. We will investigate it and notify you about the results as soon as possible.
Hi,

Any news here?

I tried the latest beta but now I am unable to insert more then 4000 chars into the oracle LONG field.

(FYI when I use a oracle CLOB column instead of LONG, above test program works)

Marc

Posted: Fri 23 Oct 2009 14:54
by Shalex
1. The "Network error: 204" error. Try using the following code (reader is placed into the using section) with the latest 3.00.1 version of dotConnect Universal:

Code: Select all

string connectString = "Provider=Oracle;Server=***;SID=***;Direct=true;User Id=***;Password=***";
      using (UniConnection conn = new UniConnection(connectString)) {
        conn.Open();
        UniTransaction trans = conn.BeginTransaction();
        try {
          //Lest run the test cycle a few times 
          int maxCycle = 2;
          for (int cycle = 1; cycle <= maxCycle; cycle++) {
            Console.WriteLine("**** Cycle {0}/{1}", cycle, maxCycle);

            //Delete all the record 
            UniCommand cmdDelete = new UniCommand("DELETE FROM DELME", conn);
            int recordsAffected = cmdDelete.ExecuteNonQuery();
            Console.WriteLine("{0} returns {1}", cmdDelete.CommandText, recordsAffected);

            Console.WriteLine("Inserting big fields...");
            for (int i = 1; i <= 100; i++) {
              int maxLen = 1000 * i;
              string longText = new string('X', maxLen);
              UniCommand cmd = new UniCommand("INSERT INTO DELME (ID,BIGFIELD) VALUES (:pID, :pBIGFIELD)", conn);
              cmd.Parameters.Add("pID", i);
              UniParameter param = new UniParameter("pBIGFIELD", UniDbType.Blob);
              param.Value = CreateBlob(conn, longText);
              cmd.Parameters.Add(param);
              recordsAffected = cmd.ExecuteNonQuery();
              Console.WriteLine("Inserting {0} characters returned {1}", maxLen, recordsAffected);
            }

            Console.WriteLine("Verifying big fields...");
            for (int i = 1; i <= 100; i++) {
              int maxLen = 1000 * i;
              string longText = string.Empty;
              UniCommand cmd = new UniCommand("SELECT ID,BIGFIELD FROM DELME WHERE ID = :pID", conn);
              cmd.Parameters.Add("pID", i);

             //placing reader into using section
              using (UniDataReader rdr = cmd.ExecuteReader()) {
                if (rdr.Read())
                  longText = ReadBlob(rdr, 1);
                if (longText.Length != maxLen)
                  throw new ApplicationException("Unexpected length");
                Console.WriteLine("Verified length {0} characters", maxLen);
              }

            }
          }
          //Commit 
          trans.Commit();
        }
        catch {
          trans.Rollback();
          throw;
        }
        finally {
          conn.Close();
        }
      }

      Console.WriteLine("End. Press a key to terminate the program");
      Console.ReadKey();
2. The 4000 chars limitation for the Long field. This issue will be fixed in the next build of dotConnect Universal. I will post here when it is available.

Oracle LONG

Posted: Mon 02 Nov 2009 11:21
by marc.vanhoecke
First of all , thank you for the reply but I have the feeling that the Unidirect providers are not as actively maintained or thoroughly tested as the dotConnect providers.

For maximum reliability , do you advise to use dotConnect providers (together with enterprise library) or is this an unfortunate temporary situation?

I am looking forward to the Oracle LONG fix because this prevents further development using UniDirect.

Posted: Mon 02 Nov 2009 13:52
by Shalex
We support equally dotConnect for Oracle and dotConnect Universal. Your provider choice should be based on your tasks. If you encouner any problems with our provider, please report the issue. We will do our best to resolve it.

The LONG issue is fixed. Look forward to the next build of dotConnect Universal.

Posted: Mon 02 Nov 2009 14:11
by marc.vanhoecke
Thank you Shalex for the quick reply.

Oracle LONG issue

Posted: Fri 06 Nov 2009 08:35
by marc.vanhoecke
Do you have estimated time of arrival on the new build where the long issue is fixed?
Best regards,
Marc

Posted: Tue 10 Nov 2009 13:11
by Shalex
We plan to make a new build of dotConnect Universal in the end of this week.

Posted: Fri 20 Nov 2009 16:45
by Shalex
dotConnect Universal v 3.00 is released.
It can be downloaded from http://www.devart.com/dotconnect/unidir ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=16441 .