delphiwindows-7oracle11gdbexpress

Why does reconnecting to an Oracle database via dbExpress cause an access violation?


I have a Delphi 2006 application running on Windows 7 that connects to an Oracle database via dbExpress using an Oracle 11 client install. After the first connect, I can query data and everything works as expected. However, when I disconnect and then re-connect, I get the following error:

Exception EAccessViolation in module orageneric11.dll at 00450EB5. 
Access violation at address 048A0EB5 in module 'orageneric11.dll'.
Read of address 00000038

The same application is running fine on Windows XP using an Oracle 10 client install (unfortunately, I don't have a test-setup with XP + Oracle 11 or Windows 7 + Oracle 10).

I have reduced the problem to the following:

program OracleReconnectTest; 

{$APPTYPE CONSOLE} 

uses
  SysUtils,
  SqlExpr; 

var
  connection: TSQLConnection;

begin
  connection := TSQLConnection.Create( nil );
  connection.DriverName := 'Oracle';
  connection.LibraryName := 'dbxora30.dll';
  connection.VendorLib := 'oci.dll';
  connection.GetDriverFunc := 'getSQLDriverORACLE';
  connection.LoginPrompt := False;
  connection.Params.Text :=
    'DATABASE=TheDatabase' + #$D#$A +
    'USER_NAME=TheUser' + #$D#$A +
    'PASSWORD=ThePassword' + #$D#$A +
    'DECIMAL SEPARATOR=,'; 

  connection.Connected := True; 

  Writeln( 'Connected once, press ENTER to disconnect and reconnect' );
  Readln; 

  connection.Connected := False;
  connection.Connected := True; // <- access violation on Windows 7 + Oracle 11

  Writeln( 'Reconnected, press ENTER to exit' );
  Readln;
end.

I suppose this rules out a problem with my application code. I have stepped through the dbExpress code that comes with Delphi, but haven't encountered anything that looks wrong or would explain this.

So I haven't been able to find anything that indicates this to be a bug in either dbExpress or the Oracle driver. Hence I wouldn't know whether to file a bug against with Embarcadero and/or Oracle.

The version of orageneric11.dll is 11.2.0.1, and dbxora30.dll is version 10.0.2151.25345.

Because it has caused problems when multiple client versions were installed in parallel, the machine in question only has the 11 client. Using Process Explorer, I have verified that only DLLs from the 11 client are used.

Has anybody else encountered this issue and can point me in the right direction?


Solution

  • Sorry, I don't have a "nice and sweet" solution that would fix it, but there are some options you may consider:

    a) Change the used driver and try your luck accessing the database via ODBC after setting up an ODBC DSN on the client for the specified database. An Open Source driver can be found here: https://sourceforge.net/projects/open-dbexpress/

    b) Buy a new version of Delphi. That may be a real pain, I know. It'll cost money and time (more if 3rd party components are involved), but sometimes it's just not the best idea to use products that are more than a decade old. The company and the intellectual property behind Delphi have since then been transformed / sold several times to different companies. There is absolutely no chance to get official support for this legacy product.

    c) (really ugly, but may have its chance): Build up a pooling mechanism to prevent ever closing the connection. Sounds really ridiculous, doesn't it?