stmt.executeQuery("select * from user where username = " + name);
执行上述代码就会引发该错误。
原因是:拼凑sql语句时对字符类型数据没有用引号引起来
更改为以下语句即可改正
stmt.executeQuery("select * from user where username = '" + name + "'");
stmt.executeQuery("select * from user where username = " + name);
stmt.executeQuery("select * from user where username = '" + name + "'");