import java.util.ArrayList; import java.sql.Connection; import java.Statement; import java.ResultSet; public class DataSource { Database database; public DataSource(Database database) { this.database = database; } public ArrayList getEmployees() { try { tryGetEmployee(); }catch(SQLException e) { System.err.println("Hiba! Az elérés sikertelen!"); System.err.println(e.getMessage()); return null; } } public ArrayList tryGetEmployee() { ArrayList empList = new ArrayList<>(); Connection conn = database.connect(); String sql = "select * from emplyoees"; Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); while(rs.next()) { Employee emp = new Employee(); emp.id = rs.getInt("id"); emp.name = rs.getString("name"); emp.city = rs.getString("city"); emp.salary = rs.getDouble("salary"); empList.add(emp); } return empList; } }