当前位置:网站首页>Investigate why close is required after sqlsession is used in mybatties
Investigate why close is required after sqlsession is used in mybatties
2022-04-23 20:14:00 【nobody234】
Study in detail MyBaties in SqlSession Why do you need close
stay Mybatis There is a sentence in the document
Open one SqlSession, After returning a response , Just turn it off . This close operation is very important , In order to ensure that the close operation can be performed every time , You should put this shutdown operation in finally In block .
Mybatis file
But we know SqlSessionFactory Equivalent to a database connection pool , And by the SqlSessionFactory Got SqlSession It is equivalent to a database connection .
And when we learn about thread pools , We understand that the lifetime of threads in the thread pool is regulated by the thread pool itself , After we apply for a thread, it only works , The thread pool itself will release this thread at the most appropriate time . So as to avoid frequent application and destruction of threads .
The principle of database connection pool is similar to that of thread pool , Then why does one need to release even if one doesn't need it ?
This is mainly because when we write thread pool code , We can ’ perception ’ When the thread being used should be recycled ( Recycled when task is completed ), When a connection is used up cannot be used as a database connection pool ’ perception ’ Of , So when we finish using a connection, we need to tell the database connection pool that we have finished using , It can be recycled , The operation of notification is close. in other words SqlSession Of close It's not closing the connection , It's going to be Sqlsession Recycle into the database connection pool, that is SqlSessionFactory
complete
版权声明
本文为[nobody234]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210555176751.html
边栏推荐
- Esp8266 - beginner level Chapter 1
- Mfcc: Mel frequency cepstrum coefficient calculation of perceived frequency and actual frequency conversion
- Efficient serial port cyclic buffer receiving processing idea and code 2
- 图书管理数据库系统设计
- Devops integration - environment variables and building tools of Jenkins service
- PCL点云处理之基于PCA的几何形状特征计算(五十二)
- 山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(六)
- How does onlyoffice solve no route to host
- R语言ggplot2可视化:ggplot2可视化散点图并使用geom_mark_ellipse函数在数据簇或数据分组的数据点周围添加椭圆进行注释
- Rédaction de thèses 19: différences entre les thèses de conférence et les thèses périodiques
猜你喜欢
An error is reported when sqoop imports data from Mysql to HDFS: sqlexception in nextkeyvalue
【文本分类案例】(4) RNN、LSTM 电影评价倾向分类,附TensorFlow完整代码
WordPress插件:WP-China-Yes解决国内访问官网慢的方法
Redis cache penetration, cache breakdown, cache avalanche
Five minutes to show you what JWT is
Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (6)
How to create bep-20 pass on BNB chain
SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
程序设计语言基础(2)
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
随机推荐
渤海期货这家公司怎么样。期货开户办理安全?
[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached
LeetCode异或运算
Record: call mapper to report null pointer Foreach > the usage of not removing repetition;
uIP1. 0 actively sent problem understanding
Redis的安装(CentOS7命令行安装)
[text classification cases] (4) RNN and LSTM film evaluation Tendency Classification, with tensorflow complete code attached
AQS learning
MySQL数据库 - 连接查询
Unity 模型整体更改材质
nc基础用法2
Software College of Shandong University Project Training - Innovation Training - network security shooting range experimental platform (8)
Electron入门教程3 ——进程通信
antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
程序设计语言基础(2)
PCL点云处理之直线与平面的交点计算(五十三)
NC basic usage 3
aqs的学习
Redis installation (centos7 command line installation)
Introduction to electron Tutorial 4 - switching application topics