Advertisement
arthur_arw

MetodoAdicionar

Nov 26th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1.     public void AumentarEstoque(int id, float qntd) {
  2.         String sql = "UPDATE produtos SET qntdEstoque = qntd WHERE id = ?";
  3.  
  4.         Connection conn = null;
  5.         PreparedStatement x = null;
  6.  
  7.         try {
  8.             conn = Conexao.createConnectionToMySQL();
  9.             x = conn.prepareStatement(sql);
  10.  
  11.             x.setInt(1, id);
  12.             x.setFloat(2, qntd);
  13.             x.execute();
  14.         } catch (Exception e) {
  15.             e.printStackTrace();
  16.  
  17.         } finally {
  18.             try {
  19.                 if (x != null) {
  20.                     x.close();
  21.                 }
  22.                 if (conn != null) {
  23.                     conn.close();
  24.                 }
  25.             } catch (Exception e) {
  26.                 e.printStackTrace();
  27.             }
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement