Página 1 de 1
mysql connection
Publicado: Sab Ene 21, 2012 2:17 pm
por Roberto
I have an application with mysql. It works fine but if I stop using it for a few minutes the mysql connection is lost (Lost connection to MySQL during query #2013).
There is no problem with the network and the server is ok.
mysql connection
Publicado: Mié Ene 25, 2012 2:31 pm
por Roberto
No answer?
mysql connection
Publicado: Mié Ene 25, 2012 3:28 pm
por Martin Del Angel
#include "Xailer.ch"
//---------------------------------------------------------- --------------------
// SOPORTE CONEXION DATA SOURCE MySQL
//---------------------------------------------------------- --------------------
#define DK_DEFAULT_OR_NOT DEFAULT // Why ? :'(
CLASS TMySQLDataSource FROM XMySQLDataSource
METHOD CheckError( cArgument, nStackLevel )
METHOD Recupera( cArgument )
ENDCLASS
//---------------------------------------------------------- --------------------
METHOD CheckError( cArgument, nStackLevel ) CLASS TMySQLDataSource
LOCAL oErr, lSuccess , x:=0
IF ::nLastError != 0
IF ::nLastError==2006 // MySQL server has gone away
::Recupera(cArgument)
ELSEIF ::nLastError==2013 // MySQL server lost
::Recupera(cArgument)
ELSEIF ::nLastError==2014 // MySQL Command Out if Sync
::Recupera(cArgument)
ELSE
IF Len( cArgument ) > 4096
cArgument := Left( cArgument, 4096 ) + "..."
ENDIF
::NewError( ::cLastError, ::nLastError,, "MySQL:" + cArgument )
ENDIF
ENDIF
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD Recupera( cArgument ) CLASS TMySQLDataSource
LOCAL oErr, lSuccess , x:=0
*MSGINFO(::nLastError)
IF ::nLastError!=2014 // MySQL Command Out if Sync
::Disconnect()
ENDIF
ProcessMessages(); Sleep( 10 )
Waiton('Reconectado con Servidor...')
For x:=1 to 10
lSuccess := ::Connect(); ProcessMessages(); Sleep( 10 )
if( !lSuccess )
loop
endif
NEXT
WaitOff()
if( !lSuccess )
::NewError( ::cLastError, ::nLastError,, "MySQL:" + cArgument )
endif
RETURN NIL
mysql connection
Publicado: Mié Ene 25, 2012 7:37 pm
por jrcpoli-quitar
El 25/01/2012 15:28, Martin Del Angel escribió:
> On 1/25/2012 7:31 AM, Roberto wrote:
>> No answer?
>
> Hi Roberto:
>
> Add this prg to your Projects and recompile.
>
>
> Some Messages are in Spanish, change them to English.
>
>
> Regards.
>
> Martin Del Angel
> T&T SOFTWARE DE MEXICO SA DE CV
>
www.tytsoftwaredemexico.com
Greetings:
If you use the "prg" has commanded you "Martin Del Angel", you must
add these two functions that you attached.
The functions "WaitOn" and "WaitOff" prg are included in the
"Messages" whose author is "Bingen", you can look at
http://xailer.info/esp/?p=239
José R.Castro.
--
mysql connection
Publicado: Jue Ene 26, 2012 6:22 am
por Martin Del Angel
On 1/25/2012 12:37 PM, José Ramón Castro Polinio wrote:
> El 25/01/2012 15:28, Martin Del Angel escribió:
>> On 1/25/2012 7:31 AM, Roberto wrote:
>>> No answer?
>>
>> Hi Roberto:
>>
>> Add this prg to your Projects and recompile.
>>
>>
>> Some Messages are in Spanish, change them to English.
>>
>>
>> Regards.
>>
>> Martin Del Angel
>> T&T SOFTWARE DE MEXICO SA DE CV
>>
www.tytsoftwaredemexico.com
>
> Greetings:
>
> If you use the "prg" has commanded you "Martin Del Angel", you must add
> these two functions that you attached.
> The functions "WaitOn" and "WaitOff" prg are included in the "Messages"
> whose author is "Bingen", you can look at
http://xailer.info/esp/?p=239
>
> José R.Castro.
Thanks José for the Additional Info.
Best Regards...
mysql connection
Publicado: Jue Ene 26, 2012 11:12 am
por jfgimenez
Roberto,
> I have an application with mysql. It works fine but if I
> stop using it for a few minutes the mysql connection is lost
> (Lost connection to MySQL during query #2013).
> There is no problem with the network and the server is ok.
The component TMySQLDatasource has a built-in procedure to do pings to
the server, in order to reconnect if the conection has closed due a
timeout. It's driven by the 'nTimeout' property, which is setted to 1000
seconds by default. Try to change it to a lower value, f.e. 180 (3 minutes).
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info