Advertisement
Guest User

Untitled

a guest
Dec 26th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3. import java.beans.Statement;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.ResultSet;
  7.  
  8. import javax.swing.Icon;
  9. import javax.swing.JButton;
  10. import javax.swing.JOptionPane;
  11.  
  12. public class Povezivanje {
  13.  
  14. private static final String ID = null;
  15.  
  16. public static void main(String[] args) {
  17. }
  18.  
  19. public Povezivanje(String Povezivanje){
  20. Connection con = null;
  21. Statement st = null;
  22. try{
  23. con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");
  24. st = (Statement) con.createStatement();
  25. ((java.sql.Statement) st).executeUpdate(Povezivanje);
  26. JOptionPane.showMessageDialog(null,"Upit je izvrsen");
  27. }catch(Exception ex){
  28. JOptionPane.showMessageDialog(null,ex.getMessage());
  29. }
  30.  
  31.  
  32. private JButton (String upis);{
  33.  
  34. JButton dugme = new JButton(upis);
  35.  
  36. dugme.addActionListener(new ActionListener() {
  37.  
  38. public void actionPerformed(ActionEvent e) {
  39. try{
  40. upis("insert into reklama (NAZIV_REKLAME, ID, TRAJANJE_REKLAME, DATUM_POCETKA, DATUM_KRAJA) values ('"+text2.getText()+"','"+id1.getText()+"',"+ text3.getText()+"','" + text4.getText()+ "','" + text5.getText()+")" );
  41. }
  42. catch(Exception ex){}
  43. }
  44. });
  45.  
  46. return dugme;
  47. }
  48.  
  49.  
  50. izbrisi(String izbrisi ); {
  51.  
  52. dugmeizbrisi.addActionListener(new ActionListener() {
  53.  
  54. public void actionPerformed(ActionEvent e) {
  55. try{
  56.  
  57. izbrisi("delete from reklame where id = "+ unos.getText());
  58.  
  59.  
  60. }
  61. catch(Exception ex){}
  62. }
  63.  
  64.  
  65. });
  66.  
  67. return izbrisi;
  68.  
  69.  
  70. public provjeri (String[] args) {
  71.  
  72.  
  73. try {
  74. String sql = " select naziv_reklame, ID from reklama";
  75. ResultSet rs = ((java.sql.Statement) st).executeQuery(sql);
  76. while (rs.next())
  77. System.out.println(
  78. "naziv reklame : " + rs.getString("Naziv_reklame") + ", ID: " + rs.getString("ID") );
  79.  
  80. String ID = rs.getString(ID);
  81.  
  82.  
  83.  
  84. } catch (Exception e) {
  85.  
  86.  
  87. System.out.println(e);
  88. }
  89. return ID;
  90. }
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. }
  107.  
  108. private void upis(Object object) {
  109. // TODO Auto-generated method stub
  110.  
  111. }
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement