Gets a value from the database.
int result = 0;
Statement stmt = null;
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next()) {
result = rs.getInt(1);
}
} catch (final SQLException ex) {
throw ex;
} finally {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
}
return result;