Recent

Author Topic: [SOLVED] How to set timeout of mysql connection  (Read 4407 times)

heejit

  • Full Member
  • ***
  • Posts: 245
[SOLVED] How to set timeout of mysql connection
« on: March 22, 2018, 08:48:24 pm »
I am connecting to multiple mysql server to get some data
if any server is not connected within 4 seconds function
return error message and continue with next server

I am using SQLDB setting params has no effect

Code: Pascal  [Select][+][-]
  1.      conn.DatabaseName := db_name;
  2.       conn.HostName := ip;
  3.       conn.UserName := user;
  4.       conn.Password := pwd;
  5.       conn.Connected := True;
  6.       conn.Params.Add('connect_timeout=4');
  7.       Result := conn;
  8.       writeln('connected to :' + ip);
  9.  
« Last Edit: June 30, 2018, 05:54:19 pm by jshah »

Huandi

  • Newbie
  • Posts: 5
Re: How to set timeout of mysql connection
« Reply #1 on: June 19, 2018, 10:16:50 pm »
You need to change 5 and 6 lines of the place.

      conn.Params.Add('connect_timeout=4');
      conn.Connected := True;

heejit

  • Full Member
  • ***
  • Posts: 245
Re: How to set timeout of mysql connection
« Reply #2 on: June 20, 2018, 09:35:46 pm »
Not working

Connection still wait for default timeout

heejit

  • Full Member
  • ***
  • Posts: 245
Re: How to set timeout of mysql connection
« Reply #3 on: June 30, 2018, 05:53:52 pm »
Adding this solve the issue

TMySQL57Connection.Params.Add('MYSQL_OPT_CONNECT_TIMEOUT=5');


 

TinyPortal © 2005-2018