mybatis连接mysql断连接问题记录

本文记录了在使用mybatis操作mysql数据库时遇到的断连接问题。mybatis提供的UNPOOLED、POOLED和JNDI三种数据源中,POOLED尝试通过连接池提高性能。然而,在长时间无操作后,数据库连接会丢失,即使配置了ping操作和autoReconnect也无法避免。官方指出,这些配置仅适用于mysql4.0,对于5.x版本无效。为解决此问题,建议切换到如c3p0或druid等第三方连接池,并给出了c3p0的配置示例。
摘要由CSDN通过智能技术生成

1.mybatis提供的数据源类型

        以下是官网介绍


        UNPOOLED    不使用连接池的数据源

       This implementation of DataSource simply opens and closes a connection each time it is requested. While it’s a bit slower, this is a good choice for simple applications that do not require the performance of immediately available connections. Different databases are also different in this performance area, so for some it may be less important to pool and this configuration will be ideal. The UNPOOLED DataSource is configured with only five properties:

         POOLED      使用连接池的数据源

        This implementation of DataSource pools JDBC Connection objects to avoid the i

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值