查询应该有结果的,却if(res.next)里面的语句却没有执行
花了很长时间,究其原因,
1 varchar类型的变量,没有单引号,结果为空,
2 单引号与变量之间不能有空格,不然是=‘ 182’这样查询结果也是空,
错误的:
res = sql.executeQuery(" select id from user where id = "
+ registerId+ ";");
错误的:
res = sql.executeQuery(" select id from user where id = ' "///有空格则错误
+ registerId+ ";");
res = sql.executeQuery(" select id from user where id = '"///有单引号,无空格