[Cppcms-users] Cppcms-users] cppdb: test connect to database and reconnection
Brought to you by:
artyom-beilis
From: Daniel V. <chi...@gm...> - 2010-12-28 21:40:08
|
Hello. I can't find a method to test database connection. I think there is no such method (Similarly, there is no such method in SOCI). I think this method would be useful for connection error handling and robustness. Another issue related: When connection is lost to database and we reconnect later, we need to re build all prepared statements. The ideal would have a statement object to be rebuilt when its associated session is reconnected. This would be a code like this: cppdb::session sql("..."); ... if (! sql.is_connect() ) { sql.reconnect(); // reconnect session and rebuild all prepared statement associated } Would it be possible in future cppdb releases? For example in mysql by default the server closes the connection after eight hours if nothing has happened. ( "MySQL server has gone away" error ). Then a web application that is idle for 8 hours or more suffer from such problems. What is the proper way to deal with this problem with actual version? Thank you. |