zoukankan      html  css  js  c++  java
  • 使用数据库关键字做字段引起的mybatis或tk.mybatis框架报错

    报错信息:

    Exception Error:

    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ‘require ) VALUES( 1,‘xx’,‘dfs’,‘sdf’,‘sdfds’,0 )’ at line 1
    ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ‘require ) VALUES( 1,‘xx’,‘dfs’,‘sdf’,‘sdfds’,0 )’ at line 1

    解决方案:

    1.mybatis映射文件中写Sql的时候在关键字加转义符号

    例如字段:

    name     应该写成   `name`
    require  应该写成   `require`
    

    2.tk.mybatis增加注解指定字段加转义符号

    @Column(name = "`require`")
    private Integer require;
    @Column(name = "`name`")
    private Integer name;
    
  • 相关阅读:
    《构建之法阅读笔记02》
    《人月神话阅读笔记01》
    第四周学习进度条
    子数组2
    敏捷开发方法综述
    子数组1
    第三周学习进度条
    四则运算3
    第二周学习进度条
    四则运算4
  • 原文地址:https://www.cnblogs.com/javakfz/p/13938199.html
Copyright © 2011-2022 走看看