Accessed Nulls
by Remy Porter
in CodeSOD
on 2024-05-13
"The attached class connects to an Access database," writes Nicolai. That's always a good start for a WTF. Let's take a look.
public class ResultLoader {
private static Logger sysLog = Logger.getLogger(ResultLoader.class);
private static String url = "somePath";
private static Table getResultTable(String tableName) {
try {
File db = new File(url);
return Database.open(db).getTable(tableName);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static void loadResult() {
String tableName = "Result";
Table resultTable = getResultTable(tableName);
if (!resultTable.equals(null)) {
Map<Integer, Float> yearConsumption = new HashMap<Integer, Float>();
for (Map<String, Object> row : resultTable) {
}
Result result = new Result(00, new Date(), consumptions);
} else {
sysLog.info("There is no data object in the Access Database!");
}
}
}