swing update
Publicado por Francisco (56 intervenciones) el 17/10/2018 23:50:51
Hola, como va?, no me ejecuta el siguiente código:
Yo quiero seleccionar un registro para modificarlo desde el net beans y que también se modifique en el mysql, pero cuando aprieto en modificar, el registro sigue igual.
¿Donde esta mi error?
muchas gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
int fila = jtbHtMedicos.getSelectedRow();
if(fila >= 0){
jtbHtMedicos.getValueAt(fila, 0).toString();
jtbHtMedicos.getValueAt(fila,1).toString();
jtbHtMedicos.getValueAt(fila, 2).toString();
jtbHtMedicos.getValueAt(fila,3).toString();
}
else{
JOptionPane.showMessageDialog(null, "fila no seleccionada");
}
String valorMatricula = jtbHtMedicos.getValueAt(fila, 0).toString();
String valorDiaTrabajo = jtbHtMedicos.getValueAt(fila,1).toString();
String valorHoraEntrada = jtbHtMedicos.getValueAt(fila, 2).toString();
String valorHoraSalida = jtbHtMedicos.getValueAt(fila,3).toString();
try {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); //("HH:mm:ss a")
String SQL = "UPDATE horariosdetrabajo SET `horaDeSalida`= ? WHERE `matricula`= ? AND `diaTrabajoSemanal`= ? AND `horaDeEntrada`= ?";
PreparedStatement ps = conn.prepareStatement(SQL);
ps.setInt(1, Integer.parseInt(valorMatricula));
ps.setString(2, valorDiaTrabajo);
ps.setTime(3, new java.sql.Time(formatter.parse(valorHoraEntrada).getTime()));
ps.setTime(4, new java.sql.Time(formatter.parse(valorHoraSalida).getTime()));
ps.executeUpdate();
mostrarDatos();
} catch (ParseException ex) {
Logger.getLogger(AbmMedico.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(AbmMedico.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(AbmMedico.class.getName()).log(Level.SEVERE, null, ex);
}
}
Yo quiero seleccionar un registro para modificarlo desde el net beans y que también se modifique en el mysql, pero cuando aprieto en modificar, el registro sigue igual.
¿Donde esta mi error?
muchas gracias
Valora esta pregunta


0