用注释的代码就出错?原理不是一样的么?
猪小烧 2007-08-13 01:03:01 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;
ex.printStackTrace ();
}
return false;
}
真的非常奇怪
按密码来查找就没问题
按名字来查找的话就说没有这列...........
我的名字和密码在SQL里的数据类型是carchar(50)
求高人指点迷津