Miletone

Rp0 / Rp1.000.000

Sunday, September 29, 2019

[JAVA] How to Edit Database on Button

Action Performed :
try
                {
                    Connection connect = Connect.getConnect();
                    //Statement stm=connect.createStatement();
                    String sql="update other set coder ='?', a='?', b='?', c='?', d='?', e='?', f='?' where coder ='?'";
                     PreparedStatement prepare = (PreparedStatement) connect.prepareStatement(sql);
        prepare.setString(1, jTextField1.getText());
        prepare.setString(2, jTextField2.getText());
        prepare.setString(3, jTextField3.getText());
        prepare.setString(4, jTextField5.getText());
        prepare.setString(5, jTextField4.getText());
        prepare.setString(6, jTextField4.getText());
        prepare.setString(7, jTextArea1.getText());
        prepare.executeUpdate();
                    JOptionPane.showMessageDialog(null,"Success");
                    //reset();
                    //table();
                }
                catch(Exception ex)
                {
                    JOptionPane.showMessageDialog(null,"Error :"+ex);
                }

No comments: