Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.10 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. public void dodajBron(String nazwa_broni, int rzadkość, int atak, int szybkość_ataku, int wytrzymałość)
  63. {
  64. try {
  65. Class.forName("com.mysql.jdbc.Driver");
  66. Connection conn = null;
  67. java.sql.PreparedStatement pst = null;
  68. conn = DriverManager.getConnection(url, user, password);
  69. if (conn != null) System.out.println("Connected");
  70. String sql = "INSERT INTO generator_postaci_rpg1.broń (Nazwa_B,Rzadkość_B,Atak_B,Szybkość_ataku_B," +
  71. "Wytrzymałość_B) VALUES(?,?,?,?,?)";
  72. pst = conn.prepareStatement(sql);
  73.  
  74.  
  75. pst.setString(1, nazwa_broni );
  76. pst.setInt(2,rzadkość);
  77. pst.setInt(3,atak );
  78. pst.setInt(4,szybkość_ataku );
  79. pst.setInt(5, wytrzymałość);
  80.  
  81. pst.executeUpdate();
  82.  
  83. } catch (ClassNotFoundException e) {
  84. System.out.println("Driver problem");
  85. } catch (SQLException e) {
  86. System.out.println(e);
  87. }
  88. }
  89.  
  90. public void dodajCharakter(String moralnosc, String personalnosc)
  91. {
  92. try {
  93. Class.forName("com.mysql.jdbc.Driver");
  94. Connection conn = null;
  95. java.sql.PreparedStatement pst = null;
  96. conn = DriverManager.getConnection(url, user, password);
  97. if (conn != null) System.out.println("Connected");
  98. String sql = "INSERT INTO generator_postaci_rpg1.charakter (Moralność_CHAR, Personalność_CHAR) VALUES(?,?)";
  99. pst = conn.prepareStatement(sql);
  100.  
  101.  
  102. pst.setString(1, moralnosc );
  103. pst.setString(2, personalnosc );
  104.  
  105. pst.executeUpdate();
  106.  
  107. } catch (ClassNotFoundException e) {
  108. System.out.println("Driver problem");
  109. } catch (SQLException e) {
  110. System.out.println(e);
  111. }
  112. }
  113.  
  114. public void dodajCzar(String nazwa, int wymagany_poziom, int wymagany_poziom_klasy, int kosztHP, int kosztMP, int ranga)
  115. {
  116. try {
  117. Class.forName("com.mysql.jdbc.Driver");
  118. Connection conn = null;
  119. java.sql.PreparedStatement pst = null;
  120. conn = DriverManager.getConnection(url, user, password);
  121. if (conn != null) System.out.println("Connected");
  122. String sql = "INSERT INTO generator_postaci_rpg1.czar (Nazwa_CZ, Wymagany_poziom_CZ, Wymagany_poziom_klasy_CZ," +
  123. "Koszt_many_CZ, Koszt_życia_CZ, Ranga_CZ) VALUES(?,?,?,?,?,?)";
  124. pst = conn.prepareStatement(sql);
  125.  
  126.  
  127. pst.setString(1, nazwa );
  128. pst.setInt(2, wymagany_poziom );
  129. pst.setInt(3, wymagany_poziom_klasy);
  130. pst.setInt(4, kosztMP );
  131. pst.setInt(5, kosztHP);
  132. pst.setInt(6, ranga );
  133.  
  134. pst.executeUpdate();
  135.  
  136. } catch (ClassNotFoundException e) {
  137. System.out.println("Driver problem");
  138. } catch (SQLException e) {
  139. System.out.println(e);
  140. }
  141. }
  142.  
  143. public void dodajCzescCiala(String nazwa, int HP)
  144. {
  145. try {
  146. Class.forName("com.mysql.jdbc.Driver");
  147. Connection conn = null;
  148. java.sql.PreparedStatement pst = null;
  149. conn = DriverManager.getConnection(url, user, password);
  150. if (conn != null) System.out.println("Connected");
  151. String sql = "INSERT INTO generator_postaci_rpg1.część_ciała (Nazwa_CC, Punkty_Życia_CC) VALUES(?,?)";
  152. pst = conn.prepareStatement(sql);
  153.  
  154.  
  155. pst.setString(1, nazwa);
  156. pst.setInt(2, HP );
  157.  
  158. pst.executeUpdate();
  159.  
  160. } catch (ClassNotFoundException e) {
  161. System.out.println("Driver problem");
  162. } catch (SQLException e) {
  163. System.out.println(e);
  164. }
  165. }
  166.  
  167. public void dodajKlase(String nazwa, int poziom_klasy)
  168. {
  169. try {
  170. Class.forName("com.mysql.jdbc.Driver");
  171. Connection conn = null;
  172. java.sql.PreparedStatement pst = null;
  173. conn = DriverManager.getConnection(url, user, password);
  174. if (conn != null) System.out.println("Connected");
  175. String sql = "INSERT INTO generator_postaci_rpg1.klasa (Nazwa_KL, Poziom_KL) VALUES(?,?)";
  176. pst = conn.prepareStatement(sql);
  177.  
  178.  
  179. pst.setString(1, nazwa);
  180. pst.setInt(2, poziom_klasy );
  181.  
  182. pst.executeUpdate();
  183.  
  184. } catch (ClassNotFoundException e) {
  185. System.out.println("Driver problem");
  186. } catch (SQLException e) {
  187. System.out.println(e);
  188. }
  189. }
  190.  
  191. public void dodajMajatek(String nazwa, String rodzaj_majatku, int wartosc)
  192. {
  193. try {
  194. Class.forName("com.mysql.jdbc.Driver");
  195. Connection conn = null;
  196. java.sql.PreparedStatement pst = null;
  197. conn = DriverManager.getConnection(url, user, password);
  198. if (conn != null) System.out.println("Connected");
  199. String sql = "INSERT INTO generator_postaci_rpg1.majatek (Nazwa_MJ, Rodzaj_majątku_MJ, Wartość_MJ) VALUES(?,?)";
  200. pst = conn.prepareStatement(sql);
  201.  
  202.  
  203. pst.setString(1, nazwa);
  204. pst.setString(2, rodzaj_majatku);
  205. pst.setInt(3, wartosc );
  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 dodajMiksture(String nazwa, int pojemnosc, int czasdziałania)
  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.mikstura (Nazwa_MIKS, Pojemność_MIKS, Czas_działania_MIKS) VALUES(?,?)";
  225. pst = conn.prepareStatement(sql);
  226.  
  227.  
  228. pst.setString(1, nazwa);
  229. pst.setInt(2, pojemnosc);
  230. pst.setInt(3, czasdziałania );
  231.  
  232. pst.executeUpdate();
  233.  
  234. } catch (ClassNotFoundException e) {
  235. System.out.println("Driver problem");
  236. } catch (SQLException e) {
  237. System.out.println(e);
  238. }
  239. }
  240.  
  241. public void dodajZwoje(String nazwa_zwoju, String opis, int czas_dzialania)
  242. {
  243. try {
  244. Class.forName("com.mysql.jdbc.Driver");
  245. Connection conn = null;
  246. java.sql.PreparedStatement pst = null;
  247. conn = DriverManager.getConnection(url, user, password);
  248. if (conn != null) System.out.println("Connected");
  249. String sql = "INSERT INTO generator_postaci_rpg1.zwój (Nazwa_ZWOJ,Opis_działania_ZWOJ,Czas_dzialania_ZWOJ) VALUES(?,?,?)";
  250. pst = conn.prepareStatement(sql);
  251.  
  252. pst.setString(1, nazwa_zwoju);
  253. pst.setString(2,opis);
  254. pst.setInt(3,czas_dzialania);
  255.  
  256. pst.executeUpdate();
  257.  
  258. } catch (ClassNotFoundException e) {
  259. System.out.println("Driver problem");
  260. } catch (SQLException e) {
  261. System.out.println(e);
  262. }
  263. }
  264.  
  265. public void dodajZbroje(String nazwa_zbroi, int rzadkosc, int klasa, int wytrzymalosc, int id_cc)
  266. {
  267. try {
  268. Class.forName("com.mysql.jdbc.Driver");
  269. Connection conn = null;
  270. java.sql.PreparedStatement pst = null;
  271. conn = DriverManager.getConnection(url, user, password);
  272. if (conn != null) System.out.println("Connected");
  273. String sql = "INSERT INTO generator_postaci_rpg1.zbroja (Nazwa_ZB,Rzadkość_ZB,Klasa_Pancerza_ZB,Wytrzymałość_ZB,ID_CC) VALUES(?,?,?,?,?)";
  274. pst = conn.prepareStatement(sql);
  275.  
  276. pst.setString(1, nazwa_zbroi);
  277. pst.setInt(2, rzadkosc);
  278. pst.setInt(3, klasa);
  279. pst.setInt(4, wytrzymalosc);
  280. pst.setInt(5, id_cc);
  281.  
  282. pst.executeUpdate();
  283.  
  284. } catch (ClassNotFoundException e) {
  285. System.out.println("Driver problem");
  286. } catch (SQLException e) {
  287. System.out.println(e);
  288. }
  289. }
  290.  
  291. public void dodajUmiejetnosci(String nazwa_um, int wym_poz, String opis)
  292. {
  293. try {
  294. Class.forName("com.mysql.jdbc.Driver");
  295. Connection conn = null;
  296. java.sql.PreparedStatement pst = null;
  297. conn = DriverManager.getConnection(url, user, password);
  298. if (conn != null) System.out.println("Connected");
  299. String sql = "INSERT INTO generator_postaci_rpg1.umiejętność (Nazwa_U,Wymagany_poziom_U,Opis_U) VALUES(?,?,?)";
  300. pst = conn.prepareStatement(sql);
  301.  
  302. pst.setString(1, nazwa_um);
  303. pst.setInt(2, wym_poz);
  304. pst.setString(3, opis);
  305.  
  306. pst.executeUpdate();
  307.  
  308. } catch (ClassNotFoundException e) {
  309. System.out.println("Driver problem");
  310. } catch (SQLException e) {
  311. System.out.println(e);
  312. }
  313. }
  314.  
  315. public void dodajTypZbroi(String nazwa_tzb, int id_zb)
  316. {
  317. try {
  318. Class.forName("com.mysql.jdbc.Driver");
  319. Connection conn = null;
  320. java.sql.PreparedStatement pst = null;
  321. conn = DriverManager.getConnection(url, user, password);
  322. if (conn != null) System.out.println("Connected");
  323. String sql = "INSERT INTO generator_postaci_rpg1.typ_zbroi (Nazwa_TZB,ID_ZB) VALUES(?,?)";
  324. pst = conn.prepareStatement(sql);
  325.  
  326. pst.setString(1, nazwa_tzb);
  327. pst.setInt(2, id_zb);
  328.  
  329. pst.executeUpdate();
  330.  
  331. } catch (ClassNotFoundException e) {
  332. System.out.println("Driver problem");
  333. } catch (SQLException e) {
  334. System.out.println(e);
  335. }
  336. }
  337.  
  338. public void dodajTypCzesciCiala(String nazwa_tcc)
  339. {
  340. try {
  341. Class.forName("com.mysql.jdbc.Driver");
  342. Connection conn = null;
  343. java.sql.PreparedStatement pst = null;
  344. conn = DriverManager.getConnection(url, user, password);
  345. if (conn != null) System.out.println("Connected");
  346. String sql = "INSERT INTO generator_postaci_rpg1.typ_części_ciała (Nazwa_TCC) VALUES(?)";
  347. pst = conn.prepareStatement(sql);
  348.  
  349. pst.setString(1, nazwa_tcc);
  350.  
  351. pst.executeUpdate();
  352.  
  353. } catch (ClassNotFoundException e) {
  354. System.out.println("Driver problem");
  355. } catch (SQLException e) {
  356. System.out.println(e);
  357. }
  358. }
  359.  
  360. public void dodajTypBroni(String nazwa_tb, int id_b)
  361. {
  362. try {
  363. Class.forName("com.mysql.jdbc.Driver");
  364. Connection conn = null;
  365. java.sql.PreparedStatement pst = null;
  366. conn = DriverManager.getConnection(url, user, password);
  367. if (conn != null) System.out.println("Connected");
  368. String sql = "INSERT INTO generator_postaci_rpg1.typ_broni (Nazwa_TB,ID_B) VALUES(?,?)";
  369. pst = conn.prepareStatement(sql);
  370.  
  371. pst.setString(1, nazwa_tb);
  372. pst.setInt(1, id_b);
  373.  
  374. pst.executeUpdate();
  375.  
  376. } catch (ClassNotFoundException e) {
  377. System.out.println("Driver problem");
  378. } catch (SQLException e) {
  379. System.out.println(e);
  380. }
  381. }
  382.  
  383. public void dodajRase(String nazwa_rasy)
  384. {
  385. try {
  386. Class.forName("com.mysql.jdbc.Driver");
  387. Connection conn = null;
  388. java.sql.PreparedStatement pst = null;
  389. conn = DriverManager.getConnection(url, user, password);
  390. if (conn != null) System.out.println("Connected");
  391. String sql = "INSERT INTO generator_postaci_rpg1.rasa (Nazwa_RS) VALUES(?)";
  392. pst = conn.prepareStatement(sql);
  393.  
  394. pst.setString(1, nazwa_rasy);
  395.  
  396. pst.executeUpdate();
  397.  
  398. } catch (ClassNotFoundException e) {
  399. System.out.println("Driver problem");
  400. } catch (SQLException e) {
  401. System.out.println(e);
  402. }
  403. }
  404.  
  405. public void dodajAtutKlasy(int id_atutu, int id_klasy)
  406. {
  407. try {
  408. Class.forName("com.mysql.jdbc.Driver");
  409. Connection conn = null;
  410. java.sql.PreparedStatement pst = null;
  411. conn = DriverManager.getConnection(url, user, password);
  412. if (conn != null) System.out.println("Connected");
  413. String sql = "INSERT INTO generator_postaci_rpg1.atuty_klasy (ID_AT,ID_KL) VALUES(?,?)";
  414. pst = conn.prepareStatement(sql);
  415.  
  416. pst.setInt(1, id_atutu);
  417. pst.setInt(1, id_klasy);
  418.  
  419. pst.executeUpdate();
  420.  
  421. } catch (ClassNotFoundException e) {
  422. System.out.println("Driver problem");
  423. } catch (SQLException e) {
  424. System.out.println(e);
  425. }
  426. }
  427.  
  428. public void dodajAtutPostaci(int id_postaci, int id_atutu)
  429. {
  430. try {
  431. Class.forName("com.mysql.jdbc.Driver");
  432. Connection conn = null;
  433. java.sql.PreparedStatement pst = null;
  434. conn = DriverManager.getConnection(url, user, password);
  435. if (conn != null) System.out.println("Connected");
  436. String sql = "INSERT INTO generator_postaci_rpg1.atuty_postaci (ID_P,ID_AT) VALUES(?,?)";
  437. pst = conn.prepareStatement(sql);
  438.  
  439. pst.setInt(1, id_postaci);
  440. pst.setInt(1, id_atutu);
  441.  
  442. pst.executeUpdate();
  443.  
  444. } catch (ClassNotFoundException e) {
  445. System.out.println("Driver problem");
  446. } catch (SQLException e) {
  447. System.out.println(e);
  448. }
  449. }
  450.  
  451. public void dodajCzarKlasy(int id_klasy, int id_czaru)
  452. {
  453. try {
  454. Class.forName("com.mysql.jdbc.Driver");
  455. Connection conn = null;
  456. java.sql.PreparedStatement pst = null;
  457. conn = DriverManager.getConnection(url, user, password);
  458. if (conn != null) System.out.println("Connected");
  459. String sql = "INSERT INTO generator_postaci_rpg1.czary_klasy (ID_KL,ID_CZ) VALUES(?,?)";
  460. pst = conn.prepareStatement(sql);
  461.  
  462. pst.setInt(1, id_klasy);
  463. pst.setInt(1, id_czaru);
  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 dodajInwentarz()
  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.inwentarz () VALUES()";
  483. pst = conn.prepareStatement(sql);
  484.  
  485. pst.executeUpdate();
  486.  
  487. } catch (ClassNotFoundException e) {
  488. System.out.println("Driver problem");
  489. } catch (SQLException e) {
  490. System.out.println(e);
  491. }
  492. }
  493.  
  494. public void dodajKonfiguracjeBroni(int id_typu_broni, int id_typu_cz_ciala)
  495. {
  496. try {
  497. Class.forName("com.mysql.jdbc.Driver");
  498. Connection conn = null;
  499. java.sql.PreparedStatement pst = null;
  500. conn = DriverManager.getConnection(url, user, password);
  501. if (conn != null) System.out.println("Connected");
  502. String sql = "INSERT INTO generator_postaci_rpg1.konfiguracja_broni (ID_TB,ID_TCC) VALUES(?,?)";
  503. pst = conn.prepareStatement(sql);
  504.  
  505. pst.setInt(1, id_typu_broni);
  506. pst.setInt(1, id_typu_cz_ciala);
  507.  
  508. pst.executeUpdate();
  509.  
  510. } catch (ClassNotFoundException e) {
  511. System.out.println("Driver problem");
  512. } catch (SQLException e) {
  513. System.out.println(e);
  514. }
  515. }
  516.  
  517. public void dodajKonfiguracjeZbroi(int id_typu_zbroi, int id_typu_cz_ciala)
  518. {
  519. try {
  520. Class.forName("com.mysql.jdbc.Driver");
  521. Connection conn = null;
  522. java.sql.PreparedStatement pst = null;
  523. conn = DriverManager.getConnection(url, user, password);
  524. if (conn != null) System.out.println("Connected");
  525. String sql = "INSERT INTO generator_postaci_rpg1.konfiguracja_zbroi (ID_TZB,ID_TCC) VALUES(?,?)";
  526. pst = conn.prepareStatement(sql);
  527.  
  528. pst.setInt(1, id_typu_zbroi);
  529. pst.setInt(1, id_typu_cz_ciala);
  530.  
  531. pst.executeUpdate();
  532.  
  533. } catch (ClassNotFoundException e) {
  534. System.out.println("Driver problem");
  535. } catch (SQLException e) {
  536. System.out.println(e);
  537. }
  538. }
  539.  
  540. public void dodajMagicznyEkwipunekDoInwentarza(int id_inwentarza, int id_me)
  541. {
  542. try {
  543. Class.forName("com.mysql.jdbc.Driver");
  544. Connection conn = null;
  545. java.sql.PreparedStatement pst = null;
  546. conn = DriverManager.getConnection(url, user, password);
  547. if (conn != null) System.out.println("Connected");
  548. String sql = "INSERT INTO generator_postaci_rpg1.magiczny_ekwipunek_w_inwentarzu (ID_I,ID_ME) VALUES(?,?)";
  549. pst = conn.prepareStatement(sql);
  550.  
  551. pst.setInt(1, id_inwentarza);
  552. pst.setInt(1, id_me);
  553.  
  554. pst.executeUpdate();
  555.  
  556. } catch (ClassNotFoundException e) {
  557. System.out.println("Driver problem");
  558. } catch (SQLException e) {
  559. System.out.println(e);
  560. }
  561. }
  562.  
  563. public void dodajMajatekDoInwentarza(int id_inwentarza, int id_majatku)
  564. {
  565. try {
  566. Class.forName("com.mysql.jdbc.Driver");
  567. Connection conn = null;
  568. java.sql.PreparedStatement pst = null;
  569. conn = DriverManager.getConnection(url, user, password);
  570. if (conn != null) System.out.println("Connected");
  571. String sql = "INSERT INTO generator_postaci_rpg1.majątek_w_inwentarzu (ID_I,ID_MJ) VALUES(?,?)";
  572. pst = conn.prepareStatement(sql);
  573.  
  574. pst.setInt(1, id_inwentarza);
  575. pst.setInt(1, id_majatku);
  576.  
  577. pst.executeUpdate();
  578.  
  579. } catch (ClassNotFoundException e) {
  580. System.out.println("Driver problem");
  581. } catch (SQLException e) {
  582. System.out.println(e);
  583. }
  584. }
  585.  
  586. public void dodajMikstureDoInwentarza(int id_inwentarza, int id_mikstury)
  587. {
  588. try {
  589. Class.forName("com.mysql.jdbc.Driver");
  590. Connection conn = null;
  591. java.sql.PreparedStatement pst = null;
  592. conn = DriverManager.getConnection(url, user, password);
  593. if (conn != null) System.out.println("Connected");
  594. String sql = "INSERT INTO generator_postaci_rpg1.mikstury_w_inwentarzu (ID_I,ID_MIKS) VALUES(?,?)";
  595. pst = conn.prepareStatement(sql);
  596.  
  597. pst.setInt(1, id_inwentarza);
  598. pst.setInt(1, id_mikstury);
  599.  
  600. pst.executeUpdate();
  601.  
  602. } catch (ClassNotFoundException e) {
  603. System.out.println("Driver problem");
  604. } catch (SQLException e) {
  605. System.out.println(e);
  606. }
  607. }
  608.  
  609. public void dodajUmiejetnosciKlasy(int id_umiejetnosci, int id_klasy)
  610. {
  611. try {
  612. Class.forName("com.mysql.jdbc.Driver");
  613. Connection conn = null;
  614. java.sql.PreparedStatement pst = null;
  615. conn = DriverManager.getConnection(url, user, password);
  616. if (conn != null) System.out.println("Connected");
  617. String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_klasy (ID_U,ID_KL) VALUES(?,?)";
  618. pst = conn.prepareStatement(sql);
  619.  
  620. pst.setInt(1, id_umiejetnosci);
  621. pst.setInt(1, id_klasy);
  622.  
  623. pst.executeUpdate();
  624.  
  625. } catch (ClassNotFoundException e) {
  626. System.out.println("Driver problem");
  627. } catch (SQLException e) {
  628. System.out.println(e);
  629. }
  630. }
  631.  
  632. public void dodajUmiejetnosciPostaci(int id_postaci, int id_umiejetnosci)
  633. {
  634. try {
  635. Class.forName("com.mysql.jdbc.Driver");
  636. Connection conn = null;
  637. java.sql.PreparedStatement pst = null;
  638. conn = DriverManager.getConnection(url, user, password);
  639. if (conn != null) System.out.println("Connected");
  640. String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_postaci (ID_P,ID_U) VALUES(?,?)";
  641. pst = conn.prepareStatement(sql);
  642.  
  643. pst.setInt(1, id_postaci);
  644. pst.setInt(1, id_umiejetnosci);
  645.  
  646. pst.executeUpdate();
  647.  
  648. } catch (ClassNotFoundException e) {
  649. System.out.println("Driver problem");
  650. } catch (SQLException e) {
  651. System.out.println(e);
  652. }
  653. }
  654.  
  655. public void dodajUmiejetnosciRas(int id_rasy, int id_umiejetnosci)
  656. {
  657. try {
  658. Class.forName("com.mysql.jdbc.Driver");
  659. Connection conn = null;
  660. java.sql.PreparedStatement pst = null;
  661. conn = DriverManager.getConnection(url, user, password);
  662. if (conn != null) System.out.println("Connected");
  663. String sql = "INSERT INTO generator_postaci_rpg1.umiejętności_ras (ID_RS,ID_U) VALUES(?,?)";
  664. pst = conn.prepareStatement(sql);
  665.  
  666. pst.setInt(1, id_rasy);
  667. pst.setInt(1, id_umiejetnosci);
  668.  
  669. pst.executeUpdate();
  670.  
  671. } catch (ClassNotFoundException e) {
  672. System.out.println("Driver problem");
  673. } catch (SQLException e) {
  674. System.out.println(e);
  675. }
  676. }
  677.  
  678. public void dodajZwojDoInwentarza(int id_inwentarza, int id_zwoju)
  679. {
  680. try {
  681. Class.forName("com.mysql.jdbc.Driver");
  682. Connection conn = null;
  683. java.sql.PreparedStatement pst = null;
  684. conn = DriverManager.getConnection(url, user, password);
  685. if (conn != null) System.out.println("Connected");
  686. String sql = "INSERT INTO generator_postaci_rpg1.zwoje_w_inwentarzu (ID_I,ID_ZWOJ) VALUES(?,?)";
  687. pst = conn.prepareStatement(sql);
  688.  
  689. pst.setInt(1, id_inwentarza);
  690. pst.setInt(1, id_zwoju);
  691.  
  692. pst.executeUpdate();
  693.  
  694. } catch (ClassNotFoundException e) {
  695. System.out.println("Driver problem");
  696. } catch (SQLException e) {
  697. System.out.println(e);
  698. }
  699. }
  700.  
  701. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement