if(!(isInvalid(strwhere)))
{
sql+=" where "+strwhere;
}
if(!(isInvalid(strorder)))
{
sql+=" order by "+strorder;
}
Statement stat = null;
ResultSet rs = null;
Connection conn = new DBHelper().getConn();
List<AdminBean> list=new ArrayList<AdminBean>();
try{
stat = conn.createStatement();
rs = stat.executeQuery(sql);
while(rs.next()){
AdminBean cnbean=new AdminBean();
cnbean.setAdmin_ID(rs.getInt("Admin_ID"));
cnbean.setAdmin_Username(rs.getString("Admin_Username"));
cnbean.setAdmin_Password(rs.getString("Admin_Password"));
cnbean.setAdmin_Name(rs.getString("Admin_Name"));
cnbean.setAdmin_Sex(rs.getString("Admin_Sex"));
cnbean.setAdmin_Tel(rs.getString("Admin_Tel"));
list.add(cnbean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (conn != null)
conn.close();
if (stat != null)
stat.close();
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
開頭的f(!(isInvalid(strwhere)))是什么意思啊大佬們,小白真的不懂了求救
uj5u.com熱心網友回復:
如果編譯能通過 isInvalid(strwhere) 回傳的應該是 true 或者 false 然后取反;意思就是當 isInvalid(strwhere) 回傳false的時候 進入 if 代碼塊
uj5u.com熱心網友回復:
isInvalid應當是個自定義的方法吧,看方法名就是判斷引數是否已失效,結合代碼背景關系當失效時回傳為true,未失效時回傳為true.代碼就是判斷是否包含where和order by條件。
uj5u.com熱心網友回復:
引數無效的話,不走if里面,有效的話,走if里面uj5u.com熱心網友回復:
if(!(isInvalid(strwhere)))if是判斷陳述句
isInvalid是方法回傳boolean值,引數應該是字串
strwhere 沒猜錯的話這應該是字串吧,是上面方法的實參
題外話,如果你這是作業中遇到的問題,那么,我建議你可以換個職位做做,比如測驗之類的。
uj5u.com熱心網友回復:
public static boolean isInvalid(Object s){
if(s==null||"".equals(s)){
return true;
}
return false;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/46140.html
標籤:Web 開發
上一篇:怎樣解決JDBC 例外?
下一篇:關于后端學習的問題
