Unable to create two simultaneous connections

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
azabluda
Posts: 35
Joined: Thu 10 Sep 2009 14:45

Unable to create two simultaneous connections

Post by azabluda » Thu 23 Jun 2011 19:41

Hello,

C++ Builder XE
ODAC 7.20.0.7
Oracle 11.2.0.1

Code: Select all

//---------------------------------------------------------------------------
void __fastcall TForm1::testBTNClick(TObject *Sender)
{
   boost::scoped_ptr session1(new TOraSession(0));
   session1->Options->UseUnicode = true;
   session1->Options->Net = true;
   session1->Server = "demo11g:1521:pvs";
   session1->Username = "pvs";
   session1->Password = "pvs";
   session1->ConnectMode = cmNormal;
   session1->Connect();

   boost::scoped_ptr session2(new TOraSession(0));
   session2->Options->UseUnicode = true;
   session2->Options->Net = true;
   session2->Server = "demo11g:1521:pvs";
   session2->Username = "pvs";
   session2->Password = "pvs";
   session2->ConnectMode = cmNormal;
   session2->Connect(); << Exception: Connection Unicode OCI environment differs from already active connections!!!
}
//---------------------------------------------------------------------------
void __fastcall EnableUnicodeInSQL()
{
   OCIUnicode = true;
}
#pragma startup EnableUnicodeInSQL
//---------------------------------------------------------------------------
° What am I doing wrong?
° It worked in ODAC 7.20.0.6

Thanks,
Alexander

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 24 Jun 2011 07:19

Hello,

Thank you for the information.
We have reproduced the problem.
We will notify you as soon as we have any results.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 24 Jun 2011 15:32

Hello,

We've fixed this problem.
I've sent you the corrected *.dcu file to your e-mail.

azabluda
Posts: 35
Joined: Thu 10 Sep 2009 14:45

Post by azabluda » Fri 24 Jun 2011 16:24

Dear AlexP,

Thank you for a quick solution. However the .dcu file seems to be of no use in C++ Builder. We would rather be interested in getting an official release containing the bugfix. Is the release date already known?

Thanks,
az

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 27 Jun 2011 06:55

Hello,

The new release will be available not earlier than August, so please send your registration data to alexp*devart*com and we'll send you the fixed ODAC version.

cis-wurzen
Posts: 75
Joined: Tue 04 Jan 2005 10:26

Post by cis-wurzen » Wed 06 Jul 2011 13:49

Hmm I just stepped into the same problem and wasted time creating this test case. I'll send you a mail to get the fix too.

Code: Select all

program ODACMultipleUnicodeSessionTest;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Ora,
  OraCall;

{
--DB should use Unicode charset like AL32UTF8 and not something like WIN12xx
CREATE TABLE ODACTESTMULTISESSIONUNICODETAB(
  ID                                 NUMBER(10,0),
  FIELD1                             VARCHAR2(10)
);
}

const
  cServer = 'YourServer';
  cUsername = 'YourUser';
  cPassword = 'YourPassword';
  cMoscow = #1052#1086#1089#1082#1074#1072;
  cKiev = #1050#1080#1111#1074;

function TestMultipleUnicodeSessions: Boolean;

  procedure SetSessionParams(ASession: TOraSession);
  begin
    ASession.Server := cServer;
    ASession.Username := cUserName;
    ASession.Password := cPassword;
    ASession.Options.UseUnicode := True;
  end;

  procedure InsertUnicodeRecord(ASession: TOraSession; AID: Integer; AStr: string);
  var
    os: TOraSQL;
  begin
    os := TOraSQL.Create(nil);
    try
      os.Session := ASession;
      os.AutoCommit := True;
      os.SQL.Add('INSERT INTO ODACTESTMULTISESSIONUNICODETAB(ID, FIELD1)');
      os.SQL.Add(Format('VALUES(%d, %s)', [AID, QuotedStr(AStr)]));
      os.Execute;
    finally
      os.Free;
    end;
  end;

  function GetRecordStr(ASession: TOraSession; AID: Integer): string;
  var
    qr: TOraQuery;
  begin
    qr := TOraQuery.Create(nil);
    try
      qr.Session := ASession;
      qr.SQL.Add('SELECT FIELD1 FROM ODACTESTMULTISESSIONUNICODETAB');
      qr.SQL.Add(Format('WHERE ID = %d', [AID]));
      qr.Open;
      Result := qr.Fields[0].AsString;
      qr.Close;
    finally
      qr.Free;
    end;
  end;

  procedure DelAll(ASession: TOraSession);
  var
    os: TOraSQL;
  begin
    os := TOraSQL.Create(nil);
    try
      os.Session := ASession;
      os.SQL.Add('DELETE FROM ODACTESTMULTISESSIONUNICODETAB');
      os.Execute;
    finally
      os.Free;
    end;
  end;

