解决sql语句中username=? 提示sql语句在?有错误的解决方法

解决sql语句中username=? 提示sql语句在?有错误的解决方法
在对该语句进行数据库连接查询时报了sql语句错误

解决sql语句中username=? 提示sql语句在?有错误的解决方法提示sql语句中?有错误

解决方法,将rs = stat.executeQuery(sql);中的sql删除
解决sql语句中username=? 提示sql语句在?有错误的解决方法

原因在于stat = conn.prepareStatement(sql);已经对sql语句进行了预编译
在rs = stat.executeQuery();加入sql相当于对原sql语句进行编译