Can't connect to Mysql server ... on XP machine

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Can't connect to Mysql server ... on XP machine

Post by 777Yves » Tue 24 Apr 2012 19:51

Hi, I use Delphi XE with Mydac 6.10.0.7.
I could access the Mysql server from any PC running W7 but not on XP PC.

Do you have an idea, a clue ?

More stanger, I have a XP PC that has a .exe on my application that is old of a few month and it works.

Thanks

Yves

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

Post by AlexP » Wed 25 Apr 2012 09:25

Hello,

Please send the text or the screenshot of the error message you get when attempting to connect to the server. Also please specify the exact MySQL server and IDE versions.

777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Post by 777Yves » Wed 25 Apr 2012 10:19

Error message are:

Can't connect to mysql server on localhost 10061
Socket error on connect. WSAJetLastError return 10061

in a new error window
Application error
The exception unknown software exception (0x0eedfade) occured in the application at location 0x7c812a5b

in a new error window
Erreur d'application
Exception EMyError dans le module Fmrq.exe en 0021AFD1
Can't connect to mysql server on localhost 10061
Socket error on connect. WSAJetLastError return 10061


I use Delphi XE update 1 with Mydac 6.10.0.7. and Mysql 5.5.22

777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Can't connect to Mysql server ... on XP machine

Post by 777Yves » Wed 25 Apr 2012 11:10

More info, the first module that load in the application is a DataModule that execute this procedure. I put a trace with 2 messages and none of them show on screen with XP. On W7 I have no error and I could see both messages.

Code: Select all

procedure TDmFmrq.DataModuleCreate(Sender: TObject);
var
  reg: TRegistry;
begin
  // voir procedure TDmFmrq.adFmrqError(Sender: TObject; E: EDAError; var Fail: Boolean);
  reg         := TRegistry.Create;
  reg.RootKey := HKEY_CURRENT_USER;
  if reg.OpenKey('\Software\FMRQMySql\, False) then
  begin
    // ShowMessage('debug dmFmrq in ok 100');
    MotDePasse := reg.ReadString('MotDePasse');
    Serveur    := reg.ReadString('Serveur');
    PortAcces  := reg.ReadString('PortAcces');
    NomUsager  := reg.ReadString('NomUsager');

    adFmrq.Password  := MotDePasse;
    adFmrq.Server    := Serveur;
    adFmrq.Port      := StrToInt(PortAcces);
    adFmrq.Username  := NomUsager;
    reg.CloseKey;
    reg.Free;

    ShowMessage('L923 ' + MotDePasse + ', ' + Serveur + ', ' + PortAcces + ', ' + NomUsager);
    try
      ShowMessage('L925 ' + MotDePasse + ', ' + Serveur + ', ' + PortAcces + ', ' + NomUsager);
      adFmrq.Connected := True;
    except
      FmLogin := TFmLogin.Create(self);
      FmLogin.showmodal;
      FmLogin.Free;
      DmFmrq.Free;
//      Application.Terminate;
    end;
  end
  else
  begin
    reg.CloseKey;
    reg.Free;
    FmLogin := TFmLogin.Create(self);
    FmLogin.showmodal;
    FmLogin.Free;
    DmFmrq.Free;
//    Application.Terminate;
  end;
end;

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

Post by AlexP » Wed 25 Apr 2012 11:56

Hello,

In the code you sent, the ShowMessage methods are in the IF block, and if IF = false, you won't see these messages. You are trying to obtain data from the registry in your code:

Code: Select all

if reg.OpenKey('\Software\FMRQMySql\, False) then 
and if this method returns False, this means that there is no such key in the registry or you don't have access, and this problem is not due to MyDAC. To check the opportunity to connect to the server, try to set the connection parameters explicitly in MyConnection and connect to the server.

777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Post by 777Yves » Wed 25 Apr 2012 17:57

Hi,
To check the opportunity to connect to the server, try to set the connection parameters explicitly in MyConnection and connect to the server.
Yes, I try this and it does not connect to the server.
but
I thing that I have found a clue.
Is it possible that the problem happen because TMyConnection is set connected = true in the IDE and because those XP pc have to establish a connection first they crash.
On the other hand, all W7 pc that I tested were mysql server itself and my development pc where XE is install.

Yves

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

Post by AlexP » Thu 26 Apr 2012 07:28

Hello,

Please try connecting to your MySQL server using the following console application, and inform us about the results.

Code: Select all

program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils, MyAccess;
var
  MyConnection: TMyConnection;
begin
  MyConnection := TMyConnection.Create(nil);
  try
    MyConnection.Server := host;
    MyConnection.Port := 3306;//port
    MyConnection.Database := database;
    MyConnection.Username := login;
    MyConnection.Password := password;
    try
      MyConnection.Connect;
      Writeln('OK');
    except
      on E: Exception do
        Writeln('Error: ' + E.Message);
    end;
  finally
    MyConnection.Free;
    Readln;
  end;
end.

777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Can't connect to Mysql server ... on XP machine

Post by 777Yves » Thu 26 Apr 2012 12:13

Hi, yes this work OK.

I did a lot of testing to.
The problem happen because TMyConnection was set connected = true in the IDE.
On XP PC for some reason, the application crash.
On W7 pc the application close the connection and establish a new one.

More tests with my app. with connected = false.
If I stop the service MySql.
- On XP PC I receive exact same error message that I describe in my first email and the application crash.
- On W7 pc the application give me the exact same error message that I describe in my first email but the application did not crash.
- With your console app. on XP, the pc did not crash and give me the same message 10061.


When TMyConnection is set connected = false in the IDE, I have no problem on XP or W7.

Thanks

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

Post by AlexP » Thu 26 Apr 2012 13:08

Hello,

In your case, AccessViolation occurs due to that the DataModule Free method calls itself after connection failure, and this behaviour is similar for any platform.
If you don't want the connection set in design-time to be opened when the application is executed, you should set the MyConnection.Options.KeepDesignConnected property to false. In this case, the connection won't be open automatically after the application is executed.

777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Can't connect to Mysql server ... on XP machine

Post by 777Yves » Thu 26 Apr 2012 13:34

Hi, ok great.

I don't see any documentation that talk about that option ...

Thanks

Yves

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

Post by AlexP » Thu 26 Apr 2012 13:49

hello,

This property is described in the TDAConnectionOptions.KeepDesignConnected Property section of the help file

777Yves
Posts: 37
Joined: Mon 09 Aug 2010 19:55
Location: Québec

Post by 777Yves » Thu 26 Apr 2012 14:04

Yes that is true if you dig in the help file a bit but put the cursor on that property in the ide and try F1.
From my installation here, I don't see that documentation, only some property are there.

Should I see it ?

Any way, the problem is resolve, that make my day.


Thanks again.

Yves

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

Re: Can't connect to Mysql server ... on XP machine

Post by AlexP » Fri 27 Apr 2012 13:31

Hello,

Thank you for the information. We will try to fix passage and positioning by F1 in the help.

Post Reply