var
  se1, se2: TOraSession;
  S1, S2: string;
begin
  se1 := TOraSession.Create(nil);
  se2 := TOraSession.Create(nil);
  try
    SetSessionParams(se1);
    SetSessionParams(se2);
    OraCall.OCIUnicode := True;
    se1.Open;
    //OraCall.OCIUnicode := False;//temporary workaround
    se2.Open;
    DelAll(se1);
    InsertUnicodeRecord(se1, 1, cMoscow);
    InsertUnicodeRecord(se2, 2, cKiev);
    S1 := GetRecordStr(se1, 1);
    S2 := GetRecordStr(se1, 2);
    Result := (S1 = cMoscow) and (S2 = cKiev);
  finally
    se2.Free;
    se1.Free;
  end;
end;

begin
  try
    if TestMultipleUnicodeSessions then
      WriteLn('PASS')
    else
      WriteLn('FAIL');
  except
    on E: Exception do
    begin
      WriteLn('FAIL - Exception Error');
      WriteLn('  E.ClassName = ', E.ClassName);
      WriteLn('    E.Message = ', E.Message);
    end;
  end;
  ReadLn;
end.
Output with 7.20.0.7 is

FAIL - Exception Error
E.ClassName = Exception
E.Message = Connection Unicode OCI environment differs from already active connections

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 07 Jul 2011 07:35

Hello,

cis-wurzen:
Please specify the version of your IDE.

Eurocg
Posts: 14
Joined: Tue 15 Jul 2008 08:11
Location: Germany

Connection Unicode OCI environment differs from already....

Post by Eurocg » Fri 16 Dec 2011 09:29

We need a solution to connect two TCRSQLConnections simultaneous.

Backend : Oracle 11g
Client : Delphi XE, devExpress 5.01


Error : Connection Unicode OCI environment differs from already
active connections
(After we opened the second SqlConnection)

THANKS

Christian G

Eurocg
Posts: 14
Joined: Tue 15 Jul 2008 08:11
Location: Germany

Connection Unicode OCI environment differs from already....

Post by Eurocg » Fri 16 Dec 2011 09:29

We need a solution to connect two TCRSQLConnections simultaneous.

Backend : Oracle 11g
Client : Delphi XE, devExpress 5.01


Error : Connection Unicode OCI environment differs from already
active connections
(After we opened the second SqlConnection)

THANKS

Christian G

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 16 Dec 2011 13:03

hello,

Now you cannot connect to Oracle simultaneously in different modes (UniCode = True and UniCode = False).
We know about this problem, we are working on it.

lucbuzatto
Posts: 1
Joined: Wed 10 Jan 2018 19:39

Re: Unable to create two simultaneous connections

Post by lucbuzatto » Wed 10 Jan 2018 19:44

Hi,

I am having the same problem, using Delphi XE2 and Oracle, and trying to make 2 connections with parameter UnicodeEnvironment=True.

There is any solution for this problem ?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Unable to create two simultaneous connections

Post by MaximG » Thu 11 Jan 2018 11:10

We checked the performance of the ODAC latest version 10.1.3 when creating two connections to the same Oracle database with the UnicodeEnvironment = True option and found no problems. For further investigation, please compile and send us the simplest example, in which the problem occurs. For your convenience, please use the e-support form (https://www.devart.com the "Support"\"Request Support" menu).

Post Reply