MySql Connection status?

MySql Connection status?

Postby dutch » Wed Aug 01, 2018 3: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 19.01 / 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)
User avatar
dutch
 
Posts: 1548
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: MySql Connection status?

Postby nageswaragunupudi » Fri Aug 03, 2018 2: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
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MySql Connection status?

Postby armando.lagunas » Fri Aug 03, 2018 6:42 pm

Puede que esto te ayude

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

Code: Select all  Expand view  RUN
oCn:Execute("SET SESSION wait_timeout = 86400;" )


Saludos
SkyPe: armando.lagunas@hotmail.com
Mail: armando.lagunas@gmail.com
User avatar
armando.lagunas
 
Posts: 346
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile

Re: MySql Connection status?

Postby nageswaragunupudi » Sat Aug 04, 2018 1:43 am

armando.lagunas wrote:Puede que esto te ayude

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

Code: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MySql Connection status?

Postby Maurizio » 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
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 66 guests