当前位置:网站首页>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
边栏推荐
- The R language uses the timeroc package to calculate the multi time AUC value of survival data without competitive risk, and uses the confint function to calculate the confidence interval value of mul
- php参考手册String(7.2千字)
- STM32基础知识
- Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
- How does onlyoffice solve no route to host
- Still using listview? Use animatedlist to make list elements move
- CVPR 2022 | QueryDet:使用级联稀疏query加速高分辨率下的小目标检测
- Mysql database - connection query
- SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
- R language uses econocrats package to create microeconomic or macroeconomic map, visualize indifference function indifference curve, customize calculation intersection, and customize the parameters of
猜你喜欢
antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
DTMF dual tone multi frequency signal simulation demonstration system
How to create bep-20 pass on BNB chain
[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached
Mfcc: Mel frequency cepstrum coefficient calculation of perceived frequency and actual frequency conversion
Mysql database backup scheme
SIGIR'22「微软」CTR估计:利用上下文信息促进特征表征学习
程序设计语言基础(2)
Redis cache penetration, cache breakdown, cache avalanche
Notes of Tang Shu's grammar class in postgraduate entrance examination English
随机推荐
Vericrypt file hard disk encryption tutorial
[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached
R语言使用timeROC包计算存在竞争风险情况下的生存资料多时间AUC值、使用cox模型、并添加协变量、R语言使用timeROC包的plotAUCcurve函数可视化多时间生存资料的AUC曲线
论文写作 19: 会议论文与期刊论文的区别
Five minutes to show you what JWT is
DTMF dual tone multi frequency signal simulation demonstration system
PCA based geometric feature calculation of PCL point cloud processing (52)
Design of warehouse management database system
Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
R语言ggplot2可视化分面图(facet_wrap)、使用lineheight参数自定义设置分面图标签栏(灰色标签栏)的高度
NC basic usage 3
Kubernetes introduction to mastery - ktconnect (full name: kubernetes toolkit connect) is a small tool based on kubernetes environment to improve the efficiency of local test joint debugging.
2022 - Data Warehouse - [time dimension table] - year, week and holiday
R language ggplot2 visual facet_wrap, and use the lineheight parameter to customize the height of the facet icon tab (gray label bar)
Video understanding
渤海期货这家公司怎么样。期货开户办理安全?
SRS 的部署
Is the wechat CICC wealth high-end zone safe? How to open an account for securities
R语言使用caret包的preProcess函数进行数据预处理:对所有的数据列进行BoxCox变换处理(将非正态分布数据列转换为正态分布数据、不可以处理负数)、设置method参数为BoxCox
Record: call mapper to report null pointer Foreach > the usage of not removing repetition;