一个小错误
Statement stmt_Check=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = "select * from tAdmin where fPassword= ' "+ UserPwd + " ' and fUserName= ' " + UserName + " ' ";
ResultSet RsLoginCheck = stmt_Check.executeQuery(sql);
if(RsLoginCheck.next())
{
String a =RsLoginCheck.getString( "fPurview ");
String b= "超级用户 ";
if (a==b)
{
out.print( "成功 ");
}
else
{
out.print( "失败 ");
}
}
经查询,a显示出来是 "超级用户 ",可是在IF语句结束以后,始终显示 "失败 ",不知为何?
------解决方案--------------------if (a==b)
应该是
if (b.equals(a))