Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Zeos 6.6.6 -> Oracle 10g Verbindungsversuch schlägt fehl (https://www.delphipraxis.net/155532-zeos-6-6-6-oracle-10g-verbindungsversuch-schlaegt-fehl.html)

Klaus01 27. Okt 2010 14:58

Datenbank: Oracle • Version: 10g • Zugriff über: Zeos 6.6.6-stable

Zeos 6.6.6 -> Oracle 10g Verbindungsversuch schlägt fehl
 
Hallo,

stehe vor einem Problem und weiß nicht so recht weiter.

Ich versuche mich auf den Port 1521 (dort läuft der Listener) zu verbinden.
Delphi-Quellcode:
var
  ZConnection : TZConnection;
  SQLQuery : TZReadOnlyQuery;
  dataSet : TClientDataSet;
  SQLStatement : TStringList;
  dbResult : TStringList;
begin
  ZConnection := TZConnection.Create(nil);
  try
    ZConnection.Protocol := 'oracle-9i';
    ZConnection.HostName := configData.getDatabaseSettings.dbServerAddress;
    ZConnection.Port := configData.getDatabaseSettings.dbListenerPort;
    ZConnection.User := configData.getDatabaseSettings.dbUserName;
    ZConnection.Password := configData.getDatabaseSettings.dbPassword;
    ZConnection.database := 'oss';
    try
      ZConnection.Connect;
      logData.addItem('Connection to db established');
    except
      on E:Exception do
        logData.addItem('Error connecting to the database: '+e.Message);
    end;
Hier haut es mich immer raus:

Delphi-Quellcode:
procedure TZOracleConnection.Open;
var
  Status: Integer;
  LogMessage: string;
//  ConnectTimeout: Integer;
//  SQL: PChar;

  procedure CleanupOnFail;
  begin
    FPlainDriver.HandleFree(FContextHandle, OCI_HTYPE_SVCCTX);
    FContextHandle := nil;
    FPlainDriver.HandleFree(FErrorHandle, OCI_HTYPE_ERROR);
    FErrorHandle := nil;
    FPlainDriver.HandleFree(FServerHandle, OCI_HTYPE_SERVER);
    FServerHandle := nil;
  end;

begin
  if not Closed then Exit;

  LogMessage := Format('CONNECT TO "%s" AS USER "%s"', [Database, User]);

  { Sets a default port number. }
  if Port = 0 then Port := 1521;
  { Sets connection timeout. }
//  ConnectTimeout := StrToIntDef(Info.Values['timeout'], 0);

  { Connect to Oracle database. }
  if FHandle = nil then
    FPlainDriver.EnvInit(FHandle, OCI_DEFAULT, 0, nil);
  FErrorHandle := nil;
  FPlainDriver.HandleAlloc(FHandle, FErrorHandle, OCI_HTYPE_ERROR, 0, nil);
  FServerHandle := nil;
  FPlainDriver.HandleAlloc(FHandle, FServerHandle, OCI_HTYPE_SERVER, 0, nil);
  FContextHandle := nil;
  FPlainDriver.HandleAlloc(FHandle, FContextHandle, OCI_HTYPE_SVCCTX, 0, nil);

  Status := FPlainDriver.ServerAttach(FServerHandle, FErrorHandle,
    PChar(string(Database)), Length(Database), 0);
  try
    CheckOracleError(FPlainDriver, FErrorHandle, Status, lcConnect, LogMessage);
    //Hier springt die Routine immer in die Exception
    // FPlainDriver : TZOracle9iPlainDriver($C6DB38) as IZOraclePlainDriver
    // FErrorHandle: nil
    // Status : -1
    // lcConnect : lcConnect
    // LogMessage: CONNECT TO ... as USER ..
  except
    CleanupOnFail;
    raise;
  end;

  // stuff deleted
Die Exception ist auch nicht sehr aussagekräftig:
Zitat:

---------------------------
Debugger Exception Notification
---------------------------
Project .... raised exception class EZSQLException with message 'SQL Error: ë#B'.
---------------------------
Break Continue Help
---------------------------
Mache ich hier etwas grundsätzlich falsch?
Kennt jemand das Problem und deren Lösung?

Nachtrag: die oci.dll ist Version 11.2.0.1
Nachtrag2: Der Port ist erreichbar: mit telnet IP-Adresse 1521 kommt eine Verbindung zustande.
Nachtrag3: Der Inhalt der ErrorMessage:

Zitat:

('ë', '#', 'B', #0, #0, #4, #0, #0, #1, #0, #0, #0, 'X', 'R', 'Æ', #0, #3, #0, #0, #0, #16, #157, 'P', #0, #3, #0, #0, #0, '(', 'ù', #18, #0, #20, 'ù', #18, #0, '"', '/', '@', #0, 'J', 'N', '@', #0, 'L', 'Ò', 'A', #0, 'x', 'ù', #18, #0, #6, '/', '@', #0, 'Õ', 'N', '@', #0, #12, #0, #0, #0, #3, #0, #0, #0, #24, 'O', '@', #0, #16, #157, 'P', #0, #0, #16, 'Ä', #0, #3, #0, #0, #0, 'L', 'S', '@', #0, 'L', 'Ò', 'A', #0, '™', #16, 'B', #0, 'x', 'ù', #18, #0, '\', 'ù', #18, #0, '¸', #16, 'B', #0, 'À', #16, 'B', #0, 'ü', 'ù', #18, #0, #0, #16, 'Ä', #0, #4, #0, #0, #0, #0, #0, #0, #0, '„', 'ù', #18, #0, #4, #0, #0, #0, #0, #16, 'Ä', #0, 'u', '/', '@', #0, #24, #16, 'Ä', #0, 'Ê', '"', 'B', #0, #4, #0, #0, #0, #0, #16, 'Ä', #0, 'e', ' ', 'B', #0, #0, #16, 'Ä', #0, '|', '!', 'B', #0, #0, #0, #0, #0, ',', #13, #0, #0, 'X', 'R', 'Æ', #0, ':', #3, 'A', #0, #0, #4, #0, #0, #0, #0, #0, #0, 'k', 'õ', 'Æ', #0, #1, #0, #0, #0, ',', #13, #0, #0, #8, 'á', 'S', #0, 'ë', '#', 'B', #0, #0, #4, #0, #0, #1, #0, #0, #0, '¸', 'R', 'Æ', #0, #3, #0, #0, #0, #8, 'á', 'S', #0, #8, #0, #0, #0, 'W', 'I', 'S', #0, '(', 'Ý', 'Å', #0, 'à', 'ù', #18, #0, 'f', 'R', 'S', #0)
kann da leider nicht erkennen.
Grüße
Klaus

Klaus01 28. Okt 2010 12:04

AW: Zeos 6.6.6 -> Oracle 10g Verbindungsversuch schlägt fehl
 
so, mit zeos habe ich das Problem nicht lösen können.

Habe nun ODAC (devart) in der Testversion versucht.
Ich muss sagen - Hut ab.
Bin begeistert.

Delphi-Quellcode:
uses
  ..Ora,OdacVcl;

Function ....
var
  oracleSession : TOraSession;
  SQLQuery : TOraQuery;
  SQLStatement : TStringList;
  dbResult : TStringList;
begin
  oracleSession := TOraSession.Create(nil);
  try
    oracleSession.ConnectPrompt := false;
    oracleSession.Options.Net := true;
    oracleSession.Server := configData.getDatabaseSettings.dbServerAddress+':'+
                            intToStr(configData.getDatabaseSettings.dbListenerPort)+':'+
                            configData.getDatabaseSettings.dbSID;

    oracleSession.Username := configData.getDatabaseSettings.dbUserName;
    oracleSession.Password := configData.getDatabaseSettings.dbPassword;
    try
      oracleSession.Connect;
      logData.addItem('Connection to db established');

      SQLQuery := TOraQuery.Create(nil);
      SQLStatement := TStringList.Create;
      dbResult := TStringList.Create;
      try
        SQLQuery.Close;
        SQLQuery.Session := oracleSession;
        SQLStatement.Text := '...';
        SQLQuery.SQL := SQLStatement;
        try
          SQLQuery.Open;
        except
          on E:Exception do
            begin
              logData.addItem('SQL Error: '+E.Message);
            end;
        end;
        if SQLQuery.Active then
          if SQLQuery.RecordCount > 0 then
            while not SQLQuery.Eof do
              begin
                dbResult.Add(SQLQuery.Fields[0].asString+';'+SQLQuery.Fields[1].asString);
                SQLQuery.Next;
              end;
      finally
        if assigned(dbResult) then
          eNodeBList.Assign(dbResult)
        else
          eNodeBList := nil;

        SQLQuery.Close;
        freeAndNil(SQLQuery);
        freeAndNil(SQLStatement);
        freeAndNil(dbResult);
      end;

    except
      on E:Exception do
        logData.addItem('Error connecting to the database: '+e.Message);
    end;

  finally
    oracleSession.Disconnect;
    logData.addItem('Connection to db closed');
    freeAndNil(oracleSession);
    result := eNodeBList;
  end;
end;
Grüße
Klaus


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:14 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz