Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- Class.forName("com.mysql.jdbc.Driver");
- conectar = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1/proyecto", "root", "");
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
- } catch (SQLException ex) {
- Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
- }
- try{
- String sql= "UPDATE datos SET Nombre=?,"+ "Apellido=?,"+ "Email=?,"+"Foto=?,"+"Ruta=?,"+"Posicion=?,"+"Compañia=?,"+"Nota=?,"+"Telefono=?" +"WHERE Nombre='"+jTextField1.getText()+"'";
- PreparedStatement pst= conectar.prepareStatement(sql);
- pst.setString(1, jTextField1.getText());
- pst.setString(2, jTextField2.getText());
- pst.setString(3, jTextField3.getText());
- pst.setString(4, jTextField4.getText());
- pst.setString(5, jTextField5.getText());
- pst.setString(6, jTextField6.getText());
- pst.setString(7, jTextField8.getText());
- FileInputStream ArchivosFoto;
- FileInputStream Archivofoto = new FileInputStream(jTextField7.getText());
- pst.setBinaryStream(8, Archivofoto);
- pst.setString(9, jTextField7.getText());
- int n = pst.executeUpdate();
- if (n > 0) {
- JOptionPane.showMessageDialog(null, "Se modificaron los datos de manera correcta :D");
- tablaDatos();
- } else {
- JOptionPane.showMessageDialog(null, "Ocurrio un error, no se pudo modificar los datos :c");
- }
- } catch (SQLException ex) {
- Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
- } catch (FileNotFoundException ex) {
- Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Add Comment
Please, Sign In to add comment