首页 > 数据库 >QSqlDatabasePrivate::removeDatabase: connection ‘myConnection’ is still in use, all queries will cea

QSqlDatabasePrivate::removeDatabase: connection ‘myConnection’ is still in use, all queries will cea

时间:2023-07-19 20:46:04浏览次数:58  
标签:use QSqlDatabasePrivate work db connection cease removeDatabase still 连接

1. 解决QSqlDatabasePrivate::removeDatabase: connection ‘myConnection’ is still in use, all queries will cease to work的问题

该问题主要是因为没有关闭之前的数据库连接,然后又需要创建新的数据库连接导致。解决方案:必须释放该连接的所有查询,即删除所有与该连接有关的query;同时在释放该连接时,需要先获取该连接的连接名,然后先关闭当前数据库,并将当前数据库使用默认构造函数覆盖,最后再移除当前连接。
解决代码:
void database::close()
{
QString connection;
connection = m_db.connectionName();
m_db.close();
m_db = QSqlDatabase();
m_db.removeDatabase(connection);
}
参考链接:http://stackoverflow.com/questions/9519736/warning-remove-database
http://stackoverflow.com/questions/8461333/sql-connection-still-open-even-after-deleting-it

标签:use,QSqlDatabasePrivate,work,db,connection,cease,removeDatabase,still,连接
From: https://www.cnblogs.com/totogo/p/17566670.html

相关文章

  • Android GO 版本源码中preferred network type显示
    AndroidGO版本源码中preferrednetworktype的显示作为一名经验丰富的开发者,我将向你解释如何在AndroidGO版本的源码中实现"preferrednetworktype"的显示。下面是实现这个功能的步骤:步骤概览步骤动作步骤1创建一个新的Android项目步骤2添加必要的权限步骤......
  • MySQL到ClickHouse数据同步方案
    MySQL同步到ClickHouse的方案可以看下面的说明,选择合适最近的同步方法。1. 对比结果概述整体上,NineData(官网:www.ninedata.cloud )的数据复制功能在功能、性能表现最突出。其次是Bifrost和ClickHouse自带的MaterializeMySQL。NineData在增量DDL的处理、字段映射的准确......
  • Entity Framework Core 使用案例
    数据库生成实体类代码NuGet:Microsoft.EntityFrameworkCoreMicrosoft.EntityFrameworkCore.Tools在程序包管理控制台中执行一下命令Scaffold-DbContext"Server=【地址】;Database=【数据库名字】;Uid=【用户名】;Pwd=【密码】;"Pomelo.EntityFrameworkCore.MySql-Output......
  • Learn about some useful truck diagnostic scanner tools
    Haveyoueverexperiencedthefrustrationofunexpectedbreakdownswithyourtruck?Ormaybeyou’retiredofpayingexpensivediagnosticfeesatyourlocaldealership.Well,worrynomore!Thetruckdiagnosticscannertoolisheretomakeyourlifeeasier......
  • Android编译报错Caused by: java.lang.RuntimeException: Manifest merger failed wit
    Android编译报错Causedby:java.lang.RuntimeException:Manifestmergerfailedwithmultiple这种异常一般是引用了aar,如果项目中的manifestapplication配置和aar中不一样就会报错,比如android:icon和aar中不一致,则添加tools:replace="android:icon"配置即可。......
  • VMware Workstation 18 Tech Preview - 增强的 Windows 11 虚拟机安全性
    VMwareWorkstation18TechPreview-增强的Windows11虚拟机安全性VMwareWorkstationTechPreview2023请访问原文链接:https://sysin.org/blog/vmware-workstation-18/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org原文作者:MichaelRoyJuly13,2023准备......
  • Since Redis always uses the last processed
    RedisandItsUseofLastProcessedDataRedisisanopen-source,in-memorydatastructurestorethatcanbeusedasadatabase,cache,andmessagebroker.OneoftheuniquefeaturesofRedisisitsabilitytousethelastprocesseddataefficiently.Int......
  • Linux系统Apache添加监听端口后无法启动服务并报错:Job for httpd.service failed beca
    导言:这是SELinux安全机制导致的。解决方法:1.查看当前httpd端口#semanageport-l|grephttp2.将对应端口加入SELinux,以8068为例#semanageport-a-thttp_port_t-ptcp80683.再次查看#semanageport-l|grephttp4.重启Apache服务#systemctlrestarth......
  • ClickHouse多种实时更新方法总结
    ClickHouse本身对update的执行是低效的,因为ClickHouse的MergeTree存储一旦生成一个DataPart,这个Part就不支持更改,而是需要删除旧Part,重写整个Part。所以从MergeTree存储内核层面,ClickHouse就不擅长做数据更新删除操作。本文讲述的方法包括采用系统自带的Update,采用Replacing......
  • clickhouse "status=232/ADDRESS_FAMILIES" "code=exited, status=70" 问题
    clickhouse21.2.4.6安装时的问题232问题[root@localhostliang]#sudosystemctlstatusclickhouse-server●clickhouse-server.service-ClickHouseServer(analyticDBMSforbigdata)Loaded:loaded(/etc/systemd/system/clickhouse-server.service;enabled;ve......