1

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?

Stefano Mtangoo
  • 6,017
  • 6
  • 47
  • 93

2 Answers2

0

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!

Stefano Mtangoo
  • 6,017
  • 6
  • 47
  • 93
0

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

Janaka
  • 489
  • 1
  • 4
  • 23