惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
博客园 - 聂微东
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
小众软件
小众软件
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
B
Blog
H
Help Net Security
D
Docker
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
月光博客
月光博客
博客园 - 司徒正美

博客园 - le.li

python: 安装python 依赖pip install xxx报错,'pip' 不是内部或外部命令,也不是可运行的程序 nginx:普通用户使用80端口启动nginx报错,nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) redis:linux安装redis nginx:linux系统安装nginx linux:su切换用户后ll报错 JDK:Linux下载安装jdk1.8 Redis:访问redis报错(error) NOAUTH Authentication required idea:打开黑屏 android: onClick与onTouch冲突,onclick事件没有触发 [Mysql]快速执行sql文件 [JAVA]JDK多版本设置 Android: 添加默认菜单 Android:android studio使用本地路径依赖 [idea]mvn install没有问题,idea build报错:java: Compilation failed: internal java compiler error Android:adb devices返回设备状态offline Wireshark:记一次抓包过程 Android:adb查看手机启动端口 Android:androidx.appcompat.app.AppCompatActivity添加返回按钮 Android:查看依赖
JAVA: Mybatis添加xml执行多行更新语句时报错
le.li · 2025-10-09 · via 博客园 - le.li

tableMapper.xml

<update id="updateTables" parameterType="Table">
    <foreach collection="tableList" item="item" separator=";">
        update tb_test
        <trim prefix="SET" suffixOverrides=",">
            <if test="item.name != null">title = #{item.name},</if>
        </trim>
        where id = #{item.id}
    </foreach>
</update>

### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update 

检查了sql和单独执行,都没有问题

搜索发现,是出于安全安全,连接数据库不允许使用分号,即不允许一次执行多行sql

解决:

修改数据库连接URL配置添加允许使用分号allowMultiQueries=true

 jdbc:mysql://localhost:3306/test_db?allowMultiQueries=true

备注:

允许使用分号,意味更多的注入风险,校验好用户输入的内容