查询数据库报错,错误提示如下,代码如下

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? and sex=?' at line 1

图片

在执行 rs = pstat.executeQuery(sql); 之前  将sql打印出来,System.out.println(sql);

然后把打印出来的sql 放在数据库里执行。

参数没有穿进去,数据库执行的一定是带问号的语句

有可能是userpass和sex为空导致sql语句出错,,打个断点看看

to use near '? and sex=?' at line 1应该不支持你这种写法吧