QT mysql 数据库线程池 与数据库操作封装

news2024/9/22 5:40:36

最近事情比较多很久没有写学习笔记了,数据库线程池,+ 数据库封装,虽说数据库操作有很多不需要写sql 的,ORM 封装的方式去操作数据库。但是从业这些年一直是自己动手写sql ,还是改不了这个习惯。不说了直接上代码。

数据库线程池

ConnectionPool.h 文件

#ifndef CONNECTIONPOOL_H
#define CONNECTIONPOOL_H

#include <QtSql>
#include <QQueue>
#include <QString>
#include <QMutex>
#include <QMutexLocker>

#include "ConnectionPool.h"

class ConnectionPool {
public:
    static void release(); // 关闭所有的数据库连接
    static QSqlDatabase createConnection();                 // 获取数据库连接
    static void closeConnection(QSqlDatabase connection); // 释放数据库连接回连接池

    ~ConnectionPool();

private:
    static ConnectionPool& getInstance();

    ConnectionPool();
    ConnectionPool(const ConnectionPool &other);
    ConnectionPool& operator=(const ConnectionPool &other);
    QSqlDatabase createConnection(const QString &connectionName); // 创建数据库连接
    void initialize();
    void loadConfigFile();

public:

    QQueue<QString> usedConnectionNames;   // 已使用的数据库连接名
    QQueue<QString> unusedConnectionNames; // 未使用的数据库连接名

    QJsonObject mJsonObject;
    // 数据库信息
    QString hostName;
    QString databaseName;
    QString username;
    QString password;
    QString databaseType;
    int     port;

    bool    testOnBorrow;    // 取得连接的时候验证连接是否有效
    QString testOnBorrowSql; // 测试访问数据库的 SQL

    int maxWaitTime;  // 获取连接最大等待时间
    int waitInterval; // 尝试获取连接时等待间隔时间
    int maxConnectionCount; // 最大连接数



    static QMutex mutex;
    static QWaitCondition waitConnection;
    static ConnectionPool *instance;
};

#endif // CONNECTIONPOOL_H
ConnectionPool.cpp


#include "ConnectionPool.h"
#include <QDebug>

QMutex ConnectionPool::mutex;
QWaitCondition ConnectionPool::waitConnection;
ConnectionPool* ConnectionPool::instance = NULL;

ConnectionPool::ConnectionPool()
{
    initialize();
}

ConnectionPool::~ConnectionPool()
{
    // 销毁连接池的时候删除所有的连接
    foreach(QString connectionName, usedConnectionNames)
    {
        QSqlDatabase::removeDatabase(connectionName);
    }

    foreach(QString connectionName, unusedConnectionNames)
    {
        QSqlDatabase::removeDatabase(connectionName);
    }
}

void ConnectionPool::loadConfigFile()
{
    QString path = qApp->applicationDirPath();
    QString strFile;
    strFile = path + "/config/DBConfig.json";
    QFile file(strFile);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        qDebug() << "could't open projects json";
        return;
    }

    QString value = file.readAll();
    file.close();

    QJsonParseError parseJsonErr;
    QJsonDocument document = QJsonDocument::fromJson(value.toUtf8(), &parseJsonErr);
    if(!(parseJsonErr.error == QJsonParseError::NoError))
    {
        qDebug() << parseJsonErr.errorString();
        return;
    }

    mJsonObject=document.object();
}

void ConnectionPool::initialize()
{
    //loadConfigFile();
    hostName     = "127.0.0.1";
    databaseName = "test";
    username     = "root";
    password     = "admin";
    databaseType = "QMYSQL";
    port         = 3306;
    testOnBorrow = true;
    testOnBorrowSql = "SELECT 1";
    waitInterval = 200;
    maxWaitTime     = 5000;
    maxConnectionCount = 10;

}


ConnectionPool& ConnectionPool::getInstance()
{
    if (NULL == instance)
    {
        QMutexLocker locker(&mutex);

        if (NULL == instance)
        {
            instance = new ConnectionPool();
        }
    }

    return *instance;
}

void ConnectionPool::release()
{
    QMutexLocker locker(&mutex);
    delete instance;
    instance = NULL;
}

QSqlDatabase ConnectionPool::createConnection()
{
    ConnectionPool& pool = ConnectionPool::getInstance();
    QString connectionName;

    QMutexLocker locker(&mutex);

    // 已创建连接数
    int connectionCount = pool.unusedConnectionNames.size() + pool.usedConnectionNames.size();

    // 如果连接已经用完,等待 waitInterval 毫秒看看是否有可用连接,最长等待 maxWaitTime 毫秒
    for (int i = 0;
         i < pool.maxWaitTime
         && pool.unusedConnectionNames.size() == 0 && connectionCount == pool.maxConnectionCount;
         i += pool.waitInterval)
    {
        waitConnection.wait(&mutex, pool.waitInterval);

        // 重新计算已创建连接数
        connectionCount = pool.unusedConnectionNames.size() + pool.usedConnectionNames.size();
    }

    qDebug() << "connectionCount:"<<connectionCount;
    qDebug() << "pool.maxConnectionCount:"<<pool.maxConnectionCount;
    if (pool.unusedConnectionNames.size() > 0)
    {
        // 有已经回收的连接,复用它们
        connectionName = pool.unusedConnectionNames.dequeue();
    }
    else if (connectionCount < pool.maxConnectionCount)
    {
        // 没有已经回收的连接,但是没有达到最大连接数,则创建新的连接
        connectionName = QString("Connection-%1").arg(connectionCount + 1);
    }
    else
    {
        // 已经达到最大连接数
        qDebug() << "Cannot create more connections.";
        return QSqlDatabase();
    }

    // 创建连接
    QSqlDatabase db = pool.createConnection(connectionName);

    // 有效的连接才放入 usedConnectionNames
    if (db.isOpen())
    {
        pool.usedConnectionNames.enqueue(connectionName);
    }

    return db;
}

void ConnectionPool::closeConnection(QSqlDatabase connection)
{
    ConnectionPool& pool = ConnectionPool::getInstance();
    QString connectionName = connection.connectionName();

    // 如果是我们创建的连接,从 used 里删除,放入 unused 里
    if (pool.usedConnectionNames.contains(connectionName))
    {
        QMutexLocker locker(&mutex);
        pool.usedConnectionNames.removeOne(connectionName);
        pool.unusedConnectionNames.enqueue(connectionName);
        waitConnection.wakeOne();
    }
}

QSqlDatabase ConnectionPool::createConnection(const QString &connectionName)
{
    // 连接已经创建过了,复用它,而不是重新创建
    if (QSqlDatabase::contains(connectionName))
    {
        QSqlDatabase db1 = QSqlDatabase::database(connectionName);

        if (testOnBorrow)
        {
            // 返回连接前访问数据库,如果连接断开,重新建立连接
            qDebug() << "Test connection on borrow, execute:" << testOnBorrowSql << ", for" << connectionName;
            QSqlQuery query(testOnBorrowSql, db1);

            if (query.lastError().type() != QSqlError::NoError && !db1.open())
            {
                qDebug() << "Open datatabase error:" << db1.lastError().text();
                return QSqlDatabase();
            }
        }

        return db1;
    }

    // 创建一个新的连接
    QSqlDatabase db = QSqlDatabase::addDatabase(databaseType, connectionName);
    db.setHostName(hostName);
    db.setDatabaseName(databaseName);
    db.setUserName(username);
    db.setPassword(password);
    db.setPort(port);
    if (!db.open())
    {
        qDebug() << "Open datatabase error:" << db.lastError().text();
        return QSqlDatabase();
    }

    return db;
}

数据库封装:

SqlDatabase.h


#ifndef SQLDATABASE_H
#define SQLDATABASE_H

#include <QJsonArray>
#include <QJsonValue>
#include <QJsonObject>

class  SqlDatabase
{
public:
    SqlDatabase();
    ~SqlDatabase();

public:
    static void InsertDB(QString strTableName,QJsonArray jsonValue);
    static void UpdateDB(QString strTableName,QJsonArray jsonValue,QString strColumnCondition);
    static int  InsertDB(QString strTableName,QJsonObject jsonValue);
    static void UpdateDB(QString strTableName,QJsonObject jsonValue,QString strCondition);
    static void QueryRecord(QString strSql,QJsonArray &nJsonValue);
    static int  QueryCount(QString strSql);
    static bool Delete(QString strSql);
    static bool Delete(QString strTableName,QString strCondition);
};

#endif // SQLDATABASE_H

 

SqlDatabase.cpp



#include "SqlDatabase.h"
#include "ConnectionPool.h"
#include <QDebug>


#pragma execution_character_set("utf-8")

SqlDatabase::SqlDatabase()
{

}

SqlDatabase::~SqlDatabase()
{
    ConnectionPool::Destroy();
}

void SqlDatabase::InsertDB(QString strTableName,QJsonArray jsonValues)
{
    QSqlDatabase db =ConnectionPool::CreateConnection();
    QString strValues="";
    QString strNames="";
    bool iskeyName=false;
    for(int j=0;j<jsonValues.size();j++)
    {
        QJsonObject::iterator it;
        QString strKeyValue;
        QJsonObject tmpObj =jsonValues.at(j).toObject();
        for(it=tmpObj.begin();it!=tmpObj.end();it++)
        {
            if(strKeyValue.isEmpty())
            {
                if(it.value().isDouble())
                {
                    it.value()=QString::number(it.value().toDouble(),'f',12);
                }
                strKeyValue=QString("'%1'").arg(it.value().toString());
                if(!iskeyName)
                {
                    strNames=QString("%1").arg(it.key());
                }
            }
            else
            {
                if(it.value().isDouble())
                {
                    it.value()=QString::number(it.value().toDouble(),'f',12);
                }
                strKeyValue+=QString(",'%1'").arg(it.value().toString());
                if(!iskeyName)
                {
                    strNames+=QString(",%1").arg(it.key());
                }
            }
        }

        iskeyName =true;
        if(strValues.isEmpty())
        {
            strValues +="("+strKeyValue+")";
        }
        else
        {
            strValues +=",("+strKeyValue+")";
        }
    }
    QString strSql=QString("INSERT INTO %1 (%2)  VALUES %3 ").arg(strTableName).arg(strNames).arg(strValues);
    QSqlQuery query(db);
    if(!query.exec(strSql))
    {
        qDebug()<<"Failed to INSERT:"<<strSql;
    }
    ConnectionPool::CloseConnection(db);
}

void SqlDatabase::UpdateDB(QString strTableName,QJsonArray jsonValue,QString strColumnCondition)
{
	QString mHeadSql= QString(" UPDATE  %1 m,( ").arg(strTableName);
    QString mEndSql=" ) n ";
	QString mSetConditionSql="";
    QString mValueSql="";
    QString mCondition="";
    QString strSql="";
	for(int i=0;i<jsonValue.size();i++)
    {
        QJsonObject jsonObject=jsonValue.at(i).toObject();
        QJsonObject::iterator it;
        QString strValue="";
        if(!mValueSql.isEmpty())
        {
            mValueSql +=  " UNION ";
        }
        for(it=jsonObject.begin();it!=jsonObject.end();it++)
        {
            if(it.value().isDouble())
            {
                it.value()=QString::number(it.value().toDouble(),'f',3);
            }
            if(strValue =="")
			{
                strValue =QString(" SELECT '%0' as `%1`").arg(it.value().toString()).arg(it.key());
                mSetConditionSql =QString(" SET m.%0 = n.%1").arg(it.key()).arg(it.key());
			}
			else
			{
                strValue +=QString(",'%0' as `%1`").arg(it.value().toString()).arg(it.key());
                mSetConditionSql += QString(" ,m.%0 = n.%1").arg(it.key()).arg(it.key());
			}	
		}

        mValueSql += strValue;
	}

    mCondition += QString(" WHERE m.%0 = n.%1").arg(strColumnCondition).arg(strColumnCondition);

    strSql =mHeadSql +mValueSql + mEndSql + mSetConditionSql+ mCondition;
    qDebug()<<strSql;
}

