Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package MetodaSzablonowa;
  7. import java.sql.Connection;
  8. import java.sql.DriverManager;
  9. import java.sql.ResultSet;
  10. import java.sql.Statement;
  11. import java.util.Random;
  12. import javaapplication4.MyServerForm;
  13. import static javaapplication4.MyServerForm.send;
  14. /**
  15. *
  16. * @author Kamil
  17. */
  18.  
  19. public class Emerytura extends Umowa{
  20. String login = javaapplication4.MyServerForm.login_baza;
  21. String haslo = javaapplication4.MyServerForm.haslo_baza;
  22. @Override
  23. protected void collectSource() {
  24.  
  25. try{
  26. Class.forName("oracle.jdbc.OracleDriver");
  27. Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",login,haslo);
  28.  
  29. Statement st = con.createStatement();
  30. String Id = "'43060070090"; //to jest pesel i mi go przesylasz
  31.  
  32.  
  33. String sql3 = ("select max(id) from dane_osobowe"); //
  34. //int foo = Integer.parseInt(sql3);
  35. String sqlmax = sql3 +1;
  36. System.out.println(sqlmax);
  37. Random rand = new Random();
  38. int n = rand.nextInt(100) + 1;
  39. String dane_osobid= ("select Id from dane_osobowe WHERE pesel= "+Id);
  40. Integer.parseInt(dane_osobid);
  41. // teraz robimy konto id - trzeba oddzielic to
  42. int uslugaid = 1; //tu jest opcja emerytura wiec to jest stale
  43. int wyplacanakwota = rand.nextInt(10000) + 1;
  44. //INSERT INTO umowa (Id,dane_osobowe_id,konto_id,uslugi_id,wyplacana_kwota,ilosc_wyplat,data_podpisania,data_konca) VALUES ('6','61','1','4','57248','76','22-05-12','11-09-14');
  45.  
  46.  
  47. //String sql = "INSERT INTO umowa (Id,dane_osobowe_id,konto_id,uslugi_id,wyplacana_kwota,ilosc_wyplat,data_podpisania,data_konca) VALUES('103','2','3','4','5','6','22-05-12','11-09-14')";
  48. String sql = "INSERT INTO umowa (Id,dane_osobowe_id,konto_id,uslugi_id,wyplacana_kwota,ilosc_wyplat,data_podpisania,data_konca) VALUES('"sql3"','"+dane_osobid+"',"+n+","+uslugaid+","+wyplacanakwota+","+n+",'22-05-12','11-09-14')";
  49.  
  50. ResultSet rs = st.executeQuery(sql);
  51.  
  52. while(rs.next()){
  53. // send(IP,"U-"+rs.getInt(1)+ "-"+rs.getString(2));
  54. // Thread.sleep(100);
  55. System.out.println(rs.getInt(1)+rs.getInt(2)+rs.getInt(3)+rs.getInt(4)+rs.getInt(5)+rs.getInt(6)+rs.getInt(7)+rs.getInt(8));
  56.  
  57.  
  58. }
  59. con.close();
  60.  
  61. } catch(Exception e){
  62. System.out.println(e);
  63. }
  64. }
  65.  
  66. @Override
  67. protected void compileToTarget() {
  68. System.out.println("Emerytura");
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement