FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MySql Connection status?
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
MySql Connection status?
Posted: Wed Aug 01, 2018 03:07 AM

I would like to check the MySql server connection status.
I try
oCn:Connect()
oCn:lOpen

Both are returning .T. after connect but after I disconnect internet/intranet (lost the connection). It is still returning .T.

How can I know the connection status? Because, I will use oCn:Close(), oCn:Connect() after I know the connection is lost.

Thank you in advance.

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MySql Connection status?
Posted: Fri Aug 03, 2018 02:41 AM
Because, I will use oCn:Close(), oCn:Connect() after I know the connection is lost.

There is nothing you need to do to reconnect after a connection is lost. FWH lib automatically reconnects, if possible, when you do an operation.

Example:
Open a rowset and start browsing. After editing and saving a few changes, unplug the network cable. Now edits cannot be saved and the user gets a message that the connection is lost. But still, the user can continue browsing even if there is no connection but can not edit and save.
Now restore the connection. If you edit and save any value, the connection is "automatically re-established" and the edit and save works as usual.

Because the library provides automatic reconnection, the programmer needs to do nothing.

In case the auto-reconnection feature is not working as expected in any case, please let us know the circumstances and we will fix the issue immediately for you.

Information:
1. Method Connect(): There should be no need to use this method in an application program.
2. You can use these methods to check connection status if you like, but you do not really need to:
a) oCn:Ping() : If the connection is closed previously by calling oCn:Close(), Ping() returns .f.. If not it tries to reconnect and returns if the connection is really available.
b) oCn:Check(): Even if the connection was closed earlier, it tries the reconnect and returns if the connection is really available.
Regards



G. N. Rao.

Hyderabad, India
Posts: 346
Joined: Mon Oct 05, 2009 03:35 PM
Re: MySql Connection status?
Posted: Fri Aug 03, 2018 06:42 PM
Puede que esto te ayude

prolonga a 24 horas la conexión activa en MySql.

Code (fw): Select all Collapse
 oCn:Execute("SET SESSION wait_timeout = 86400;" )


Saludos
SkyPe: armando.lagunas@hotmail.com

Mail: armando.lagunas@gmail.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MySql Connection status?
Posted: Sat Aug 04, 2018 01:43 AM
armando.lagunas wrote:Puede que esto te ayude

prolonga a 24 horas la conexión activa en MySql.

Code (fw): Select all Collapse
 oCn:Execute("SET SESSION wait_timeout = 86400;" )


Saludos

It is good to set a larger limit to wait_timeout.
But in the case of FWH lib, it is not necessary.
Even if the connection is timed out, it is automatically restored when the application needs the connection.
Regards



G. N. Rao.

Hyderabad, India
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: MySql Connection status?
Posted: Mon Aug 06, 2018 10:08 AM

Hello Rao

is it possible use Ping() and Check with ADO ? or can you help me do these functions ?

Regards
Maurizio

Continue the discussion