Question

I'm using soci for making my app interact with databases and currently I use MySQL server to test. I have wrapped SOCI into simple class where I call session.open() in Connect method of my class

m_session.open(soci::mysql, connString);

Then in destructor I call the close method

m_session.close();

But When I use the class few times (creating and destroying objects of this class) I find that soci fails to connects to MySQL server with error too many connections. I'm confused since I call the close method on destructor, I suppose that soci should release the connection. Checking soci docs I cannot see anything than close().

Is there a way to force soci::session to release connection?

Was it helpful?

Solution

I found somehow my destructor was not getting called because I had unhandled exception in one of my class methods. I re-designed my class and handled that exception too. All is well now!

OTHER TIPS

You can just close the SOCI:Session by soci::session.close() function

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top