iis服务器助手广告
返回顶部
首页 > 资讯 > 数据库 >MySQL java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax 关键字异常处理
  • 927
分享到

MySQL java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax 关键字异常处理

mysqljavasql 2023-08-16 15:08:21 927人浏览 泡泡鱼
摘要

目录 一、异常错误二、原因三、解决方法 一、异常错误 使用mybatis插入数据时出现java.sql.SQLSyntaxErrorException异常 收到错误“由:java.sql.SQLSyntaxErrorExcept

一、异常错误

使用mybatis插入数据时出现java.sql.SQLSyntaxErrorException异常

收到错误“由:java.sql.SQLSyntaxErrorException:您的SQL语法有错误;检查与您的Mysql服务器版本相对应的手册,了解在第14行的“”附近使用的正确语法。

Uncaught (in promise) Error: ### Error updating database.  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 'group,            device_sort,                        create_time )         ' at line 4### The error may exist in file [D:\Project\zdhzyjy\remote-burning\ruoyi-device\target\classes\mapper\device\DevDeviceMapper.xml]### The error may involve com.ruoyi.device.mapper.DevDeviceMapper.insertDevDevice-Inline### The error occurred while setting parameters### SQL: insert into dev_device          ( name,             port,             group,             device_sort,                          create_time )           values ( ?,             ?,             ?,             ?,                          ? )### 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 'group,            device_sort,                        create_time )         ' at line 4; bad SQL grammar []; nested exception is 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 'group,            device_sort,                        create_time )         ' at line 4    at _default (request.js:93:1)

二、原因

liquibase回答:

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 ” at line 14

在这里插入图片描述

This error is very common, it’s true. Mostly that’s because we are only human, and people make mistakes in their SQL syntax often. This can be due to using reserved Words, missing data in the database, or mistyped/obsolete commands.
这个错误很常见,这是真的。这主要是因为我们只是人类,人们经常在SQL语法中犯错误。这可能是由于使用了保留字、数据库中缺少数据或命令键入错误/过时。

InMotion Hosting has a great troubleshooting guide here: InMotion
Hosting在这里有一个很棒的故障排除指南:

MySQL 1064 Error: You have an error in your SQL syntax – InMotion
Hosting Support Center 82. MySQL 1064 错误:您的 SQL 语法有错误 – InMotion
托管支持中心82。

inomotion回答:

在这里插入图片描述

MySQL 1064 错误:您的 SQL 语法有误
斯科特·米切尔 ( Scott Mitchell)于 2021 年 2 月 1 日更新
3 分 55 秒阅读

因此,您正在创建自定义 SQL 查询以在数据库中执行任务。将代码放在一起并在 PHPmyAdmin 中运行后,它会返回 1064
错误。它可能看起来类似于:
在这里插入图片描述

1064 错误信息 每当您的 SQL 语法出现问题时,都会显示 1064
错误,这通常是由于使用了保留字、数据库中缺少数据或输入错误/过时的命令。因此,请继续阅读并详细了解 1064
错误是什么、一些可能的原因以及一般故障排除步骤。

注意:由于在长查询中很难定位语法错误,因此以下在线工具通常可以通过检查您的代码和定位问题来节省时间:

PiliApp MySQL 语法检查
EverSQL SQL 查询语法检查和验证器

总结:group在MySql中是关键字, 如果直接使用会报异常,需要更改字段名或使用转义符
在这里插入图片描述

三、解决方法

更改group字段名,加上前缀即可

在这里插入图片描述

` (键盘数字1左侧键) 是 MySQL 的转义符,用于避免关键字冲突

比如你可以在插入语句中这样写

SELECT `group` FROM table;

来源地址:https://blog.csdn.net/qq_46207024/article/details/131327978

您可能感兴趣的文档:

--结束END--

本文标题: MySQL java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax 关键字异常处理

本文链接: https://www.lsjlt.com/news/371599.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作