Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Connection conexion=null;
  2.  
  3. try{
  4. PreparedStatement ps = cn.prepareStatement("INSERT INTO Clientes (Nombre, Apellido, Sexo, Edad, Telefono, Peso) VALUES (?,?,?,?,?,?)");
  5.  
  6. ps.setString(1, txtNombre.getText() );
  7. ps.setString(2, txtApellidos.getText() );
  8. ps.setString(3, comboBoxSexo.getSelectedItem().toString() );
  9. ps.setString(4, txtEdad.getText() );
  10. ps.setString(5, txtTelefono.getText() );
  11. ps.setString(6, txtPeso.getText() );
  12.  
  13.  
  14. int res = ps.executeUpdate();
  15.  
  16. if (res>0){
  17. JOptionPane.showMessageDialog(null, "PERSONA GUARDADA");
  18. } else{
  19. JOptionPane.showMessageDialog(null, "FALLA AL GUARDAR");
  20.  
  21. }//fin else
  22. conexion.close(); //cerrando la conexión
  23.  
  24. }catch(Exception e){
  25. System.out.println(e);
  26. }//Fin TryCath
  27. limpiarCaja(); //Limpia el texto introducido
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement