MyConnection->Connected says its connected..... but server is switched off

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Rocojo
Posts: 18
Joined: Tue 24 Jan 2006 12:57
Location: Eindhoven, The Netherlands

MyConnection->Connected says its connected..... but server is switched off

Post by Rocojo » Thu 09 Feb 2006 14:56

I've builded a .dll (C++ builder and MyDAC 40028) witch is acting as a communicationlayer between my software and the databaseserver.


I still have some strange issues:

MyConnection problem:
After a MyConnection is connected and i swith of the server..... the MyConnection component is still saying that it has connection (MyConnection->Connected() == true)..... ( thats impossible when the server is switched off)

Closing problem:
By closing the driver while it is connecting with a server i cannot stop the MyConnection. Is it possible to destroy the connect() action?


Please help (oh sorry for my bad english)

Rocojo
Posts: 18
Joined: Tue 24 Jan 2006 12:57
Location: Eindhoven, The Netherlands

Post by Rocojo » Thu 09 Feb 2006 15:32

hmmm ok i found out that when i am going to use the connection the component is saying.... no way you have no connection...and then myconnectionconnected == false


good to know

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 10 Feb 2006 14:08

> the MyConnection component is still saying that it has connection
> >(MyConnection->Connected() == true).....

MyDAC components doesn't check connection to the server all the time. The connection is checked only if it's necessary to get from the server any information. But you can check the connection manually using MyConnection.Ping.

>Is it possible to destroy the connect() action?

What do you mean by destroying the connection action? What is the reason to do this?

Rocojo
Posts: 18
Joined: Tue 24 Jan 2006 12:57
Location: Eindhoven, The Netherlands

Post by Rocojo » Mon 20 Feb 2006 10:12

In someway it takes quite a while to connect over a network with a mysql server. This is no problem because i made a thread within the connect action. But the problem is: when i want to close my program i have to wait for all the threads to be closed because i cannot stop the thread while the myconnection is trying to connect with the server.

But i think this is a problem in Microsoft Windows because when i am browsing the network, windows hangs a few seconds to....

I thought maybe it is possible to destroy the myconnection component so it is not searching for the server anymore.

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Mon 20 Feb 2006 21:44

I find that one of the great things is that connections are made very quickly.. Check your settings, also if your server is connected to internet and the DNS servers. When connecting, mysql resolves the name of connection to checkup the user/privileges.

I normally add the

Code: Select all

skip-name-resolve
to the MySQL config files (my.ini under windows, my.cnf under linux). Look at http://dev.mysql.com/doc/refman/5.1/en/dns.html for more details.

Rocojo
Posts: 18
Joined: Tue 24 Jan 2006 12:57
Location: Eindhoven, The Netherlands

Post by Rocojo » Fri 24 Feb 2006 13:06

oh, ok thank you for your reply.

I will try the skip-name-resolve and check my settings.

Rocojo
Posts: 18
Joined: Tue 24 Jan 2006 12:57
Location: Eindhoven, The Netherlands

Post by Rocojo » Mon 27 Feb 2006 10:53

It's working... connecting to the server is really fast! thank you very mutch.

I found another problem in my DLL.

When i want to close my application (which is using my dll) i got an error.

Is the following code correct? ( i know this is not the forum for these questions but nobody can answer it.... so i hope somebody can help me.)

#pragma argsused
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return (true);
}
//---------------------------------------------------------------------------

std::auto_ptr ASBSQLForm(new TASBSQLForm1(NULL));

extern "C" _declspec(dllexport) AnsiString __stdcall ASBDD_Connection_Connect( void )
{
ASBSQLForm->ASBDDInsertSelectConnectEvent = true;
return ("true");
}

Post Reply