简体   繁体   English

Soci会话未释放连接

[英]Soci Session is not releasing connection

I'm using soci for making my app interact with databases and currently I use MySQL server to test. 我正在使用soci来使我的应用程序与数据库交互,目前我正在使用MySQL服务器进行测试。 I have wrapped SOCI into simple class where I call session.open() in Connect method of my class 我已经将SOCI包装到简单的类中,在该类的Connect方法中调用session.open()

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

Then in destructor I call the close method 然后在析构函数中调用close方法

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. 但是当我几次使用该类(创建和销毁该类的对象)时,我发现soci无法连接到MySQL服务器,并且连接错误过多。 I'm confused since I call the close method on destructor, I suppose that soci should release the connection. 我很困惑,因为我在析构函数上调用了close方法,所以我想soci应该释放连接。 Checking soci docs I cannot see anything than close(). 检查社会文档,除了close()我什么都看不到。

Is there a way to force soci::session to release connection? 有没有办法强制soci :: session释放连接?

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! 现在一切都好!

您可以通过soci :: session.close()函数关闭SOCI:Session

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM