connect SSHClient and MySQL

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ysyang99
Posts: 16
Joined: Tue 04 Dec 2012 08:43

connect SSHClient and MySQL

Post by ysyang99 » Tue 09 Apr 2013 17:08

Hi

I use MyDAC 7.6.12 for Delphi 2009 and SecureBridge 5.5.1 for Delphi 2009

After sshclient connect , TMyconnection cannot connect MySQL server

error message is "Not overriden in an inherited class" (CRVio.pas line 372)

Please check a source code

Code: Select all

procedure TForm10.Button1Click(Sender: TObject);
var
  OldCursor: TCursor;
begin
  OldCursor := Screen.Cursor;
  try
    Screen.Cursor := crHourGlass;

    ScSSHClient.HostName := 'www.xxxx.com';
    ScSSHClient.User := 'www';
    ScSSHClient.Password := 'xxxx';
    ScSSHClient.Port := 22;
    ScSSHClient.Connect;

{
    ScSSHChannel.SourcePort := 5001;
    ScSSHChannel.DestPort := 3306;
    ScSSHChannel.DestHost := 'localhost';
    ScSSHChannel.Connect;
}


    if ScSSHClient.Connected then
    begin
      With MyConnection1 do
      begin
        IOHandler := MySSHIOHandler;
        Server := 'localhost';
        UserName := 'root';
        Password := 'xxx';
        Connect;
      end;

    end;
  finally
    Screen.Cursor := OldCursor;
  end;
end;

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: connect SSHClient and MySQL

Post by DemetrionQ » Thu 11 Apr 2013 10:34

Hello.

I run your code - everything works with no errors.
The specified error occurs in case if the ReadNoWait method is incorrectly overrided in the class of the object that is transfered to TMyConnection.IOHandler. Please check the CRSSHIOHandler unit - the ReadNoWait method must be present in the public section of the TCRSSHIOHandler class, it must be overrided and set as follows:

Code: Select all

TCRSSHIOHandler = class (TCRIOHandler)
...
public

 {$IFNDEF CLR}class{$ENDIF} function ReadNoWait(Handle: TCRIOHandle; {$IFDEF CLR}var {performance opt}{$ENDIF} buffer: TValueArr; offset, count: integer): integer; override;
...

{$IFNDEF CLR}class{$ENDIF} function TCRSSHIOHandler.ReadNoWait(Handle: TCRIOHandle;
  {$IFDEF CLR}var{performance opt}{$ENDIF} buffer: TValueArr; offset, count: integer): integer;
var
  Channel: TScSSHChannel;
  buf: TBytes;
begin
  Channel := Handle as TScSSHChannel;
  buf := TBytes(buffer);
  Result := Channel.ReadNoWait(buf, offset, count);
end;

Post Reply