从数据库中选择一个值,检查它是真还是假

时间:2013-04-02 03:25:32

标签: mkannotation

这段代码总是返回true,有些请帮帮我

public boolean plselct(String sqd)
    {
     try{
         String player  ;

         pm = conn.prepareStatement("SELECT playertype FROM playerdetails where idplayeratrr = ?");

         pm.setString(1,sqd );
         h= pm.executeQuery();

         player = h.getString("playertype");

         if ("Goal keeper".equals(player))
         { return true; }
         else 
           return false;

       }catch (Exception e)
        {}
    return false;
}

SelectQu p = new SelectQu();
p.plselct("77");

if(true)
{ System.out.println("Yes"); }
else 
{ System.out.println("No"); }

1 个答案:

答案 0 :(得分:0)

您正在检查if(true)?你的意思是:

SelectQu p = new SelectQu();

if(p.plselct("77"))
{ 
     System.out.println("Yes"); 
}
else 
{ 
    System.out.println("No"); 
}