Recent

Author Topic: [SOLVED] TMySQL50Connection and timeout  (Read 8814 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
[SOLVED] TMySQL50Connection and timeout
« on: May 24, 2010, 04:19:23 pm »
Hi,

I'm using TMySQL50Connection. When I don't send any queries for about one minute, every next query fails with errors: MySQL server has gone away. KeepConnection doesn't work (if it does what I think). I know this is server configuration, but how can I keep connection on client side? I can do some kind of timer and send simple query but maybe is any switch?

Regards
« Last Edit: May 26, 2010, 01:20:32 pm by Dibo »

Lacak2

  • Guest
Re: TMySQL50Connection and timeout
« Reply #1 on: May 25, 2010, 01:16:24 am »
KeepConnection property is not used at all, so changing it has no effect.
AFAIK there is no "automatic disconnect" feature, so I think, that source of your error message is in another place.

There is api function mysql_options with param MYSQL_OPT_RECONNECT ... http://dev.mysql.com/doc/refman/5.1/en/mysql-options.html

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: TMySQL50Connection and timeout
« Reply #2 on: May 25, 2010, 07:08:13 am »
Thanks for the tip. I found this function in mysql.inc
Code: [Select]
function mysql_options(mysql:PMYSQL; option:mysql_option; arg:Pchar):cint;extdecl;external mysqllib name 'mysql_options';But I don't know how to get a PMYSQL from TMySQL50Connection. It is in private section and there is no public property :/

Loesje

  • Full Member
  • ***
  • Posts: 168
    • Lazarus Support website
Re: TMySQL50Connection and timeout
« Reply #3 on: May 25, 2010, 04:54:14 pm »
The TMySQLConnection.Handle actually returns the PMYSQL you are looking for.

But it's better to add this option to TMysqlConnection, so that you can set it using TMysqConnection.Params. Can you create a bug report for that?

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: TMySQL50Connection and timeout
« Reply #4 on: May 26, 2010, 01:19:45 pm »
Thanks, now it works :D. Sample:
Code: [Select]
uses mysql50

procedure TForm1.Button1Click(Sender: TObject);
begin
  MySQL50Connection1.Connected := True;
  mysql_options(MySQL50Connection1.Handle, MYSQL_OPT_RECONNECT, 'true');
end;
Quote
Can you create a bug report for that
Yes, I can. Thanks for help. Must I lock this topic or just add [Solved] to subject?
« Last Edit: May 26, 2010, 01:37:27 pm by Dibo »

Lacak2

  • Guest
Re: [SOLVED] TMySQL50Connection and timeout
« Reply #5 on: May 28, 2010, 12:28:18 am »
You must fill bug report here: http://bugs.freepascal.org/my_view_page.php

eara

  • Jr. Member
  • **
  • Posts: 84
Re: [SOLVED] TMySQL50Connection and timeout
« Reply #6 on: April 17, 2014, 09:01:50 am »
thanks LaCak again....

tsr

  • New Member
  • *
  • Posts: 21
Re: [SOLVED] TMySQL50Connection and timeout
« Reply #7 on: January 24, 2016, 07:32:13 pm »
Thanks for this topic, it is still usable in 2016.

I added by myself Timer with setted interval at 2 minutes and in OnTimer procedure I use
Code: Pascal  [Select][+][-]
  1. mysql_ping(MySQLConnection.Handle);

Do you think it is a good solution?
Ubuntu 64bit

 

TinyPortal © 2005-2018