• java.sql.SQLException: No value specified for parameter 12


    String sql="update  dishes set foodName = ? , foodPrice=? , 
    foodWeight=? ,cost_performance=? , address=? ,date=? , firstCategoty=?,
     secondCategory=? , foods=? , photo=? , other =?  where id=?";
    
    	pstmt = conn.prepareStatement(sql);
    				pstmt.setString(1, stu.getFoodname());
    				pstmt.setFloat(2, stu.getPrice());
    				pstmt.setFloat(3, stu.getWeight());
    				pstmt.setInt(4, stu.getCost_performance());
    				pstmt.setString(5, stu.getAddress());
    				pstmt.setString(6, stu.getDate());
    				pstmt.setString(7, stu.getFirstCategory());
    				pstmt.setString(8, stu.getSecondCategory());
    				pstmt.setString(9, stu.getFoods());
    				pstmt.setString(10, stu.getPhoto());
    				pstmt.setString(11, stu.getOther());
    				pstmt.executeUpdate();
    

    应该加上

    pstmt.setInt(12, stu.getId());
    

    	            pstmt = conn.prepareStatement(sql);
    				pstmt.setString(1, stu.getFoodname());
    				pstmt.setFloat(2, stu.getPrice());
    				pstmt.setFloat(3, stu.getWeight());
    				pstmt.setInt(4, stu.getCost_performance());
    				pstmt.setString(5, stu.getAddress());
    				pstmt.setString(6, stu.getDate());
    				pstmt.setString(7, stu.getFirstCategory());
    				pstmt.setString(8, stu.getSecondCategory());
    				pstmt.setString(9, stu.getFoods());
    				pstmt.setString(10, stu.getPhoto());
    				pstmt.setString(11, stu.getOther());
    				pstmt.setInt(12, stu.getId());
    				pstmt.executeUpdate();
    

    第12个?没有赋值,也就是id没有指定

  • 相关阅读:
    coding++:SpringBoot-事务注解详解
    coding++:java-自定义签名+拦截器
    linux++:Linux
    coding++:java-全局异常处理
    POJ 2823 双端队列
    POJ 3250 栈
    10进制数字向0~3999的罗马数字的转换
    POJ 1986 LCA
    POJ 1236 强联通分量
    河南工业大学2017校赛题解
  • 原文地址:https://www.cnblogs.com/CCCrunner/p/11781634.html
Copyright © 2020-2023  润新知