Guest User

Untitled

a guest
Aug 4th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. try{
  2.  
  3. Class.forName("com.mysql.jdbc.Driver");
  4. conectar = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1/proyecto", "root", "");
  5.  
  6.  
  7. } catch (ClassNotFoundException ex) {
  8. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  9. } catch (SQLException ex) {
  10. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  11. }
  12. try{
  13. String sql= "UPDATE datos SET Nombre=?,"+ "Apellido=?,"+ "Email=?,"+"Foto=?,"+"Ruta=?,"+"Posicion=?,"+"Compañia=?,"+"Nota=?,"+"Telefono=?" +"WHERE Nombre='"+jTextField1.getText()+"'";
  14.  
  15. PreparedStatement pst= conectar.prepareStatement(sql);
  16.  
  17. pst.setString(1, jTextField1.getText());
  18. pst.setString(2, jTextField2.getText());
  19. pst.setString(3, jTextField3.getText());
  20. pst.setString(4, jTextField4.getText());
  21. pst.setString(5, jTextField5.getText());
  22. pst.setString(6, jTextField6.getText());
  23. pst.setString(7, jTextField8.getText());
  24. FileInputStream ArchivosFoto;
  25. FileInputStream Archivofoto = new FileInputStream(jTextField7.getText());
  26. pst.setBinaryStream(8, Archivofoto);
  27. pst.setString(9, jTextField7.getText());
  28. int n = pst.executeUpdate();
  29. if (n > 0) {
  30. JOptionPane.showMessageDialog(null, "Se modificaron los datos de manera correcta :D");
  31. tablaDatos();
  32.  
  33. } else {
  34.  
  35. JOptionPane.showMessageDialog(null, "Ocurrio un error, no se pudo modificar los datos :c");
  36.  
  37. }
  38. } catch (SQLException ex) {
  39. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  40. } catch (FileNotFoundException ex) {
  41. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  42. }
  43. }
Add Comment
Please, Sign In to add comment