日期:2014-05-20  浏览次数:20957 次

用注释的代码就出错?原理不是一样的么?
public   Boolean   isHasInDB   (   String   name   ,   String   password   )
        {
                Connection   con   =   connetionDB.getConnetionDB   ();
                Statement   controlDB   =   null;
                //String   SQL   =   "select   Password   from   Card   where   Id   =   "+   name;//为什么这样就会出错??????????
                String   SQL   =   "select   Id   from   Card   where   Password   =   "   +   password;
                try
                {
                        controlDB   =   con.createStatement   ();
                        ResultSet   rsDB   =   controlDB.executeQuery   (   SQL   );
                        while   (   rsDB.next   ()   )
                        {

                                //if   (   rsDB.getString   (   1   ).equals   (   password   )   )//为什么这样就会出错??????????
                                if   (   rsDB.getString   (   1   ).equals   (   name   )   )
                                {
                                        rsDB.close   ();
                                        con.close   ();
                                        controlDB.close   ();
                                        return   true;
                                }
                        }
                        rsDB.close   ();
                        con.close   ();
                        controlDB.close   ();

                }
                catch   (   SQLException   ex   )
                {
                        //return   false;