Advertisement
BorislavaYordanova

Evening Dress

May 1st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. package ClothingItemShop;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.Statement;
  7.  
  8. public class EveningDress extends ClothingItemShop {
  9.     private static float box_price;
  10.  
  11.     public EveningDress(float price_param, float weight_param, String color_param, String colorPattern_param,
  12.             String size_param, String fabric_param) {
  13.         super(price_param, weight_param, color_param, colorPattern_param, size_param, fabric_param);
  14.     }
  15.  
  16.     static {
  17.         try {
  18.             Connection connection = null;
  19.             Statement statement = null;
  20.  
  21.             Class.forName("com.mysql.jdbc.Driver");
  22.             connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/clothingitem", "root", "123456");
  23.  
  24.             statement = connection.createStatement();
  25.             ResultSet result = statement
  26.                     .executeQuery("SELECT container_price FROM containers WHERE item_type = 'Dress'");
  27.  
  28.             while (result.next()) {
  29.                 box_price = result.getFloat("container_price");
  30.                 System.out.println("The box price for the Dress is: " + box_price);
  31.             }
  32.             result.close();
  33.             statement.close();
  34.             connection.close();
  35.         } catch (Exception e) {
  36.             System.out.print(e);
  37.         }
  38.     }
  39.  
  40.     public float getContainerPrice() {
  41.         return box_price;
  42.     }
  43.  
  44.     public float getItemPrice() {
  45.         return price;
  46.     }
  47.  
  48.     public float getWeight() {
  49.         return weight;
  50.     }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement