zoukankan      html  css  js  c++  java
  • ### Cause: org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2]

    org.apache.ibatis.exceptions.PersistenceException:
    ### Error updating database. Cause: org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2]
    ### The error may involve com.imp.IStudents.insertOne-Inline
    ### The error occurred while setting parameters
    ### SQL: insert into students(name,pass) values(?,?)
    ### Cause: org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2]

    mmp ,遇到这个错误弄了半天,在百度上找了半天的教程,在cdsn上看到说是有两种方法可以

    但我测试之后只有第一种方法可行

    xml文件中的插入语句不要变

    1   <insert id="insertOne" parameterType="Students">
    2        insert into students(name,age) values(#{name},#{age})
    3   </insert>

    改一下接口中的方法的参数

    1  void insertOne(@Param("name")String name,@Param("age")int age);
    IStudents.java

    测试方法如下

    1 @Test
    2     public void testInsertOne() throws Exception {
    3         SqlSession sqlSession = DataBaseManager.getSqlSession();
    4         IStudents mapper = sqlSession.getMapper(IStudents.class);
    5         mapper.insertOne("邢逸", 18);
    6         sqlSession.commit();
    7     }
    TestBasic.java
  • 相关阅读:
    MyBatis的动态SQL语句这么厉害的!
    连接数据库,使用c3p0技术连接MySQL数据库
    Servlet 常见的乱码解决方案
    超级签具体实现
    Xcode报错You don’t have permission.
    SpringBoot+Mybatis整合实例
    恢复mysql数据库误删数据
    日期(date)运用座谈会
    程序猿日记--学习怎样学习
    服务器数据库密码忘记
  • 原文地址:https://www.cnblogs.com/xyblogs/p/8724194.html
Copyright © 2011-2022 走看看