JuanAlves73

BotaoAtualizar

Nov 30th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. private void jButtonAtualizarActionPerformed(java.awt.event.ActionEvent evt) {                                                
  2.         String sql = "UPDATE livros SET titulo=?,cod_autor=?,cod_editora=?,ed=?, preco_livro WHERE codigo=?";
  3.  
  4.         try {
  5.             PreparedStatement statement = livraria.connection.prepareStatement(sql);
  6.             statement.setString(1, tfTitulo.getText());
  7.             statement.setString(2, tfAutor.getText());
  8.             statement.setString(3, tfEditora.getText());
  9.             statement.setString(4, tfEd.getText()); //
  10.             statement.setString(5, tfCodigo.getText());
  11.             statement.setString(6, tfPreco.getText());
  12.            
  13.            
  14.             statement.executeUpdate();
  15.             JOptionPane.showMessageDialog(null, "Cadastro realizado com sucesso");
  16.         } catch (Exception e) {
  17.             System.out.println("O erro é o seguinte: " + e.toString());
  18.             System.exit(0);
  19.         }
  20.  
  21.     }
Add Comment
Please, Sign In to add comment