int SqlDatabase::InsertDB(QString strTableName,QJsonObject jsonValue)
{
    QSqlDatabase db =ConnectionPool::CreateConnection();
    QString strValues="";
    QString strNames="";
    int nLastNum=0;
    QJsonObject::iterator it;
    for(it=jsonValue.begin();it!=jsonValue.end();it++)
    {
        if(strValues.isEmpty())
        {
            if(it.value().isDouble())
            {
                it.value()=QString::number(it.value().toDouble(),'f',12);
            }
            strValues=QString("'%1'").arg(it.value().toString());
            strNames=QString("%1").arg(it.key());
        }
        else
        {
            if(it.value().isDouble())
            {
                it.value()=QString::number(it.value().toDouble(),'f',12);
            }
            strValues+=QString(",'%1'").arg(it.value().toString());
            strNames+=QString(",%1").arg(it.key());
        }
    }
    QString strSql=QString("INSERT INTO %1 (%2)  VALUES(%3) ").arg(strTableName).arg(strNames).arg(strValues);

    QSqlQuery query(db);
    if(!query.exec(strSql))
    {
        qDebug()<<"Failed to InsertDB:"<<query.lastError().text();
    }
    else
    {
        nLastNum=query.lastInsertId().toInt();
    }

    ConnectionPool::CloseConnection(db);
    return  nLastNum;
}

void SqlDatabase::UpdateDB(QString strTableName,QJsonObject jsonValue,QString strCondition)
{
    QSqlDatabase db =ConnectionPool::CreateConnection();
    QString strValues="";
    QString strNames="";
    QJsonObject::iterator it;
    for(it=jsonValue.begin();it!=jsonValue.end();it++)
    {
        if(strValues.isEmpty())
        {
            if(it.value().isDouble())
            {
                it.value()=QString::number(it.value().toDouble(),'f',12);
            }
            strValues=QString("%1='%2'").arg(it.key()).arg(it.value().toString());
        }
        else
        {
            if(it.value().isDouble())
            {
                it.value()=QString::number(it.value().toDouble(),'f',12);
            }
            strValues+=QString(",%1='%2'").arg(it.key()).arg(it.value().toString());
        }
    }

    QString strSql=QString("UPDATE  %1  SET %2  %3 ").arg(strTableName).arg(strValues).arg(strCondition);
    QSqlQuery query(db);
    if(!query.exec(strSql))
    {
        qDebug()<<"Failed to UpdateDB:"<<query.lastError().text();
    }

    ConnectionPool::CloseConnection(db);
}

void SqlDatabase::QueryRecord(QString strSql,QJsonArray &nJsonValue)
{
    QSqlDatabase db =ConnectionPool::CreateConnection();
    QSqlQuery query(db);
    if(!query.exec(strSql))
    {
       qDebug()<<"Failed to QueryRecord:"<<query.lastError().text();
    }

    while(query.next())
    {
        QSqlRecord qResultRecord=query.record();
        QJsonObject jsonObject;
        for(int fileIndex =0; fileIndex<qResultRecord.count();fileIndex++)
        {
            if(query.value(fileIndex).isNull())
            {
                jsonObject.insert(qResultRecord.fieldName(fileIndex),QJsonValue::Null);
            }
            else if(query.value(fileIndex).type() ==QVariant::Int)
            {
                jsonObject.insert(qResultRecord.fieldName(fileIndex),query.value(fileIndex).toInt());
            }
            else if(query.value(fileIndex).type() == QVariant::Double)
            {
                jsonObject.insert(qResultRecord.fieldName(fileIndex),query.value(fileIndex).toDouble());
            }
            else if(query.value(fileIndex).type() == QVariant::LongLong)
            {
                jsonObject.insert(qResultRecord.fieldName(fileIndex),query.value(fileIndex).toLongLong());
            }
            else
            {
                jsonObject.insert(qResultRecord.fieldName(fileIndex),query.value(fileIndex).toString());
            }
        }
        nJsonValue.append(jsonObject);
    }
    ConnectionPool::CloseConnection(db);
}

int SqlDatabase::QueryCount(QString strSql)
{
   QSqlDatabase db =ConnectionPool::CreateConnection();
   QSqlQuery query(db);
   int totalCnt=0;
   QString strSqlCount=QString(" SELECT COUNT(*) AS Cnt FROM  (%1) t ").arg(strSql);
   if(!query.exec(strSqlCount))
   {
       qDebug()<<"Failed to QueryCount:"<<query.lastError().text();
   }

   while(query.next())
   {
        totalCnt=query.value("Cnt").toInt();
   }
   ConnectionPool::CloseConnection(db);
   return totalCnt;
}

bool SqlDatabase::Delete(QString strSql)
{
    bool bRet =true;
    QSqlDatabase db =ConnectionPool::CreateConnection();
    QSqlQuery query(db);
    if(!query.exec(strSql))
    {
        qDebug()<<"Failed to Delete:"<<query.lastError().text();
        bRet = false;
    }

    ConnectionPool::CloseConnection(db);
    return bRet;
}

bool SqlDatabase::Delete(QString strTableName,QString strCondition)
{
    bool bRet =true;
    QSqlDatabase db =ConnectionPool::CreateConnection();
    QSqlQuery query(db);
    QString strSql=QString(" DELETE FROM %1 %2 ").arg(strTableName).arg(strCondition);
    if(!query.exec(strSql))
    {
        qDebug()<<"Failed to Delete:"<<query.lastError().text();
        bRet = false;
    }

    ConnectionPool::CloseConnection(db);
    return bRet;
}

此处说一下批量更新

源数据是这样需要更新

id:1      shorName  :aaaaa       score1:56.9   ranking  :22

id:2      shorName  :bbbbb       score1:89.9  score3:59.9  ranking  :27

id:3      shorName  :ccccc       score1:76.9   score2:81.9  ranking  :29

sql 语句 批量更新

UPDATE test m,(
	SELECT
		'1.000' AS `id`,
		'a' AS `name`,
		'22.000' AS `ranking`,
		'56.900' AS `score1`,
		'39.500' AS `score2`,
		'56.700' AS `score3`,
		'aaaa' AS `shorName` UNION
	SELECT
		'2.000' AS `id`,
		'b' AS `name`,
		'27.000' AS `ranking`,
		'89.900' AS `score1`,
		'39.500' AS `score2`,
		'59.900' AS `score3`,
		'bbbbb' AS `shorName` UNION
	SELECT
		'3.000' AS `id`,
		'c' AS `name`,
		'29.000' AS `ranking`,
		'76.900' AS `score1`,
		'72.900' AS `score2`,
		'81.900' AS `score3`,
		'ccccc' AS `shorName` 
	) n 
	SET m.id = n.id,
	m.NAME = n.NAME,
	m.ranking = n.ranking,
	m.score1 = n.score1,
	m.score2 = n.score2,
	m.score3 = n.score3,
	m.shorName = n.shorName 
WHERE
	m.id = n.id

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1237927.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

YOLOv5 环境搭建

