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 放在數據庫裡執行。