Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1665878

Browse files
Fixed ID autoincrement int EmpleadoDAO
1 parent ab72a35 commit 1665878

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,16 @@ public List<Empleado> readAllRangeAge(int min, int max) {
8282
@Override
8383
public void insert(Empleado empleado) {
8484
if (conexion != null) {
85-
String query = "INSERT INTO empleado VALUES (?, ?, ?, ?, ?, ?)";
85+
String query = "INSERT INTO empleado VALUES (DEFAULT, ?, ?, ?, ?, ?)";
8686
try (PreparedStatement ps = conexion.prepareStatement(query)) {
87-
ps.setInt(1, empleado.getId());
88-
ps.setString(2, empleado.getNombre());
89-
ps.setInt(3, empleado.getEdad());
90-
ps.setInt(4, empleado.getOficina().getOficina());
91-
ps.setString(5, empleado.getPuesto());
92-
ps.setDate(6, Date.valueOf(empleado.getContrato()));
87+
ps.setString(1, empleado.getNombre());
88+
ps.setInt(2, empleado.getEdad());
89+
ps.setInt(3, empleado.getOficina().getOficina());
90+
ps.setString(4, empleado.getPuesto());
91+
ps.setDate(5, Date.valueOf(empleado.getContrato()));
9392
ps.executeUpdate();
9493
} catch (SQLException e) {
95-
System.out.println("Error al insertar el empleado");
94+
System.out.println(e.getMessage());
9695
}
9796
}
9897
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /