Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 30.07 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 dodajMagicznyEkwipunekDoInwentarza(int id_inwentarza, int id_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_w_inwentarzu (ID_I,ID_ME) VALUES(?,?)";
  340.                         pst = conn.prepareStatement(sql);
  341.  
  342.                         pst.setInt(1, id_inwentarza);
  343.                         pst.setInt(2, id_me);
  344.  
  345.                         pst.executeUpdate();
  346.  
  347.                 } catch (ClassNotFoundException e) {
  348.                         System.out.println("Driver problem");
  349.                 } catch (SQLException e) {
  350.                         System.out.println(e);
  351.                 }
  352.         }
  353.  
  354.         public void dodajMajatek(String nazwa, String rodzaj_majatku, int wartosc)
  355.         {
  356.                 try {
  357.                         Class.forName("com.mysql.jdbc.Driver");
  358.                         Connection conn = null;
  359.                         java.sql.PreparedStatement pst = null;
  360.                         conn = DriverManager.getConnection(url, user, password);
  361.                         if (conn != null) System.out.println("Connected");
  362.                         String sql = "INSERT INTO generator_postaci_rpg1.majatek (Nazwa_MJ, Rodzaj_majątku_MJ, Wartość_MJ) VALUES(?,?)";
  363.                         pst = conn.prepareStatement(sql);
  364.  
  365.  
  366.                         pst.setString(1, nazwa);
  367.                         pst.setString(2, rodzaj_majatku);
  368.                         pst.setInt(3, wartosc );
  369.  
  370.                         pst.executeUpdate();
  371.  
  372.                 } catch (ClassNotFoundException e) {
  373.                         System.out.println("Driver problem");
  374.                 } catch (SQLException e) {
  375.                         System.out.println(e);
  376.                 }
  377.         }
  378.  
  379.         public void dodajMajatekDoInwentarza(int id_inwentarza, int id_majatku)
  380.         {
  381.                 try {
  382.                         Class.forName("com.mysql.jdbc.Driver");
  383.                         Connection conn = null;
  384.                         java.sql.PreparedStatement pst = null;
  385.                         conn = DriverManager.getConnection(url, user, password);
  386.                         if (conn != null) System.out.println("Connected");
  387.                         String sql = "INSERT INTO generator_postaci_rpg1.majątek_w_inwentarzu (ID_I,ID_MJ) VALUES(?,?)";
  388.                         pst = conn.prepareStatement(sql);
  389.  
  390.                         pst.setInt(1, id_inwentarza);
  391.                         pst.setInt(2, id_majatku);
  392.  
  393.                         pst.executeUpdate();
  394.  
  395.                 } catch (ClassNotFoundException e) {
  396.                         System.out.println("Driver problem");
  397.                 } catch (SQLException e) {
  398.                         System.out.println(e);
  399.                 }
  400.         }
  401.  
  402.  
  403.  
  404.         public void dodajMiksture(String nazwa, int pojemnosc, int czasdziałania)
  405.         {
  406.                 try {
  407.                         Class.forName("com.mysql.jdbc.Driver");
  408.                         Connection conn = null;
  409.                         java.sql.PreparedStatement pst = null;
  410.                         conn = DriverManager.getConnection(url, user, password);
  411.                         if (conn != null) System.out.println("Connected");
  412.                         String sql = "INSERT INTO generator_postaci_rpg1.mikstura (Nazwa_MIKS, Pojemność_MIKS, Czas_działania_MIKS) VALUES(?,?)";
  413.                         pst = conn.prepareStatement(sql);
  414.  
  415.  
  416.                         pst.setString(1, nazwa);
  417.                         pst.setInt(2, pojemnosc);
  418.                         pst.setInt(3, czasdziałania );
  419.  
  420.                         pst.executeUpdate();
  421.  
  422.                 } catch (ClassNotFoundException e) {
  423.                         System.out.println("Driver problem");
  424.                 } catch (SQLException e) {
  425.                         System.out.println(e);
  426.                 }
  427.         }
  428.  
  429.         public void dodajMikstureDoInwentarza(int id_inwentarza, int id_mikstury)
  430.         {
  431.                 try {
  432.                         Class.forName("com.mysql.jdbc.Driver");
  433.                         Connection conn = null;
  434.                         java.sql.PreparedStatement pst = null;
  435.                         conn = DriverManager.getConnection(url, user, password);
  436.                         if (conn != null) System.out.println("Connected");
  437.                         String sql = "INSERT INTO generator_postaci_rpg1.mikstury_w_inwentarzu (ID_I,ID_MIKS) VALUES(?,?)";
  438.                         pst = conn.prepareStatement(sql);
  439.  
  440.                         pst.setInt(1, id_inwentarza);
  441.                         pst.setInt(2, id_mikstury);
  442.  
  443.                         pst.executeUpdate();
  444.  
  445.                 } catch (ClassNotFoundException e) {
  446.                         System.out.println("Driver problem");
  447.                 } catch (SQLException e) {
  448.                         System.out.println(e);
  449.                 }
  450.         }
  451.  
  452.         public void dodajRase(String nazwa_rasy)
  453.         {
  454.                 try {
  455.                         Class.forName("com.mysql.jdbc.Driver");
  456.                         Connection conn = null;
  457.                         java.sql.PreparedStatement pst = null;
  458.                         conn = DriverManager.getConnection(url, user, password);
  459.                         if (conn != null) System.out.println("Connected");
  460.                         String sql = "INSERT INTO generator_postaci_rpg1.rasa (Nazwa_RS) VALUES(?)";
  461.                         pst = conn.prepareStatement(sql);
  462.  
  463.                         pst.setString(1, nazwa_rasy);
  464.  
  465.                         pst.executeUpdate();
  466.  
  467.                 } catch (ClassNotFoundException e) {
  468.                         System.out.println("Driver problem");
  469.                 } catch (SQLException e) {
  470.                         System.out.println(e);
  471.                 }
  472.         }
  473.  
  474.         public void dodajTypBroni(String nazwa_tb, int id_b)
  475.         {
  476.                 try {
  477.                         Class.forName("com.mysql.jdbc.Driver");
  478.                         Connection conn = null;
  479.                         java.sql.PreparedStatement pst = null;
  480.                         conn = DriverManager.getConnection(url, user, password);
  481.                         if (conn != null) System.out.println("Connected");
  482.                         String sql = "INSERT INTO generator_postaci_rpg1.typ_broni (Nazwa_TB,ID_B) VALUES(?,?)";
  483.                         pst = conn.prepareStatement(sql);
  484.  
  485.                         pst.setString(1, nazwa_tb);
  486.                         pst.setInt(2, id_b);
  487.  
  488.                         pst.executeUpdate();
  489.  
  490.                 } catch (ClassNotFoundException e) {
  491.                         System.out.println("Driver problem");
  492.                 } catch (SQLException e) {
  493.                         System.out.println(e);
  494.                 }
  495.         }
  496.  
  497.         public void dodajTypCzesciCiala(String nazwa_tcc)
  498.         {
  499.                 try {
  500.                         Class.forName("com.mysql.jdbc.Driver");
  501.                         Connection conn = null;
  502.                         java.sql.PreparedStatement pst = null;
  503.                         conn = DriverManager.getConnection(url, user, password);
  504.                         if (conn != null) System.out.println("Connected");
  505.                         String sql = "INSERT INTO generator_postaci_rpg1.typ_części_ciała (Nazwa_TCC) VALUES(?)";
  506.                         pst = conn.prepareStatement(sql);
  507.  
  508.                         pst.setString(1, nazwa_tcc);
  509.  
  510.                         pst.executeUpdate();
  511.  
  512.                 } catch (ClassNotFoundException e) {
  513.                         System.out.println("Driver problem");
  514.                 } catch (SQLException e) {
  515.                         System.out.println(e);
  516.                 }
  517.         }
  518.  
  519.         public void dodajTypZbroi(String nazwa_tzb, int id_zb)
  520.         {
  521.                 try {
  522.                         Class.forName("com.mysql.jdbc.Driver");
  523.                         Connection conn = null;
  524.                         java.sql.PreparedStatement pst = null;
  525.                         conn = DriverManager.getConnection(url, user, password);
  526.                         if (conn != null) System.out.println("Connected");
  527.                         String sql = "INSERT INTO generator_postaci_rpg1.typ_zbroi (Nazwa_TZB,ID_ZB) VALUES(?,?)";
  528.                         pst = conn.prepareStatement(sql);
  529.  
  530.                         pst.setString(1, nazwa_tzb);
  531.                         pst.setInt(2, id_zb);
  532.  
  533.                         pst.executeUpdate();
  534.  
  535.                 } catch (ClassNotFoundException e) {
  536.                         System.out.println("Driver problem");
  537.                 } catch (SQLException e) {
  538.                         System.out.println(e);
  539.                 }
  540.         }
  541.  
  542.  
  543.         public void dodajUmiejetnosciKlasy(int id_umiejetnosci, int id_klasy)
  544.         {
  545.                 try {
  546.                         Class.forName("com.mysql.jdbc.Driver");
  547.                         Connection conn = null;
  548.                         java.sql.PreparedStatement pst = null;
  549.                         conn = DriverManager.getConnection(url, user, password);
  550.                         if (conn != null) System.out.println("Connected");
  551.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_klasy (ID_U,ID_KL) VALUES(?,?)";
  552.                         pst = conn.prepareStatement(sql);
  553.  
  554.                         pst.setInt(1, id_umiejetnosci);
  555.                         pst.setInt(2, id_klasy);
  556.  
  557.                         pst.executeUpdate();
  558.  
  559.                 } catch (ClassNotFoundException e) {
  560.                         System.out.println("Driver problem");
  561.                 } catch (SQLException e) {
  562.                         System.out.println(e);
  563.                 }
  564.         }
  565.  
  566.         public void dodajUmiejetnosciPostaci(int id_postaci, int id_umiejetnosci)
  567.         {
  568.                 try {
  569.                         Class.forName("com.mysql.jdbc.Driver");
  570.                         Connection conn = null;
  571.                         java.sql.PreparedStatement pst = null;
  572.                         conn = DriverManager.getConnection(url, user, password);
  573.                         if (conn != null) System.out.println("Connected");
  574.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_postaci (ID_P,ID_U) VALUES(?,?)";
  575.                         pst = conn.prepareStatement(sql);
  576.  
  577.                         pst.setInt(1, id_postaci);
  578.                         pst.setInt(2, id_umiejetnosci);
  579.  
  580.                         pst.executeUpdate();
  581.  
  582.                 } catch (ClassNotFoundException e) {
  583.                         System.out.println("Driver problem");
  584.                 } catch (SQLException e) {
  585.                         System.out.println(e);
  586.                 }
  587.         }
  588.  
  589.         public void dodajUmiejetnosciRas(int id_rasy, int id_umiejetnosci)
  590.         {
  591.                 try {
  592.                         Class.forName("com.mysql.jdbc.Driver");
  593.                         Connection conn = null;
  594.                         java.sql.PreparedStatement pst = null;
  595.                         conn = DriverManager.getConnection(url, user, password);
  596.                         if (conn != null) System.out.println("Connected");
  597.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_ras (ID_RS,ID_U) VALUES(?,?)";
  598.                         pst = conn.prepareStatement(sql);
  599.  
  600.                         pst.setInt(1, id_rasy);
  601.                         pst.setInt(2, id_umiejetnosci);
  602.  
  603.                         pst.executeUpdate();
  604.  
  605.                 } catch (ClassNotFoundException e) {
  606.                         System.out.println("Driver problem");
  607.                 } catch (SQLException e) {
  608.                         System.out.println(e);
  609.                 }
  610.         }
  611.  
  612.         public void dodajUmiejetnosci(String nazwa_um, int wym_poz, String opis)
  613.         {
  614.                 try {
  615.                         Class.forName("com.mysql.jdbc.Driver");
  616.                         Connection conn = null;
  617.                         java.sql.PreparedStatement pst = null;
  618.                         conn = DriverManager.getConnection(url, user, password);
  619.                         if (conn != null) System.out.println("Connected");
  620.                         String sql = "INSERT INTO generator_postaci_rpg1.umiejętność (Nazwa_U,Wymagany_poziom_U,Opis_U) VALUES(?,?,?)";
  621.                         pst = conn.prepareStatement(sql);
  622.  
  623.                         pst.setString(1, nazwa_um);
  624.                         pst.setInt(2, wym_poz);
  625.                         pst.setString(3, opis);
  626.  
  627.                         pst.executeUpdate();
  628.  
  629.                 } catch (ClassNotFoundException e) {
  630.                         System.out.println("Driver problem");
  631.                 } catch (SQLException e) {
  632.                         System.out.println(e);
  633.                 }
  634.         }
  635.  
  636.         public void dodajZbroje(String nazwa_zbroi, int rzadkosc, int klasa, int wytrzymalosc, int id_cc)
  637.         {
  638.                 try {
  639.                         Class.forName("com.mysql.jdbc.Driver");
  640.                         Connection conn = null;
  641.                         java.sql.PreparedStatement pst = null;
  642.                         conn = DriverManager.getConnection(url, user, password);
  643.                         if (conn != null) System.out.println("Connected");
  644.                         String sql = "INSERT INTO generator_postaci_rpg1.zbroja (Nazwa_ZB,Rzadkość_ZB,Klasa_Pancerza_ZB,Wytrzymałość_ZB,ID_CC) VALUES(?,?,?,?,?)";
  645.                         pst = conn.prepareStatement(sql);
  646.  
  647.                         pst.setString(1, nazwa_zbroi);
  648.                         pst.setInt(2, rzadkosc);
  649.                         pst.setInt(3, klasa);
  650.                         pst.setInt(4, wytrzymalosc);
  651.                         pst.setInt(5, id_cc);
  652.  
  653.                         pst.executeUpdate();
  654.  
  655.                 } catch (ClassNotFoundException e) {
  656.                         System.out.println("Driver problem");
  657.                 } catch (SQLException e) {
  658.                         System.out.println(e);
  659.                 }
  660.         }
  661.  
  662.  
  663.         public void dodajZwojDoInwentarza(int id_inwentarza, int id_zwoju)
  664.         {
  665.                 try {
  666.                         Class.forName("com.mysql.jdbc.Driver");
  667.                         Connection conn = null;
  668.                         java.sql.PreparedStatement pst = null;
  669.                         conn = DriverManager.getConnection(url, user, password);
  670.                         if (conn != null) System.out.println("Connected");
  671.                         String sql = "INSERT INTO generator_postaci_rpg1.zwoje_w_inwentarzu (ID_I,ID_ZWOJ) VALUES(?,?)";
  672.                         pst = conn.prepareStatement(sql);
  673.  
  674.                         pst.setInt(1, id_inwentarza);
  675.                         pst.setInt(2, id_zwoju);
  676.  
  677.                         pst.executeUpdate();
  678.  
  679.                 } catch (ClassNotFoundException e) {
  680.                         System.out.println("Driver problem");
  681.                 } catch (SQLException e) {
  682.                         System.out.println(e);
  683.                 }
  684.         }
  685.  
  686.  
  687.         public void dodajZwoje(String nazwa_zwoju, String opis, int czas_dzialania)
  688.         {
  689.                 try {
  690.                         Class.forName("com.mysql.jdbc.Driver");
  691.                         Connection conn = null;
  692.                         java.sql.PreparedStatement pst = null;
  693.                         conn = DriverManager.getConnection(url, user, password);
  694.                         if (conn != null) System.out.println("Connected");
  695.                         String sql = "INSERT INTO generator_postaci_rpg1.zwój (Nazwa_ZWOJ,Opis_działania_ZWOJ,Czas_dzialania_ZWOJ) VALUES(?,?,?)";
  696.                         pst = conn.prepareStatement(sql);
  697.  
  698.                         pst.setString(1, nazwa_zwoju);
  699.                         pst.setString(2,opis);
  700.                         pst.setInt(3,czas_dzialania);
  701.  
  702.                         pst.executeUpdate();
  703.  
  704.                 } catch (ClassNotFoundException e) {
  705.                         System.out.println("Driver problem");
  706.                 } catch (SQLException e) {
  707.                         System.out.println(e);
  708.                 }
  709.         }
  710.  
  711. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement