Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 33.70 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.ResultSetMetaData;
  3. import java.sql.Statement;
  4. import java.util.*;
  5. import java.sql.*;
  6.  
  7. public class DataBase
  8. {
  9.         String url = "jdbc:mysql://localhost:3306/";
  10.         String user = "root";
  11.         String password = "Qazxsw2!";
  12.  
  13.  
  14.         /**
  15.          * Displays the data base
  16.          */
  17.         public void displayDB()
  18.         {
  19.                 try {
  20.                         Class.forName("com.mysql.jdbc.Driver");
  21.                         Connection conn = null;
  22.                         conn = DriverManager.getConnection(url, user, password);
  23.  
  24.                         Statement st = conn.createStatement();
  25.                         String query = "SELECT * FROM generator_postaci_rpg1.klasa";
  26.                         ResultSet rs = st.executeQuery(query);
  27.                         ResultSetMetaData rsmd = rs.getMetaData();
  28.                         System.out.println(rsmd);
  29.  
  30.                 } catch (ClassNotFoundException e) {
  31.                         System.out.println("Driver problem");
  32.                 } catch (SQLException e) {
  33.                         System.out.println(e);
  34.                 }
  35.         }
  36.  
  37.  
  38.         public void dodajAtut(String nazwa_atutu, int wymagany_poziom)
  39.         {
  40.                 try {
  41.                         Class.forName("com.mysql.jdbc.Driver");
  42.                         Connection conn = null;
  43.                         java.sql.PreparedStatement pst = null;
  44.                         conn = DriverManager.getConnection(url, user, password);
  45.                         if (conn != null) System.out.println("Connected");
  46.                         String sql = "INSERT INTO generator_postaci_rpg1.atut (Nazwa_AT,Wymagany_Poziom_AT) VALUES(?,?)";
  47.                         pst = conn.prepareStatement(sql);
  48.  
  49.  
  50.                         pst.setString(1, nazwa_atutu);
  51.                         pst.setInt(2, wymagany_poziom);
  52.  
  53.                         pst.executeUpdate();
  54.  
  55.                 } catch (ClassNotFoundException e) {
  56.                         System.out.println("Driver problem");
  57.                 } catch (SQLException e) {
  58.                         System.out.println(e);
  59.                 }
  60.         }
  61.  
  62.  
  63.         public void dodajAtutKlasy(int id_atutu, int id_klasy)
  64.         {
  65.                 try {
  66.                         Class.forName("com.mysql.jdbc.Driver");
  67.                         Connection conn = null;
  68.                         java.sql.PreparedStatement pst = null;
  69.                         conn = DriverManager.getConnection(url, user, password);
  70.                         if (conn != null) System.out.println("Connected");
  71.                         String sql = "INSERT INTO generator_postaci_rpg1.atuty_klasy (ID_AT,ID_KL) VALUES(?,?)";
  72.                         pst = conn.prepareStatement(sql);
  73.  
  74.                         pst.setInt(1, id_atutu);
  75.                         pst.setInt(2, id_klasy);
  76.  
  77.                         pst.executeUpdate();
  78.  
  79.                 } catch (ClassNotFoundException e) {
  80.                         System.out.println("Driver problem");
  81.                 } catch (SQLException e) {
  82.                         System.out.println(e);
  83.                 }
  84.         }
  85.  
  86.  
  87.         public void dodajAtutPostaci(int id_postaci, int id_atutu)
  88.         {
  89.                 try {
  90.                         Class.forName("com.mysql.jdbc.Driver");
  91.                         Connection conn = null;
  92.                         java.sql.PreparedStatement pst = null;
  93.                         conn = DriverManager.getConnection(url, user, password);
  94.                         if (conn != null) System.out.println("Connected");
  95.                         String sql = "INSERT INTO generator_postaci_rpg1.atuty_postaci (ID_P,ID_AT) VALUES(?,?)";
  96.                         pst = conn.prepareStatement(sql);
  97.  
  98.                         pst.setInt(1, id_postaci);
  99.                         pst.setInt(2, id_atutu);
  100.  
  101.                         pst.executeUpdate();
  102.  
  103.                 } catch (ClassNotFoundException e) {
  104.                         System.out.println("Driver problem");
  105.                 } catch (SQLException e) {
  106.                         System.out.println(e);
  107.                 }
  108.         }
  109.  
  110.         public void dodajBron(String nazwa_broni, int rzadkość, int atak, int szybkość_ataku, int wytrzymałość)
  111.         {
  112.                 try {
  113.                         Class.forName("com.mysql.jdbc.Driver");
  114.                         Connection conn = null;
  115.                         java.sql.PreparedStatement pst = null;
  116.                         conn = DriverManager.getConnection(url, user, password);
  117.                         if (conn != null) System.out.println("Connected");
  118.                         String sql = "INSERT INTO generator_postaci_rpg1.broń (Nazwa_B,Rzadkość_B,Atak_B,Szybkość_ataku_B," +
  119.                                 "Wytrzymałość_B) VALUES(?,?,?,?,?)";
  120.                         pst = conn.prepareStatement(sql);
  121.  
  122.  
  123.                         pst.setString(1, nazwa_broni );
  124.                         pst.setInt(2,rzadkość);
  125.                         pst.setInt(3,atak );
  126.                         pst.setInt(4,szybkość_ataku );
  127.                         pst.setInt(5, wytrzymałość);
  128.  
  129.                         pst.executeUpdate();
  130.  
  131.                 } catch (ClassNotFoundException e) {
  132.                         System.out.println("Driver problem");
  133.                 } catch (SQLException e) {
  134.                         System.out.println(e);
  135.                 }
  136.         }
  137.  
  138.         public void dodajCharakter(String moralnosc, String personalnosc)
  139.         {
  140.                 try {
  141.                         Class.forName("com.mysql.jdbc.Driver");
  142.                         Connection conn = null;
  143.                         java.sql.PreparedStatement pst = null;
  144.                         conn = DriverManager.getConnection(url, user, password);
  145.                         if (conn != null) System.out.println("Connected");
  146.                         String sql = "INSERT INTO generator_postaci_rpg1.charakter (Moralność_CHAR, Personalność_CHAR) VALUES(?,?)";
  147.                         pst = conn.prepareStatement(sql);
  148.  
  149.  
  150.                         pst.setString(1, moralnosc );
  151.                         pst.setString(2, personalnosc );
  152.  
  153.                         pst.executeUpdate();
  154.  
  155.                 } catch (ClassNotFoundException e) {
  156.                         System.out.println("Driver problem");
  157.                 } catch (SQLException e) {
  158.                         System.out.println(e);
  159.                 }
  160.         }
  161.  
  162.  
  163.  
  164.         public void dodajCzar(String nazwa, int wymagany_poziom, int wymagany_poziom_klasy, int kosztHP, int kosztMP, int ranga)
  165.         {
  166.                 try {
  167.                         Class.forName("com.mysql.jdbc.Driver");
  168.                         Connection conn = null;
  169.                         java.sql.PreparedStatement pst = null;
  170.                         conn = DriverManager.getConnection(url, user, password);
  171.                         if (conn != null) System.out.println("Connected");
  172.                         String sql = "INSERT INTO generator_postaci_rpg1.czar (Nazwa_CZ, Wymagany_poziom_CZ, Wymagany_poziom_klasy_CZ," +
  173.                                 "Koszt_many_CZ, Koszt_życia_CZ, Ranga_CZ) VALUES(?,?,?,?,?,?)";
  174.                         pst = conn.prepareStatement(sql);
  175.  
  176.  
  177.                         pst.setString(1, nazwa );
  178.                         pst.setInt(2, wymagany_poziom  );
  179.                         pst.setInt(3, wymagany_poziom_klasy);
  180.                         pst.setInt(4, kosztMP );
  181.                         pst.setInt(5, kosztHP);
  182.                         pst.setInt(6, ranga );
  183.  
  184.                         pst.executeUpdate();
  185.  
  186.                 } catch (ClassNotFoundException e) {
  187.                         System.out.println("Driver problem");
  188.                 } catch (SQLException e) {
  189.                         System.out.println(e);
  190.                 }
  191.         }
  192.  
  193.         public void dodajCzarKlasy(int id_klasy, int id_czaru)
  194.         {
  195.                 try {
  196.                         Class.forName("com.mysql.jdbc.Driver");
  197.                         Connection conn = null;
  198.                         java.sql.PreparedStatement pst = null;
  199.                         conn = DriverManager.getConnection(url, user, password);
  200.                         if (conn != null) System.out.println("Connected");
  201.                         String sql = "INSERT INTO generator_postaci_rpg1.czary_klasy (ID_KL,ID_CZ) VALUES(?,?)";
  202.                         pst = conn.prepareStatement(sql);
  203.  
  204.                         pst.setInt(1, id_klasy);
  205.                         pst.setInt(2, id_czaru);
  206.  
  207.                         pst.executeUpdate();
  208.  
  209.                 } catch (ClassNotFoundException e) {
  210.                         System.out.println("Driver problem");
  211.                 } catch (SQLException e) {
  212.                         System.out.println(e);
  213.                 }
  214.         }
  215.  
  216.         public void dodajCzescCiala(String nazwa, int HP)
  217.         {
  218.                 try {
  219.                         Class.forName("com.mysql.jdbc.Driver");
  220.                         Connection conn = null;
  221.                         java.sql.PreparedStatement pst = null;
  222.                         conn = DriverManager.getConnection(url, user, password);
  223.                         if (conn != null) System.out.println("Connected");
  224.                         String sql = "INSERT INTO generator_postaci_rpg1.część_ciała (Nazwa_CC, Punkty_Życia_CC) VALUES(?,?)";
  225.                         pst = conn.prepareStatement(sql);
  226.  
  227.  
  228.                         pst.setString(1, nazwa);
  229.                         pst.setInt(2, HP );
  230.  
  231.                         pst.executeUpdate();
  232.  
  233.                 } catch (ClassNotFoundException e) {
  234.                         System.out.println("Driver problem");
  235.                 } catch (SQLException e) {
  236.                         System.out.println(e);
  237.                 }
  238.         }
  239.  
  240.         public void dodajInwentarz()
  241.         {
  242.                 try {
  243.                         Class.forName("com.mysql.jdbc.Driver");
  244.                         Connection conn = null;
  245.                         java.sql.PreparedStatement pst = null;
  246.                         conn = DriverManager.getConnection(url, user, password);
  247.                         if (conn != null) System.out.println("Connected");
  248.                         String sql = "INSERT INTO generator_postaci_rpg1.inwentarz () VALUES()";
  249.                         pst = conn.prepareStatement(sql);
  250.  
  251.                         pst.executeUpdate();
  252.  
  253.                 } catch (ClassNotFoundException e) {
  254.                         System.out.println("Driver problem");
  255.                 } catch (SQLException e) {
  256.                         System.out.println(e);
  257.                 }
  258.         }
  259.  
  260.         public void dodajKlase(String nazwa, int poziom_klasy)
  261.         {
  262.                 try {
  263.                         Class.forName("com.mysql.jdbc.Driver");
  264.                         Connection conn = null;
  265.                         java.sql.PreparedStatement pst = null;
  266.                         conn = DriverManager.getConnection(url, user, password);
  267.                         if (conn != null) System.out.println("Connected");
  268.                         String sql = "INSERT INTO generator_postaci_rpg1.klasa (Nazwa_KL, Poziom_KL) VALUES(?,?)";
  269.                         pst = conn.prepareStatement(sql);
  270.  
  271.  
  272.                         pst.setString(1, nazwa);
  273.                         pst.setInt(2, poziom_klasy );
  274.  
  275.                         pst.executeUpdate();
  276.  
  277.                 } catch (ClassNotFoundException e) {
  278.                         System.out.println("Driver problem");
  279.                 } catch (SQLException e) {
  280.                         System.out.println(e);
  281.                 }
  282.         }
  283.  
  284.         public void dodajKonfiguracjeBroni(int id_typu_broni, int id_typu_cz_ciala)
  285.         {
  286.                 try {
  287.                         Class.forName("com.mysql.jdbc.Driver");
  288.                         Connection conn = null;
  289.                         java.sql.PreparedStatement pst = null;
  290.                         conn = DriverManager.getConnection(url, user, password);
  291.                         if (conn != null) System.out.println("Connected");
  292.                         String sql = "INSERT INTO generator_postaci_rpg1.konfiguracja_broni (ID_TB,ID_TCC) VALUES(?,?)";
  293.                         pst = conn.prepareStatement(sql);
  294.  
  295.                         pst.setInt(1, id_typu_broni);
  296.                         pst.setInt(2, id_typu_cz_ciala);
  297.  
  298.                         pst.executeUpdate();
  299.  
  300.                 } catch (ClassNotFoundException e) {
  301.                         System.out.println("Driver problem");
  302.                 } catch (SQLException e) {
  303.                         System.out.println(e);
  304.                 }
  305.         }
  306.  
  307.  
  308.         public void dodajKonfiguracjeZbroi(int id_typu_zbroi, int id_typu_cz_ciala)
  309.         {
  310.                 try {
  311.                         Class.forName("com.mysql.jdbc.Driver");
  312.                         Connection conn = null;
  313.                         java.sql.PreparedStatement pst = null;
  314.                         conn = DriverManager.getConnection(url, user, password);
  315.                         if (conn != null) System.out.println("Connected");
  316.                         String sql = "INSERT INTO generator_postaci_rpg1.konfiguracja_zbroi (ID_TZB,ID_TCC) VALUES(?,?)";
  317.                         pst = conn.prepareStatement(sql);
  318.  
  319.                         pst.setInt(1, id_typu_zbroi);
  320.                         pst.setInt(2, id_typu_cz_ciala);
  321.  
  322.                         pst.executeUpdate();
  323.  
  324.                 } catch (ClassNotFoundException e) {
  325.                         System.out.println("Driver problem");
  326.                 } catch (SQLException e) {
  327.                         System.out.println(e);
  328.                 }
  329.         }
  330.  
  331.         public void dodajMagicznyEkwipunek(MagicznyEkwipunek me)
  332.         {
  333.                 try {
  334.                         Class.forName("com.mysql.jdbc.Driver");
  335.                         Connection conn = null;
  336.                         java.sql.PreparedStatement pst = null;
  337.                         conn = DriverManager.getConnection(url, user, password);
  338.                         if (conn != null) System.out.println("Connected");
  339.                         String sql = "INSERT INTO generator_postaci_rpg1.magiczny_ekwipunek (Nazwa_ME,Bonus_Życia_ME,Bonus_Mana_ME,Bonus_Siła_ME,Bonus_Zręczność_ME,Bonus_Roztropność_ME,Bonus_Budowa_ME,Bonus_Charyzma_ME,Bonus_Inteligencja_ME,Opis_działania_ME) VALUES(?,?,?,?,?,?,?,?,?,?)";
  340.                         pst = conn.prepareStatement(sql);
  341.  
  342.                         pst.setString(1, me.nazwa);
  343.                         pst.setInt(2, me.b_zycia);
  344.                         pst.setInt(3, me.b_mana);
  345.                         pst.setInt(4, me.b_sila);
  346.                         pst.setInt(5, me.b_zrecznosc);
  347.                         pst.setInt(6, me.b_roztropnosc);
  348.                         pst.setInt(7, me.b_budowa);
  349.                         pst.setInt(8, me.b_charyzma);
  350.                         pst.setInt(9, me.b_inteligencja);
  351.                         pst.setString(10, me.opis);
  352.  
  353.                         pst.executeUpdate();
  354.  
  355.                 } catch (ClassNotFoundException e) {
  356.                         System.out.println("Driver problem");
  357.                 } catch (SQLException e) {
  358.                         System.out.println(e);
  359.                 }
  360.         }
  361.  
  362.         public void dodajMagicznyEkwipunekDoInwentarza(int id_inwentarza, int id_me)
  363.         {
  364.                 try {
  365.                         Class.forName("com.mysql.jdbc.Driver");
  366.                         Connection conn = null;
  367.                         java.sql.PreparedStatement pst = null;
  368.                         conn = DriverManager.getConnection(url, user, password);
  369.                         if (conn != null) System.out.println("Connected");
  370.                         String sql = "INSERT INTO generator_postaci_rpg1.magiczny_ekwipunek_w_inwentarzu (ID_I,ID_ME) VALUES(?,?)";
  371.                         pst = conn.prepareStatement(sql);
  372.  
  373.                         pst.setInt(1, id_inwentarza);
  374.                         pst.setInt(2, id_me);
  375.  
  376.                         pst.executeUpdate();
  377.  
  378.                 } catch (ClassNotFoundException e) {
  379.                         System.out.println("Driver problem");
  380.                 } catch (SQLException e) {
  381.                         System.out.println(e);
  382.                 }
  383.         }
  384.  
  385.         public void dodajMajatek(String nazwa, String rodzaj_majatku, int wartosc)
  386.         {
  387.                 try {
  388.                         Class.forName("com.mysql.jdbc.Driver");
  389.                         Connection conn = null;
  390.                         java.sql.PreparedStatement pst = null;
  391.                         conn = DriverManager.getConnection(url, user, password);
  392.                         if (conn != null) System.out.println("Connected");
  393.                         String sql = "INSERT INTO generator_postaci_rpg1.majatek (Nazwa_MJ, Rodzaj_majątku_MJ, Wartość_MJ) VALUES(?,?)";
  394.                         pst = conn.prepareStatement(sql);
  395.  
  396.  
  397.                         pst.setString(1, nazwa);
  398.                         pst.setString(2, rodzaj_majatku);
  399.                         pst.setInt(3, wartosc );
  400.  
  401.                         pst.executeUpdate();
  402.  
  403.                 } catch (ClassNotFoundException e) {
  404.                         System.out.println("Driver problem");
  405.                 } catch (SQLException e) {
  406.                         System.out.println(e);
  407.                 }
  408.         }
  409.  
  410.         public void dodajMajatekDoInwentarza(int id_inwentarza, int id_majatku)
  411.         {
  412.                 try {
  413.                         Class.forName("com.mysql.jdbc.Driver");
  414.                         Connection conn = null;
  415.                         java.sql.PreparedStatement pst = null;
  416.                         conn = DriverManager.getConnection(url, user, password);
  417.                         if (conn != null) System.out.println("Connected");
  418.                         String sql = "INSERT INTO generator_postaci_rpg1.majątek_w_inwentarzu (ID_I,ID_MJ) VALUES(?,?)";
  419.                         pst = conn.prepareStatement(sql);
  420.  
  421.                         pst.setInt(1, id_inwentarza);
  422.                         pst.setInt(2, id_majatku);
  423.  
  424.                         pst.executeUpdate();
  425.  
  426.                 } catch (ClassNotFoundException e) {
  427.                         System.out.println("Driver problem");
  428.                 } catch (SQLException e) {
  429.                         System.out.println(e);
  430.                 }
  431.         }
  432.  
  433.  
  434.  
  435.         public void dodajMiksture(String nazwa, int pojemnosc, int czasdziałania)
  436.         {
  437.                 try {
  438.                         Class.forName("com.mysql.jdbc.Driver");
  439.                         Connection conn = null;
  440.                         java.sql.PreparedStatement pst = null;
  441.                         conn = DriverManager.getConnection(url, user, password);
  442.                         if (conn != null) System.out.println("Connected");
  443.                         String sql = "INSERT INTO generator_postaci_rpg1.mikstura (Nazwa_MIKS, Pojemność_MIKS, Czas_działania_MIKS) VALUES(?,?)";
  444.                         pst = conn.prepareStatement(sql);
  445.  
  446.  
  447.                         pst.setString(1, nazwa);
  448.                         pst.setInt(2, pojemnosc);
  449.                         pst.setInt(3, czasdziałania );
  450.  
  451.                         pst.executeUpdate();
  452.  
  453.                 } catch (ClassNotFoundException e) {
  454.                         System.out.println("Driver problem");
  455.                 } catch (SQLException e) {
  456.                         System.out.println(e);
  457.                 }
  458.         }
  459.  
  460.         public void dodajMikstureDoInwentarza(int id_inwentarza, int id_mikstury)
  461.         {
  462.                 try {
  463.                         Class.forName("com.mysql.jdbc.Driver");
  464.                         Connection conn = null;
  465.                         java.sql.PreparedStatement pst = null;
  466.                         conn = DriverManager.getConnection(url, user, password);
  467.                         if (conn != null) System.out.println("Connected");
  468.                         String sql = "INSERT INTO generator_postaci_rpg1.mikstury_w_inwentarzu (ID_I,ID_MIKS) VALUES(?,?)";
  469.                         pst = conn.prepareStatement(sql);
  470.  
  471.                         pst.setInt(1, id_inwentarza);
  472.                         pst.setInt(2, id_mikstury);
  473.  
  474.                         pst.executeUpdate();
  475.  
  476.                 } catch (ClassNotFoundException e) {
  477.                         System.out.println("Driver problem");
  478.                 } catch (SQLException e) {
  479.                         System.out.println(e);
  480.                 }
  481.         }
  482.  
  483.         public void dodajPostac(Postac p)
  484.         {
  485.                 try {
  486.                         Class.forName("com.mysql.jdbc.Driver");
  487.                         Connection conn = null;
  488.                         java.sql.PreparedStatement pst = null;
  489.                         conn = DriverManager.getConnection(url, user, password);
  490.                         if (conn != null) System.out.println("Connected");
  491.                         String sql = "INSERT INTO generator_postaci_rpg1.postać (Imie_P,Wzrost_P,Waga_P,Kolor_oczu_P,Kolor_włosów_P,Karnacja_P,Poziom_P,Siła_P,Zręczność_P,Roztropność_P,Inteligencja_P,Budowa_P,Charyzma_P,Historia_P,Życia_P,ID_CHAR,ID_RS,ID_KL,ID_I) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  492.                         pst = conn.prepareStatement(sql);
  493.  
  494.                         pst.setString(1, p.imie_p);
  495.                         pst.setInt(2, p.wzrost);
  496.                         pst.setInt(3, p.waga);
  497.                         pst.setString(4, p.kolor_oczu);
  498.                         pst.setString(5, p.kolor_wlosow);
  499.                         pst.setString(6, p.karnacja);
  500.                         pst.setInt(7, p.poziom);
  501.                         pst.setInt(8, p.sila);
  502.                         pst.setInt(9, p.zrecznosc);
  503.                         pst.setInt(10, p.roztropnosc);
  504.                         pst.setInt(11, p.inteligencja);
  505.                         pst.setInt(12, p.budowa);
  506.                         pst.setInt(13, p.charyzma);
  507.                         pst.setString(14, p.historia);
  508.                         pst.setInt(15, p.zycie);
  509.                         pst.setInt(16, p.id_char);
  510.                         pst.setInt(17, p.id_rs);
  511.                         pst.setInt(18, p.id_kl);
  512.                         pst.setInt(19, p.id_inw);
  513.  
  514.                         pst.executeUpdate();
  515.  
  516.                 } catch (ClassNotFoundException e) {
  517.                         System.out.println("Driver problem");
  518.                 } catch (SQLException e) {
  519.                         System.out.println(e);
  520.                 }
  521.         }
  522.  
  523.         public void dodajRase(String nazwa_rasy)
  524.         {
  525.                 try {
  526.                         Class.forName("com.mysql.jdbc.Driver");
  527.                         Connection conn = null;
  528.                         java.sql.PreparedStatement pst = null;
  529.                         conn = DriverManager.getConnection(url, user, password);
  530.                         if (conn != null) System.out.println("Connected");
  531.                         String sql = "INSERT INTO generator_postaci_rpg1.rasa (Nazwa_RS) VALUES(?)";
  532.                         pst = conn.prepareStatement(sql);
  533.  
  534.                         pst.setString(1, nazwa_rasy);
  535.  
  536.                         pst.executeUpdate();
  537.  
  538.                 } catch (ClassNotFoundException e) {
  539.                         System.out.println("Driver problem");
  540.                 } catch (SQLException e) {
  541.                         System.out.println(e);
  542.                 }
  543.         }
  544.  
  545.         public void dodajTypBroni(String nazwa_tb, int id_b)
  546.         {
  547.                 try {
  548.                         Class.forName("com.mysql.jdbc.Driver");
  549.                         Connection conn = null;
  550.                         java.sql.PreparedStatement pst = null;
  551.                         conn = DriverManager.getConnection(url, user, password);
  552.                         if (conn != null) System.out.println("Connected");
  553.                         String sql = "INSERT INTO generator_postaci_rpg1.typ_broni (Nazwa_TB,ID_B) VALUES(?,?)";
  554.                         pst = conn.prepareStatement(sql);
  555.  
  556.                         pst.setString(1, nazwa_tb);
  557.                         pst.setInt(2, id_b);
  558.  
  559.                         pst.executeUpdate();
  560.  
  561.                 } catch (ClassNotFoundException e) {
  562.                         System.out.println("Driver problem");
  563.                 } catch (SQLException e) {
  564.                         System.out.println(e);
  565.                 }
  566.         }
  567.  
  568.         public void dodajTypCzesciCiala(String nazwa_tcc)
  569.         {
  570.                 try {
  571.                         Class.forName("com.mysql.jdbc.Driver");
  572.                         Connection conn = null;
  573.                         java.sql.PreparedStatement pst = null;
  574.                         conn = DriverManager.getConnection(url, user, password);
  575.                         if (conn != null) System.out.println("Connected");
  576.                         String sql = "INSERT INTO generator_postaci_rpg1.typ_części_ciała (Nazwa_TCC) VALUES(?)";
  577.                         pst = conn.prepareStatement(sql);
  578.  
  579.                         pst.setString(1, nazwa_tcc);
  580.  
  581.                         pst.executeUpdate();
  582.  
  583.                 } catch (ClassNotFoundException e) {
  584.                         System.out.println("Driver problem");
  585.                 } catch (SQLException e) {
  586.                         System.out.println(e);
  587.                 }
  588.         }
  589.  
  590.         public void dodajTypZbroi(String nazwa_tzb, int id_zb)
  591.         {
  592.                 try {
  593.                         Class.forName("com.mysql.jdbc.Driver");
  594.                         Connection conn = null;
  595.                         java.sql.PreparedStatement pst = null;
  596.                         conn = DriverManager.getConnection(url, user, password);
  597.                         if (conn != null) System.out.println("Connected");
  598.                         String sql = "INSERT INTO generator_postaci_rpg1.typ_zbroi (Nazwa_TZB,ID_ZB) VALUES(?,?)";
  599.                         pst = conn.prepareStatement(sql);
  600.  
  601.                         pst.setString(1, nazwa_tzb);
  602.                         pst.setInt(2, id_zb);
  603.  
  604.                         pst.executeUpdate();
  605.  
  606.                 } catch (ClassNotFoundException e) {
  607.                         System.out.println("Driver problem");
  608.                 } catch (SQLException e) {
  609.                         System.out.println(e);
  610.                 }
  611.         }
  612.  
  613.  
  614.         public void dodajUmiejetnosciKlasy(int id_umiejetnosci, int id_klasy)
  615.         {
  616.                 try {
  617.                         Class.forName("com.mysql.jdbc.Driver");
  618.                         Connection conn = null;
  619.                         java.sql.PreparedStatement pst = null;
  620.                         conn = DriverManager.getConnection(url, user, password);
  621.                         if (conn != null) System.out.println("Connected");
  622.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_klasy (ID_U,ID_KL) VALUES(?,?)";
  623.                         pst = conn.prepareStatement(sql);
  624.  
  625.                         pst.setInt(1, id_umiejetnosci);
  626.                         pst.setInt(2, id_klasy);
  627.  
  628.                         pst.executeUpdate();
  629.  
  630.                 } catch (ClassNotFoundException e) {
  631.                         System.out.println("Driver problem");
  632.                 } catch (SQLException e) {
  633.                         System.out.println(e);
  634.                 }
  635.         }
  636.  
  637.         public void dodajUmiejetnosciPostaci(int id_postaci, int id_umiejetnosci)
  638.         {
  639.                 try {
  640.                         Class.forName("com.mysql.jdbc.Driver");
  641.                         Connection conn = null;
  642.                         java.sql.PreparedStatement pst = null;
  643.                         conn = DriverManager.getConnection(url, user, password);
  644.                         if (conn != null) System.out.println("Connected");
  645.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_postaci (ID_P,ID_U) VALUES(?,?)";
  646.                         pst = conn.prepareStatement(sql);
  647.  
  648.                         pst.setInt(1, id_postaci);
  649.                         pst.setInt(2, id_umiejetnosci);
  650.  
  651.                         pst.executeUpdate();
  652.  
  653.                 } catch (ClassNotFoundException e) {
  654.                         System.out.println("Driver problem");
  655.                 } catch (SQLException e) {
  656.                         System.out.println(e);
  657.                 }
  658.         }
  659.  
  660.         public void dodajUmiejetnosciRas(int id_rasy, int id_umiejetnosci)
  661.         {
  662.                 try {
  663.                         Class.forName("com.mysql.jdbc.Driver");
  664.                         Connection conn = null;
  665.                         java.sql.PreparedStatement pst = null;
  666.                         conn = DriverManager.getConnection(url, user, password);
  667.                         if (conn != null) System.out.println("Connected");
  668.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_ras (ID_RS,ID_U) VALUES(?,?)";
  669.                         pst = conn.prepareStatement(sql);
  670.  
  671.                         pst.setInt(1, id_rasy);
  672.                         pst.setInt(2, id_umiejetnosci);
  673.  
  674.                         pst.executeUpdate();
  675.  
  676.                 } catch (ClassNotFoundException e) {
  677.                         System.out.println("Driver problem");
  678.                 } catch (SQLException e) {
  679.                         System.out.println(e);
  680.                 }
  681.         }
  682.  
  683.         public void dodajUmiejetnosci(String nazwa_um, int wym_poz, String opis)
  684.         {
  685.                 try {
  686.                         Class.forName("com.mysql.jdbc.Driver");
  687.                         Connection conn = null;
  688.                         java.sql.PreparedStatement pst = null;
  689.                         conn = DriverManager.getConnection(url, user, password);
  690.                         if (conn != null) System.out.println("Connected");
  691.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętność (Nazwa_U,Wymagany_poziom_U,Opis_U) VALUES(?,?,?)";
  692.                         pst = conn.prepareStatement(sql);
  693.  
  694.                         pst.setString(1, nazwa_um);
  695.                         pst.setInt(2, wym_poz);
  696.                         pst.setString(3, opis);
  697.  
  698.                         pst.executeUpdate();
  699.  
  700.                 } catch (ClassNotFoundException e) {
  701.                         System.out.println("Driver problem");
  702.                 } catch (SQLException e) {
  703.                         System.out.println(e);
  704.                 }
  705.         }
  706.  
  707.         public void dodajZbroje(String nazwa_zbroi, int rzadkosc, int klasa, int wytrzymalosc, int id_cc)
  708.         {
  709.                 try {
  710.                         Class.forName("com.mysql.jdbc.Driver");
  711.                         Connection conn = null;
  712.                         java.sql.PreparedStatement pst = null;
  713.                         conn = DriverManager.getConnection(url, user, password);
  714.                         if (conn != null) System.out.println("Connected");
  715.                         String sql = "INSERT INTO generator_postaci_rpg1.zbroja (Nazwa_ZB,Rzadkość_ZB,Klasa_Pancerza_ZB,Wytrzymałość_ZB,ID_CC) VALUES(?,?,?,?,?)";
  716.                         pst = conn.prepareStatement(sql);
  717.  
  718.                         pst.setString(1, nazwa_zbroi);
  719.                         pst.setInt(2, rzadkosc);
  720.                         pst.setInt(3, klasa);
  721.                         pst.setInt(4, wytrzymalosc);
  722.                         pst.setInt(5, id_cc);
  723.  
  724.                         pst.executeUpdate();
  725.  
  726.                 } catch (ClassNotFoundException e) {
  727.                         System.out.println("Driver problem");
  728.                 } catch (SQLException e) {
  729.                         System.out.println(e);
  730.                 }
  731.         }
  732.  
  733.  
  734.         public void dodajZwojDoInwentarza(int id_inwentarza, int id_zwoju)
  735.         {
  736.                 try {
  737.                         Class.forName("com.mysql.jdbc.Driver");
  738.                         Connection conn = null;
  739.                         java.sql.PreparedStatement pst = null;
  740.                         conn = DriverManager.getConnection(url, user, password);
  741.                         if (conn != null) System.out.println("Connected");
  742.                         String sql = "INSERT INTO generator_postaci_rpg1.zwoje_w_inwentarzu (ID_I,ID_ZWOJ) VALUES(?,?)";
  743.                         pst = conn.prepareStatement(sql);
  744.  
  745.                         pst.setInt(1, id_inwentarza);
  746.                         pst.setInt(2, id_zwoju);
  747.  
  748.                         pst.executeUpdate();
  749.  
  750.                 } catch (ClassNotFoundException e) {
  751.                         System.out.println("Driver problem");
  752.                 } catch (SQLException e) {
  753.                         System.out.println(e);
  754.                 }
  755.         }
  756.  
  757.  
  758.         public void dodajZwoje(String nazwa_zwoju, String opis, int czas_dzialania)
  759.         {
  760.                 try {
  761.                         Class.forName("com.mysql.jdbc.Driver");
  762.                         Connection conn = null;
  763.                         java.sql.PreparedStatement pst = null;
  764.                         conn = DriverManager.getConnection(url, user, password);
  765.                         if (conn != null) System.out.println("Connected");
  766.                         String sql = "INSERT INTO generator_postaci_rpg1.zwój (Nazwa_ZWOJ,Opis_działania_ZWOJ,Czas_dzialania_ZWOJ) VALUES(?,?,?)";
  767.                         pst = conn.prepareStatement(sql);
  768.  
  769.                         pst.setString(1, nazwa_zwoju);
  770.                         pst.setString(2,opis);
  771.                         pst.setInt(3,czas_dzialania);
  772.  
  773.                         pst.executeUpdate();
  774.  
  775.                 } catch (ClassNotFoundException e) {
  776.                         System.out.println("Driver problem");
  777.                 } catch (SQLException e) {
  778.                         System.out.println(e);
  779.                 }
  780.         }
  781.  
  782. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement