您的位置:首页 > 其它

Parameter index out of range (1 > number of parameters, which is 0).

2016-08-21 12:02 465 查看
publicint delSysUser(SysUser sysUser) {

// 添加用户的SQL语句
String sql = "deletefrom table sys_user where id = ‘?’
";

// 获取SQL连接

Connection conn = dbUtils.getConn();

PreparedStatement pstm = null;

try {

// 添加字段值 下标从1开始

pstm = conn.prepareStatement(sql);

pstm.setLong(1, sysUser.getId());// 添加ID

// 执行数据库操作

pstm.executeUpdate();

return 0;

} catch (Exception e) {

throw new RuntimeException("SysUserDao-delSysUsererror", e);

} finally {

// 操作完成释放数据库连接

dbUtils.releaseAll(conn, pstm, null);

}

}
报错信息提示sql语句出错,定位在第一行,具体信息是没有找到参数
String sql = "deletefrom table sys_user where id = ?"; 

 
Sql
语句中
?不能加单引号
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