"A certain coworker of mine likes to do everything in SQL," Christoffer Hoel writes, "and I mean everything."
"Of course, since our management is non-technical, there's very little any of us can do aside from just toletarting the code. After all, his code runs about the same as ours... and that's all that matters, right?"
// 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!");
}