java.sql.SQLException:Unknown column 'admin' in 'where clause'错误问题

南宫天逸
2023-12-01

java.sql.SQLException:Unknown column 'admin' in 'where clause'

 

错误是由下面这句代码引起的:

 

ps=ct.prepareStatement("select passwd from users where username="+u+"'order by userId limit 0,1");

 

应该将其改为下面的形式:

 

ps=ct.prepareStatement("select passwd from users where username='"+u+"' order by userId limit 0,1");

 

因为username的值应该是string形式的,所以,应加 '' 单引号

 类似资料: