09-03-2012 06:09 AM
Dear colleagues,
Please help me about how can I do the automatic reconnect SQL server connection after lost.
Now the "DB open connection" I did at once before "while loop" and I don't want put into "while loop" in order to leave growth memory consumption
Solved! Go to Solution.
09-03-2012 07:06 AM
Opening the connection in the while loop should not increase memory consumption, provided you close each connection after use.
In your case you could close and reopen the connection in the while loop only if an error has been detected.
I usually avoid keeping a connection open it not strictly needed: I prefer to open-use-close the connection each time.
Regards,
Marco
09-04-2012 10:04 PM
Dear Marco
With your "open-use-close connection" how much long application works?
Simply my application is working in 24/7 () and I try to minimize memory consumption... Unfortunately LV can't working in uninterrupt mode
09-04-2012 10:49 PM
THe overhead for the open/close is very little. We have not observed any issues when using this method.
09-05-2012 01:31 AM
Opening/closing the connection to a database placed in our local network takes e few ms.
Since we are executing queries about once every 30s we chose the open-query-close approach (which has a "bult-in retry" in a certain sense...)
A look here could help confusing the ideas about what's better 🙂 :
http://stackoverflow.com/questions/312702/is-it-safe-to-keep-database-connections-open-for-long-time
Regards,
Marco
09-17-2012 07:45 AM
We were closing and opening a connection every time and we decided to change because the virtual memory increases considerably. So, we opened the connection before the while inserting a case inside the while which detects an error with the communication and if thats the case reconnect the communication.
06-09-2018 05:21 PM
how about a SQL state machine, see attached