Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- textField_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try{
- Object selected = list_1.getSelectedValue();
- Connection conn = null;
- conn=DriverManager.getConnection("jdbc:mysql://localhost/flyer","root","000");
- Statement st= conn.createStatement();
- String query = "INSERT INTO flyer_item (discount) SELECT price*? FROM `item` where item_name='?' ";
- // PreparedStatement ps = null;
- int i = Integer.valueOf((textField_1.getText()));
- i=i/100;
- java.sql.PreparedStatement ps = conn.prepareStatement(query);
- ps.setInt(1,i);
- ps.setString(2, selected.toString());
- ps.executeUpdate();
- st.executeUpdate(query);
- } catch (SQLException se){
- System.out.println(se.getMessage());
- }
- } } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement