青云HOMIE 2020-01-12 22:37 采纳率: 100%
浏览 448
已采纳

MyBatis内SQL语句报错

<insert id="insertSelectiveAndTreturnId" parameterType="com.binhai.fix.bean.FixBean" 
   useGeneratedKeys="true" keyProperty="id">
    insert into t_fix
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="describe != null" >
        describe,
      </if>
      <if test="subDate != null" >
        subDate,
      </if>
      <if test="finDate != null" >
        finDate,
      </if>
      <if test="phone != null" >
        phone,
      </if>
      <if test="shifoushanchu != null" >
        shifoushanchu,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="describe != null" >
        #{describe,jdbcType=VARCHAR},
      </if>
      <if test="subDate != null" >
        #{subDate,jdbcType=VARCHAR},
      </if>
      <if test="finDate != null" >
        #{finDate,jdbcType=VARCHAR},
      </if>
      <if test="phone != null" >
        #{phone,jdbcType=INTEGER},
      </if>
      <if test="shifoushanchu != null" >
        #{shifoushanchu,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

报错:
### Error updating database.  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 'describe,




        phone ) 
     values ( '111',
    ' at line 2
### The error may involve com.binhai.fix.dao.FixBeanDao.insertSelectiveAndTreturnId-Inline
### The error occurred while setting parameters
### SQL: insert into t_fix      ( describe,                                     phone )       values ( ?,                                     ? )
### 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 'describe,




        phone ) 
     values ( '111',
    ' at line 2
; 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 'describe,




        phone ) 
     values ( '111',
    ' at line 2
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)

我看了看了好几遍真是没看出来什么错误,请大神指点一二 谢谢!头发都秃了

https://pan.baidu.com/s/110gPmL3rkBfBYV5ILBz3xg 完整DAO文件和异常

  • 写回答

3条回答 默认 最新

  • 农夫丶果园 2020-01-13 09:19
    关注

    你的有一个参数名叫 describe , 这个在MYSQL中和 EXPLAIN 是同义词 ,建议你换一个参数名 , 或者这样使用

        insert into t_fix ( `describe` , phone) values....
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格