I am using MyDAC 7.1 and Lazarus 0.9.30-2 with FPC 2.4.4. Trying to run the following very simple project, I get the exception: "Can't connect to MySQL server on 'IP' (10061)."
Code: Select all
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp, MyAccess;
type
{ TMyApplication }
TMyApplication = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
{ TMyApplication }
procedure TMyApplication.DoRun;
var
ErrorMsg: String;
LConn: TMyConnection;
begin
// quick check parameters
ErrorMsg:=CheckOptions('h','help');
if ErrorMsg'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
// parse parameters
if HasOption('h','help') then begin
WriteHelp;
Terminate;
Exit;
end;
{ add your program here }
LConn := TMyConnection.Create(nil);
LConn.Server := 'IP';
LConn.LoginPrompt:=false;
LConn.Database := 'database';
LConn.Username:='user';
LConn.Password:='pass';
try
LConn.Connect;
finally
FreeAndNil(LConn);
end;
// stop program loop
Terminate;
end;
constructor TMyApplication.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor TMyApplication.Destroy;
begin
inherited Destroy;
end;
procedure TMyApplication.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ',ExeName,' -h');
end;
var
Application: TMyApplication;
{$R *.res}
begin
Application:=TMyApplication.Create(nil);
Application.Run;
Application.Free;
end.
Note that I can connect to the remote server using the mysql client.
Any ideas?