/** Deletes a single row in the carrito_compras table. */ public void delete(CarritoComprasPk pk) throws CarritoComprasDaoException { long t1 = System.currentTimeMillis(); // declare variables final boolean isConnSupplied = (userConn != null); Connection conn = null; PreparedStatement stmt = null; try { // get the user-specified connection or get a connection from the ResourceManager conn = isConnSupplied ? userConn : ResourceManager.getConnection(); System.out.println("Executing " + SQL_DELETE + " with PK: " + pk); stmt = conn.prepareStatement(SQL_DELETE); stmt.setString(1, pk.getIdCarrito()); int rows = stmt.executeUpdate(); long t2 = System.currentTimeMillis(); System.out.println(rows + " rows affected (" + (t2 - t1) + " ms)"); } catch (Exception _e) { _e.printStackTrace(); throw new CarritoComprasDaoException("Exception: " + _e.getMessage(), _e); } finally { ResourceManager.close(stmt); if (!isConnSupplied) { ResourceManager.close(conn); } } }
/** * Returns the rows from the carrito_compras table that matches the specified primary-key value. */ public CarritoCompras findByPrimaryKey(CarritoComprasPk pk) throws CarritoComprasDaoException { return findByPrimaryKey(pk.getIdCarrito()); }