当前位置 博文首页 > m0_46212244的博客:org.springframework.dao.TransientDataAcce

    m0_46212244的博客:org.springframework.dao.TransientDataAcce

    作者:[db:作者] 时间:2021-09-23 13:32

    org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [select * from test01 where id = ]; Parameter index out of range (1 > number of parameters, which is 0).; nested exception is java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
    
    Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
    

    一般情况下这是因为sql语句的错误,没有输入要查询的范围也就是对应的id值。所有才报了超出发索引范围的错误。

    解决办法
    String sql = “select * from test01 where id = ?”;
    这个 ?号很关键

    cs
    下一篇:没有了