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

来源:互联网 发布:百科词条优化 编辑:程序博客网 时间:2024/04/29 18:09

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形式的,所以,应加 '' 单引号