YOLOv5 环境搭建 flyfish 环境 Ubuntu20.04 驱动、CUDA Toolkit、cuDNN、PyTorch版本对应 1 NVIDIA驱动安装 在[附加驱动界]面安装驱动时&#xff0c;需要输入安全密码&#xff0c;需要记下&#xff0c;后面还需要输入这个密码 重启之后有的机器会出现 perform mok manage…

【Java开发】 Springboot集成Mybatis-Flex

1 Mybatis-Flex 介绍 1.1简介 Mybatis-Flex 是一个优雅的 Mybatis 增强框架&#xff0c;它非常轻量、同时拥有极高的性能与灵活性。我们可以轻松的使用 Mybaits-Flex 链接任何数据库&#xff0c;其内置的 QueryWrapper 亮点帮助我们极大的减少了 SQL 编写的工作的同时&#xff…

微信订房功能怎么做_公众号里怎么实现在线订房系统

微信公众号在线订房系统&#xff1a;一键解决您的住宿问题 在当今数字化时代&#xff0c;微信公众号已经成为人们生活中不可或缺的一部分。它提供了各种各样的功能和服务&#xff0c;让我们的生活变得更加便捷和高效。而如今&#xff0c;微信公众号也实现了在线订房功能&#…

SecureCRT -- 使用说明

【概念解释】什么是SSH&#xff1f; SSH的英文全称是Secure Shell 传统的网络服务程序&#xff0c;如&#xff1a;ftp和telnet在本质上都是不安全的&#xff0c;因为它们在网络上用明文传送口令和数据&#xff0c;别有用心的人非常容易就可以截获这些口令和数据。而通过使用SS…

8年老鸟整理,自动化测试-准备测试数据详细...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 大部分类型的测试…

拆解现货黄金隔夜利息计算公式

在讨论现货黄金投资手续费的时候&#xff0c;隔夜利息是经常被忽略的一个方面&#xff0c;但它是投资者不得不考虑的成本因素&#xff0c;特别是在中长线交易的情况下。隔夜利息是根据投资者的持仓数量和交易方向所计算出的利息&#xff0c;如果投资者需要持仓过夜&#xff0c;…

程序员的护城河:技术深度、创新追求与软实力的综合构筑

在IT行业&#xff0c;程序员被形象地比喻为现代社会的护城河&#xff0c;他们以代码为武器&#xff0c;捍卫着系统安全、数据防护以及网络稳定。然而&#xff0c;这位"护城河"究竟是依赖于技术深度、创新追求&#xff0c;还是软实力中的沟通协作等方面呢&#xff1f;…

【vue】ant-design-vue的树结构实现节点增删改查

根据业务需要&#xff0c;实现树结构的节点新增编辑删除功能&#xff0c;主要逻辑是利用树节点的scopedSlots属性对其进行自定义改造&#xff0c;监听悬停事件在节点右侧出现增删改对应图标&#xff0c;点击图标出现弹窗表单对内容进行修改&#xff0c;具体代码如下&#xff1a…

TikTok Shop订单狂涨,黑五全托管品类日卖爆了

01 黑五品类日爆单 显然&#xff0c;TikTok Shop在美国的首个黑五大促收获了胜利的果实。 根据最新发布的数据&#xff0c;TikTok Shop全托管黑五六大品类日支付GMV&#xff08;总交易额&#xff09;和支付量双双实现大幅度增长。举其中几个具体数据来看&#xff0c;女装童鞋…

【腾讯云云上实验室-向量数据库】腾讯云开创新时代,发布全新向量数据库Tencent Cloud VectorDB

前言 随着人工智能、数据挖掘等技术的飞速发展&#xff0c;海量数据的存储和分析越来越成为重要的研究方向。在海量数据中找到具有相似性或相关性的数据对于实现精准推荐、搜索等应用至关重要。传统关系型数据库存在一些缺陷&#xff0c;例如存储效率低、查询耗时长等问题&…

服务案例|故障频发的一周,居然睡得更香!

医院运维有多忙&#xff1f; 医院运维&#xff0c;听起来平平无奇毫不惊艳&#xff0c;但其中的含金量&#xff0c;可不是“维持系统正常运行”就能总结的。毕竟医院对业务连续性的超高要求&#xff0c;让运维面对的问题都是暂时的&#xff0c;下一秒可能就有新问题需要发现解…

CountDownLatch和CyclicBarrier

JUC&#xff08;Java.util.concurrent&#xff09;是Java 5中引入的一个并发编程库&#xff0c;它包含了许多用于多线程处理的工具类和接口。JUC主要提供了以下特性&#xff1a; 线程池&#xff1a;线程池可以提高线程的使用效率&#xff0c;避免频繁地创建和销毁线程&#xff…

许战海战略文库|从丰田到等离子屏:技术领先为何失去市场?

引言&#xff1a;在探讨技术创新与市场需求之间的微妙关系时&#xff0c;个关键的问题浮现:为什么强大的技术优势并不总是等同于市场成功?从丰田汽车在电动车领域的挑战到日本等离子显示屏技术的衰落,市场趋势对企业成功存在决定性影响。企业需要在技术创新和市场需求之间找到…

聚焦数字化项目管理——2023年PMI项目管理大会亮点回顾

11月18日-19日&#xff0c;由PMI&#xff08;中国&#xff09;主办的2023年PMI项目管理大会在上海浦东嘉里大酒店圆满召开。本次大会以“数智时代&#xff0c;汇创未来”为主题&#xff0c;聚焦数智时代大背景下的项目管理行业发展和人才培养&#xff0c;吸引了海内外千余名项目…

9.3 Windows驱动开发:内核解析PE结构节表

在笔者上一篇文章《内核解析PE结构导出表》介绍了如何解析内存导出表结构&#xff0c;本章将继续延申实现解析PE结构的PE头&#xff0c;PE节表等数据&#xff0c;总体而言内核中解析PE结构与应用层没什么不同&#xff0c;在上一篇文章中LyShark封装实现了KernelMapFile()内存映…

AIGC变革BI行业,永洪发布vividime全球化品牌

大数据产业创新服务媒体 ——聚焦数据 改变商业 国内BI商业智能市场&#xff0c;一直有着“内永洪&#xff0c;外Tableau”的说法。成立于2012年的永洪科技经过十多年的发展&#xff0c;早已崛起为国内大数据行业的一支劲旅。 ChatGPT火爆出圈之后&#xff0c;AIGC快速渗透&am…

身份证号码校验

根据《新版外国人永久居留身份证适配性改造要点》&#xff0c;公司需要把代码中对身份证的校验进行优化 就文档内容可以看到需要优化的要点是&#xff1a; 新版永居证号码以 9 开头 受理地区代码出生日期顺序码校验码&#xff1b;&#xff08;共18位&#xff09; eg&#xff…

栈的生长方向不总是向下

据我了解&#xff0c;栈的生长方向向下&#xff0c;内存地址由高到低 测试 windows下&#xff1a; 符合上述情况 测试Linux下&#xff1a; 由此可见&#xff0c;栈在不同操作系统环境下&#xff0c;生长方向不总是向下

jetpack compose中实现丝滑的轮播图效果

写在前面 最近在翻Jetpack库&#xff0c;发现了DataStore&#xff0c;官方是这么说的&#xff1a; Jetpack DataStore 是一种数据存储解决方案&#xff0c;允许您使用协议缓冲区存储键值对或类型化对象。DataStore 使用 Kotlin 协程和 Flow 以异步、一致的事务方式存储数据。 …

18张值得收藏的高清卫星影像

这里分享的18张高清卫星影像&#xff0c;由吉林一号卫星拍摄。 原图来自长光卫星嘉宾在直播中分享的PPT演示文档。 18张高清卫星影像 吉林一号高分04A星&#xff0c;于2022年05月21日拍摄的北京紫禁城高清卫星影像。 北京紫禁城 云南昆明滇池国际会展中心高清卫星影像&…