public boolean simpan(){
        boolean adaKesalahan = false;
        java.sql.Connection cn = null; 
        
        try{ 
            Class.forName(Koneksi.driver); 
        } catch (Exception ex){ 
            adaKesalahan = true; 
            JOptionPane.showMessageDialog(null,"JDBC Driver tidak ditemukan atau rusak\n"+ex,"Kesalahan",JOptionPane.ERROR_MESSAGE);  
        } 
        
        if (!adaKesalahan){ 
            try { 
                cn = DriverManager.getConnection(Koneksi.database+"?user="+Koneksi.user+"&password="+Koneksi.password+""); 
            } catch (Exception ex) { 
                adaKesalahan = true;  
                JOptionPane.showMessageDialog(null,"Koneksi ke "+Koneksi.database+" gagal\n"+ex,"Kesalahan",JOptionPane.ERROR_MESSAGE); 
            } 
            
            if (!adaKesalahan){ 
                int jumlahSimpan=0; 
                boolean simpan = false; 
                
                try { 
                    String SQLStatemen = "select * from pembeli where no_beli='"+no_beli+"'"; 
                    java.sql.Statement sta = cn.createStatement();
                    ResultSet rset = sta.executeQuery(SQLStatemen);
                    
                    rset.next(); 
                    if (rset.getRow()>0){
                        sta.close();
                        rset.close(); 
                        Object[] arrOpsi = {"Ya","Tidak"}; 
                        int pilih=JOptionPane.showOptionDialog(null,"No Pembeli sudah ada\nApakah data diupdate?","Konfirmasi",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE, null,arrOpsi,arrOpsi[0]); 
                        if (pilih==0){ 
                            simpan = true; 
                            SQLStatemen = "update pembeli set nama='"+nama+"', alamat='"+alamat+"', tlp='"+tlp+ "' where no_beli='"+no_beli+"'"; 
                            sta = cn.createStatement();
                            jumlahSimpan = sta.executeUpdate(SQLStatemen); 
                        }
                    } else {
                        sta.close();
                        rset.close(); 

                        simpan = true;
                        SQLStatemen = "insert into pembeli(no_beli, nama, alamat, tlp) values ('"+ no_beli +"','"+ nama +"','"+ alamat +"','"+ tlp +"')"; 
                        sta = cn.createStatement(); 
                        jumlahSimpan = sta.executeUpdate(SQLStatemen); 
                    }
                    
                    if (simpan) {
                        if (jumlahSimpan > 0){
                            JOptionPane.showMessageDialog(null,"Data Pembeli sudah tersimpan","Informasi",JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            adaKesalahan = true; 
                            JOptionPane.showMessageDialog(null,"Gagal menyimpan data pembeli","Kesalahan",JOptionPane.ERROR_MESSAGE); 
                        } 
                    }
                } catch (Exception ex){
                    adaKesalahan = true; 
                    JOptionPane.showMessageDialog(null,"Tidak dapat membuka tabel pembeli\n"+ex,"Kesalahan",JOptionPane.ERROR_MESSAGE);
                }
            }
        }
        return !adaKesalahan;
    }