Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<Lot> showFlights() {
- List<Lot> list = new ArrayList<>() ;
- Connection connect;
- Statement statement;
- ResultSet resultSet;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- connect = DriverManager.getConnection("jdbc:mysql://localhost/lotnisko?user=root");
- statement = connect.createStatement();
- resultSet = statement.executeQuery("select * from loty where 1");
- while (resultSet.next()) {
- list.add(new Lot(Integer.parseInt(resultSet.getString(1)), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4), resultSet.getString(5)));
- }
- if (resultSet != null) {
- resultSet.close();
- }
- if (statement != null) {
- statement.close();
- }
- if (connect != null) {
- connect.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return list;
- }
Add Comment
Please, Sign In to add comment