Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql的连接池获取 #3

Open
junlei-lv opened this issue Jun 26, 2019 · 15 comments
Open

mysql的连接池获取 #3

junlei-lv opened this issue Jun 26, 2019 · 15 comments

Comments

@junlei-lv
Copy link

为什么每次获取出来的conn打开事务的时候回出现 conn是null的情况。

@2881099
Copy link
Owner

2881099 commented Jun 26, 2019

看看定义,和代码

@junlei-lv
Copy link
Author

junlei-lv commented Jun 26, 2019 via email

@2881099
Copy link
Owner

2881099 commented Jun 26, 2019

用qq等工具截图,在github回复框可以直接粘贴的

@junlei-lv
Copy link
Author

图片

@junlei-lv
Copy link
Author

junlei-lv commented Jun 26, 2019 via email

@junlei-lv
Copy link
Author

junlei-lv commented Jun 26, 2019 via email

@2881099
Copy link
Owner

2881099 commented Jun 26, 2019

还是引用出来是什么意思?

@junlei-lv
Copy link
Author

junlei-lv commented Jun 26, 2019 via email

@junlei-lv
Copy link
Author

junlei-lv commented Jun 26, 2019 via email

@2881099
Copy link
Owner

2881099 commented Jun 26, 2019

那是一个内部类,可以把代码 copy 出来使用

@2881099
Copy link
Owner

2881099 commented Jun 26, 2019

弱弱的问下,你封装mysql用来作什么

@batsword
Copy link

mysql有个类型是不支持事务的 难道是用了mysam?

@senioi
Copy link

senioi commented Oct 10, 2019

长连接维持也需要开销,这个我也懵了,
到底是需要维持长连接呢,还是使用官方推荐的不复用,每次都新开连接.
目前用的mysqlconnector说不推荐用长连接或者复用,
请教下大佬,高频率查询和插入数据,长连接好还是短连接好?

@2881099
Copy link
Owner

2881099 commented Oct 10, 2019

@senioi 内部服务用长连接好,效率高,且数量有限。

其实ado.net基本都实现了pooling,SafeObjectPool除了池化作用,还有断熔和恢复功能。

当数据库连接不上的时候,程序基本会一直请求数据库,15秒连超时才响应。断熔后即刻响应,不影响程序的其他功能。恢复功能,可以等到数据库可用时自动切换回来。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants