SQL fanatics
Author: adminNov 17
There’s always a couple of ways to solving a problem. Right? So why not do everything you can in SQL. Takes the pressure of the server-side programming … rofl
Source: TheDailyWTF.com
// Check if date is valid!
String allowed = "not allowed";
sql = "SELECT IF(DATE(?) <= DATE(?),'allowed','not allowed')";
stmt = con.prepareStatement(sql);
stmt.setString(1, firstDate);
stmt.setString(2, terminationDate);
rs = stmt.executeQuery();
while(rs.next()){
allowed = rs.getString(1);
}
rs.close();
stmt.close();
if(!allowed.equalsIgnoreCase("allowed")){
throw new Exception("Termination Date to early!");
}




