Skip to content

Commit 2066afb

Browse files
committed
Added method to read all employees by office
1 parent abd8e14 commit 2066afb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Unit14/src/unit14/Actividad15_Aplicacion/DAO/EmpleadoDAO.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,23 @@ public List<Empleado> readAllRangeAge(int min, int max) {
7979
return empleados;
8080
}
8181

82+
public List<Empleado> readAllByOficina(int oficina) {
83+
List<Empleado> empleados = new ArrayList<>();
84+
if (conexion != null) {
85+
String query = "SELECT * FROM empleado WHERE oficina = ?";
86+
try (PreparedStatement ps = conexion.prepareStatement(query)) {
87+
ps.setInt(1, oficina);
88+
ResultSet rs = ps.executeQuery();
89+
while (rs.next()) {
90+
empleados.add(extractEmpleadoFromResultSet(rs));
91+
}
92+
} catch (SQLException e) {
93+
System.out.println("Error al leer los empleados");
94+
}
95+
}
96+
return empleados;
97+
}
98+
8299
@Override
83100
public void insert(Empleado empleado) {
84101
if (conexion != null) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy