Guest User

Untitled

a guest
Sep 9th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. package ventas.conexion.tablas;
  2.  
  3. import java.sql.CallableStatement;
  4. import java.sql.Connection;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import ventas.conexion.Conexion;
  8.  
  9. public class ventasBodegasProductos {
  10.        
  11.     Connection connMY = null;
  12.     private String host,bd,user,pass;
  13.    
  14.     private int idVentaBodegaProducto;
  15.     private int cantidad;
  16.     private int idVenta;
  17.     private int idBodegaProducto;
  18.    
  19.     public ventasBodegasProductos (String host, String bd, String user, String pass) {
  20.         this.host = host; this.bd = bd; this.user = user; this.pass = pass;
  21.     }
  22.    
  23.     /**
  24.      * Devuelve el id del resultado del query de la tabla bodegaProducto
  25.      * @return
  26.      */
  27.     public int getIdVentaBodegaProducto() {
  28.         return this.idVentaBodegaProducto;
  29.     }    
  30.    
  31.     public int getCantidad () {
  32.         return this.cantidad;
  33.     }    
  34.    
  35.     public int getIdVenta () {
  36.         return this.idVenta;
  37.     }    
  38.    
  39.     public int getIdBodegaProducto () {
  40.         return this.idBodegaProducto;
  41.     }
  42.    
  43.     public void setIdVentaBodegaProducto (int vbp) {
  44.         this.idVentaBodegaProducto = vbp;
  45.     }
  46.    
  47.     public void setCantidad (int c) {
  48.         this.cantidad = c;
  49.     }
  50.    
  51.     public void setIdVenta (int iv) {
  52.         this.idVenta = iv;
  53.     }
  54.    
  55.     public void setIdBodegaProducto (int ibp) {
  56.         this.idBodegaProducto = ibp;
  57.     }
  58.  
  59.    
  60.     @SuppressWarnings("static-access")
  61.     public final synchronized void selectAllByID (int id) throws ClassNotFoundException, SQLException {
  62.         Conexion c = new Conexion();
  63.         connMY = c.Conectar(host,bd,user,pass);
  64.         CallableStatement pa = connMY.prepareCall("{ call selectAllByID_ventasBodegasProductos(?) }");
  65.         pa.setInt("ID", id);
  66.         ResultSet rs = pa.executeQuery();
  67.         rs.first();
  68.         this.setIdVentaBodegaProducto(rs.getInt("idVentaBodegaProducto"));
  69.         this.setCantidad(rs.getInt("cantidad"));
  70.         this.setIdVenta(rs.getInt("idVenta"));
  71.         this.setIdBodegaProducto(rs.getInt("idBodegaProducto"));
  72.         connMY.close();
  73.     }    
  74.    
  75. }
Add Comment
Please, Sign In to add comment