Hi,
Is there a proper way to disconnect after an "lost connection to mysql" error message ?
How can I handle this type of error and force the user to reconnect again ?
			
									
									
						How can I safely handle Database disconnection ?
- 
				swierzbicki
 - Posts: 451
 - Joined: Wed 19 Jan 2005 09:59
 
After losing connection MyDAC tries to reconnect automatically, but datasets become closed. If you try to open a dataset or execute a query, connection will become active again.
In the nearest several months new version of MyDAC will be available. In this version MyDAC will be able to handle lost connection automatically with no user's error messages.
			
									
									
						In the nearest several months new version of MyDAC will be available. In this version MyDAC will be able to handle lost connection automatically with no user's error messages.
- 
				eduardosic
 - Posts: 387
 - Joined: Fri 18 Nov 2005 00:26
 - Location: Brazil
 
solution...
had many problems with lost connection, later that you change the variaveis of my.ini this finished:Antaeus wrote:After losing connection MyDAC tries to reconnect automatically, but datasets become closed. If you try to open a dataset or execute a query, connection will become active again.
In the nearest several months new version of MyDAC will be available. In this version MyDAC will be able to handle lost connection automatically with no user's error messages.
connect_timeout = 99999999
interactive_timeout = 99999999
net_read_timeout = 99999999
net_write_timeout = 99999999
slave_net_timeout = 99999999
wait_timeout = 99999999
max_connections = 99999999
max_user_connections = 99999999
in windows xp, try fix the register..
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"MaxUserPort"=dword:0000fffe
HI 
I can understand why you would increase the different timeout settings. But 99999999 is over 3 years!!! I find that a little over the top
 
If something is wrong the connection will "never" timeout and the program will "never" stop running.
A timeout setting in the seconds or minuts range would (for me) be more convinient
 
Max_connections = 99999999 could be dangerous. Your server could run out off memory or more likely run out of hardware memory and start to swap memory to and from the harddisc.
It is better to set Max_Connections to a more realistic number. I had an error, where I had forgot to close and free a MySQL connection in a rarely used function. That resulted in a the number of connections slowly grow and grow until the Max was reached and I got a "Too Many Connections" error.
If I have had Max_connections = 99999999, I might never had look for the error. I would have run into memory problems long before I would have gotten the "Too Many Connections" error.
 
The Max_User_Connections = 99999999 is not needed. The default setting Max_User_Connections = 0 means that there is no limit to the maximum connection a user can have. So why inforce a nearly unreacheble high one of 99999999?
This is not meant as an insult, I just wanted to bring some balance to your otherwise good idea
Your post made me check my settings and I found that my Connect_Timeout = 0, might be a reason for some of the "Couldn't connect to MySQL server" Errors I sometimes get. So I have changed it to Connect_Timeout = 5 on my 2 live servers as well as on my test server. Not as radical as your setting, but a significant change anyway.
So I would like to thank you, eduardosic, for making me check my settings
 
Best regards
TheLion
			
									
									
						I can understand why you would increase the different timeout settings. But 99999999 is over 3 years!!! I find that a little over the top
If something is wrong the connection will "never" timeout and the program will "never" stop running.
A timeout setting in the seconds or minuts range would (for me) be more convinient
Max_connections = 99999999 could be dangerous. Your server could run out off memory or more likely run out of hardware memory and start to swap memory to and from the harddisc.
It is better to set Max_Connections to a more realistic number. I had an error, where I had forgot to close and free a MySQL connection in a rarely used function. That resulted in a the number of connections slowly grow and grow until the Max was reached and I got a "Too Many Connections" error.
If I have had Max_connections = 99999999, I might never had look for the error. I would have run into memory problems long before I would have gotten the "Too Many Connections" error.
The Max_User_Connections = 99999999 is not needed. The default setting Max_User_Connections = 0 means that there is no limit to the maximum connection a user can have. So why inforce a nearly unreacheble high one of 99999999?
This is not meant as an insult, I just wanted to bring some balance to your otherwise good idea
Your post made me check my settings and I found that my Connect_Timeout = 0, might be a reason for some of the "Couldn't connect to MySQL server" Errors I sometimes get. So I have changed it to Connect_Timeout = 5 on my 2 live servers as well as on my test server. Not as radical as your setting, but a significant change anyway.
So I would like to thank you, eduardosic, for making me check my settings
Best regards
TheLion