Home » U++ Library support » U++ SQL » Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
Patch: Reconnecting PostgreSQL Automatically on Unstable Networks [message #26366] |
Tue, 27 April 2010 19:21 |
zsolt
Messages: 697 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
After a network connection problem or coming back from suspend, it is convenient for your users to reconnect your app to the server automatically.
I did not want to write a lot of code dealing with this problem, so I patched PostgreSQL classes.
Using this patch PostgreSQL classes reconnect to the server on connection problems. They try to reconnect only once and not within transactions.
In void PostgreSQLSession::ExecTrans(const char * statement) change the rowresult = PQexec(conn, statement);
to for(int i=0; i<2; i++){
result = PQexec(conn, statement);
if(level==0 && !ConnectionOK())
if(!ReOpen()) return;
else continue;
break;
}
and in bool PostgreSQLConnection::Execute() change the row result = PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);
to for(int i=0; i<2; i++){
result = PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);
if(session.level==0 && !session.ConnectionOK())
if(!session.ReOpen()) return false;
else continue;
break;
}
|
|
|
|
|
Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: zsolt on Tue, 27 April 2010 19:21
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: mirek on Tue, 27 April 2010 20:21
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: zsolt on Tue, 27 April 2010 21:19
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: zsolt on Wed, 28 April 2010 14:31
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: mirek on Thu, 29 April 2010 23:55
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: zsolt on Fri, 30 April 2010 01:41
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: mirek on Fri, 30 April 2010 10:53
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: zsolt on Tue, 04 May 2010 12:11
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: mirek on Mon, 17 May 2010 14:47
|
|
|
Re: Patch: Reconnecting PostgreSQL Automatically on Unstable Networks
By: zsolt on Mon, 17 May 2010 15:44
|
Goto Forum:
Current Time: Sun Apr 28 05:52:32 CEST 2024
Total time taken to generate the page: 0.05253 seconds
|