Mybatis同时执行多条SQL

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lyc_liyanchao/article/details/83382970
1. Mybatis配置文件示例
<delete id="resetDB">
    DELETE from wechat_question;
    DELETE from wechat_answer;
    DELETE from wechat_answer_record;
    DELETE from wechat_code_record;
    DELETE FROM wechat_award_record;
    DELETE from wechat_sms_record;
    DELETE from wechat_user;
</delete>
2. 数据连接开启多条语句处理allowMultiQueries=true
# 数据源配置
spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: com.mysql.jdbc.Driver
        druid:
            # 主库数据源
            master:
                url: jdbc:mysql://10.200.0.112:3306/wechat?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&allowMultiQueries=true
                username: root
                password: root

加上allowMultiQueries=true就可以在一个方法里同时执行多条sql了

展开阅读全文

没有更多推荐了,返回首页