i need to retrieve data from an SQL database and put it in a hashmap , i'am a bit lost about how to do that especially with my given data types , if anyone can help and explain to me the process it would be great , here's below my code :
public void load (Path p) throws DataLoadingException {
try {
String pathString = p.toString();
Connection c = DriverManager.getConnection("jdbc:sqlite:"+pathString);
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("select * from PassengerNumbers;");
while (rs.next()) {
LocalDate date = LocalDate.parse(rs.getString("Date"));
int flightnumber = Integer.parseInt(rs.getString("FlightNumber"));
int loadestimate = Integer.parseInt(rs.getString("LoadEstimate"));
}
rs.close();
c.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Here's what the data looks like in the SqlDb :
(PK TEXT) (PK INTEGER) (INTEGER)
Date FlightNumber LoadEstimate
2020-07-01 618 124