日期:2014-05-18  浏览次数:20662 次

大家进来看下啊 感觉应该是个小错误 但不知道如何改。。
注意我打星号的位置
public   Boolean   login(String   userid,String   userpassword)
  {     *****Boolean   login=true;*******
      ResultSet   rs=null;
  //查询数据库
  try{
  Connection   con=DriverManager.getConnection( "jdbc:odbc:sun ", "sa ", " ");
      Statement   stmt=con.createStatement();
      String   sql= "select   *   from   userinfo   where   id= ' "+userid+ " '   and   pw= ' "+userpassword+ " ' ";
  rs=stmt.executeQuery(sql);
  if(rs.next()){
  return   *****true******;
      }
    else{
      return   ******false*****;
  }
  }catch(SQLException   ex){System.err.println( "check.login(): "+ex.getMessage());}
            return   login;                  
}

编译时   提示   是   不匹配/不适合的类型   我用的JBUILDER  
应该没翻译错。。。大家看看怎么解决

------解决方案--------------------
public boolean login(String userid,String userpassword) throws Exception
{
ResultSet rs=null;
Connection con=null;
Statement stmt=null;
//查询数据库
try{
con=DriverManager.getConnection( "jdbc:odbc:sun ", "sa ", " ");
stmt=con.createStatement();
String sql= "select * from userinfo where id= ' "+userid+ " ' and pw= ' "+userpassword+ " ' ";
rs=stmt.executeQuery(sql);
return rs.next();
}catch(SQLException ex){
System.err.println( "check.login(): "+ex.getMessage());
throw ex;
}
}finally{
if(rs!= null)rs.close();
if(stmt!= null)stmt.close();
if(conn!= null)conn.close();
}
布尔类型是boolean,Boolean是包装类了