Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. textField_1.addActionListener(new ActionListener() {
  2. public void actionPerformed(ActionEvent e) {
  3.  
  4. try{
  5. Object selected = list_1.getSelectedValue();
  6. Connection conn = null;
  7. conn=DriverManager.getConnection("jdbc:mysql://localhost/flyer","root","000");
  8. Statement st= conn.createStatement();
  9.  
  10. String query = "INSERT INTO flyer_item (discount) SELECT price*? FROM `item` where item_name='?' ";
  11.  
  12. // PreparedStatement ps = null;
  13.  
  14. int i = Integer.valueOf((textField_1.getText()));
  15. i=i/100;
  16. java.sql.PreparedStatement ps = conn.prepareStatement(query);
  17. ps.setInt(1,i);
  18. ps.setString(2, selected.toString());
  19. ps.executeUpdate();
  20. st.executeUpdate(query);
  21.  
  22.  
  23.  
  24. } catch (SQLException se){
  25. System.out.println(se.getMessage());
  26.  
  27. }
  28.  
  29. } } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement