Miletone

Rp0 / Rp1.000.000

Sunday, September 29, 2019

[JAVA] Bagaimana caranya menambahkan isi database pada GUI


Action Performed :
try{
                    Connection connect = Connect.getConnect();
        String sql = "insert into other values(?,?,?,?,?,?,?)";
        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,
                            "Data has been success");
        
        prepare.close();
        //reset();
        //table();
    }catch (Exception e)  {
                    JOptionPane.showMessageDialog(null, "Data cannot success !","Error !",JOptionPane.ERROR_MESSAGE);
                }

No comments: