Home > front end >  Use the list can't remove the value is null
Use the list can't remove the value is null

Time:09-20

Take out the data of id=0, name=null, info=null, use SQL Server2008 database
The code is as follows:
Public class ClazzDao extends BaseDao {
Public List GetClazzList (Clazz Clazz, Page Page) {
List Ret=new ArrayList (a);
String SQL="select * from s_clazz";
if(! StringUtil. IsEmpty (clazz. GetName ())) {
(this step is to judge the result is true, so the back of the if statement is skipped)
SQL +="where name like '%' + clazz. GetName () +" '";

(when forced to false, remove the data is still the id=0, name=null, info=null)
SQL +="limit" + page. GetStart () + ", "+ page. GetPageSize ();


The ResultSet ResultSet=query (SQL);
Try {
While (resultSet. Next ()) {
Clazz cl=new Clazz ();
Cl. SetId (resultSet. Get int (" id "));
Cl. Elegantly-named setName (resultSet. Get string (" name "));
Cl. SetInfo (resultSet. Get string (" info "));
Ret. Add (cl);


}
} the catch (SQLException e) {
//TODO to automatically generate the catch block of
e.printStackTrace();
}
}

return ret;
}


}


The console output:
[]
For bosses, what went wrong=-=

CodePudding user response:

The original is SQL Server cannot use limit
  • Related