Erro ao Inserir no BD: Inserindo 2 vezes

Olá, Pessoal! Estou precisando resolver a situação a seguir, agradeço desde já

Embora já tenha dados cadastrados para Permissão, quando eu insiro o tipo de acesso grava novamente em Permissão, ou seja, está salvando em acesso e salva de novo em permissão, estou sem entender o motivo

public class ModPermissao {

protected int id_perm;
protected String permi;

public int getId_perm() {
    return id_perm;}

public void setId_perm(int id_perm) {
    this.id_perm = id_perm;}

public String getPermi() {
    return permi; }

public void setPermi(String permi) {
    this.permi = permi;}

}

public class ControlPermi {

ConectBD conectperm = new ConectBD();

public void Inserirperm (ModPermissao modperm){
conectperm.conecta();
try{
PreparedStatement pst = conectperm.conn.prepareStatement(“insert into permissao (permi)values(?)”);
pst.setString(1,modperm.getPermi());
pst.execute();
JOptionPane.showMessageDialog(null, “Dados de Tipo de Permissao: “+modperm.getPermi()+”+ armazenados com sucesso!”);
}catch(SQLException ex){
JOptionPane.showMessageDialog(null, “Erro ao cadastrar Tipo de permissao:” + ex);
}
conectperm.desconecta();
}

public void Excluirperm (ModPermissao modperm){
    conectperm.conecta();
    try{
        PreparedStatement pst = conectperm.conn.prepareStatement("delete from permissao where id_perm=?");
        pst.setInt(1,modperm.getId_perm());
        pst.execute();
        JOptionPane.showMessageDialog(null, "Dados Tipo de permissao"+modperm.getPermi()+" deletados com sucesso!");
    }catch(SQLException ex){
        JOptionPane.showMessageDialog(null, "Erro ao deletar Tipo de permissao:" + ex);
    }
    conectperm.desconecta();
}

public void Alterarperm (ModPermissao modperm){
    conectperm.conecta();
    try{
        PreparedStatement pst = conectperm.conn.prepareStatement("update permissao set permi=? where id_perm=?");
        pst.setString(1,modperm.getPermi());
        pst.execute();
        JOptionPane.showMessageDialog(null, "Dados Tipo de permissao: "+modperm.getPermi()+" alterados com sucesso!");
    }catch(SQLException ex){
        JOptionPane.showMessageDialog(null, "Erro ao atualizar Tipo de permissao:" + ex);
    }
    conectperm.desconecta();
}

}

public class GerPerm extends javax.swing.JFrame {
ConectBD conPerm = new ConectBD();
ControlPermi clp = new ControlPermi();
ModPermissao modperm = new ModPermissao();

public GerPerm() {
    initComponents();
    conPerm.conecta();
    //preencherTabela("select * from permissao order by id_perm");
}

public void preencherTabela(String SQL){
    ArrayList dados = new ArrayList();
    String[] Colunas = new String[]{"Cod", "Permissao"};
    conPerm.executaSQL(SQL);
    try{
        conPerm.rs.first();
        do{
            dados.add(new Object[]{conPerm.rs.getInt("id_perm"),conPerm.rs.getString("permi")});
        }while(conPerm.rs.next());
        conPerm.desconecta();
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(rootPane, "Erro ao preencher a ArrayList!\n Erro:" + ex);
        conPerm.desconecta();
    } 
    
    ModeloTabela modtab = new ModeloTabela(dados, Colunas);
    
    jTCad.setModel(modtab);
    jTCad.getColumnModel().getColumn(0).setPreferredWidth(80);
    jTCad.getColumnModel().getColumn(0).setResizable(false);
    jTCad.getColumnModel().getColumn(1).setPreferredWidth(450);
    jTCad.getColumnModel().getColumn(1).setResizable(false);
    jTCad.getColumnModel().getColumn(2).setPreferredWidth(80);
    jTCad.getColumnModel().getColumn(2).setResizable(false);
    
    jTCad.getTableHeader().setReorderingAllowed(false);
    jTCad.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    jTCad.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //jTCadSec.setSelectionModel(ListSelectionModel.SINGLE_SELECTION);
}

public void salvar () {
    modperm.setPermi(jTFPermi.getText());
    clp.Inserirperm(modperm);
    //preencherTabela("select * from permissao order by id_permi");
    
    jTFCodPerm.setText("");
    jTFPermi.setText("");

    jTFPermi.setEnabled(true);

    jBAtu.setEnabled(false);
    jBDel.setEnabled(false);
    jBSalvar.setEnabled(false);
    jBNew.setEnabled(true);
}

public void deletar () {
    
    modperm.setId_perm(Integer.parseInt(jTFCodPerm.getText()));
    modperm.setPermi(jTFPermi.getText());

    clp.Excluirperm(modperm);
    //preencherTabela("select * from permissao order by id_permi");
    
    jTFCodPerm.setText("");
    jTFPermi.setText("");

    jTFPermi.setEnabled(false);

    jBAtu.setEnabled(false);
    jBDel.setEnabled(false);
    jBSalvar.setEnabled(false);
    jBNew.setEnabled(true);
}

  public void atualizar () {
    
    modperm.setId_perm(Integer.parseInt(jTFCodPerm.getText()));
    modperm.setPermi(jTFPermi.getText());
    
    clp.Alterarperm(modperm);
    //preencherTabela("select * from permissao order by id_permi");
    
    jTFCodPerm.setText("");
    jTFPermi.setText("");

    jTFPermi.setEnabled(false);

    jBAtu.setEnabled(false);
    jBDel.setEnabled(false);
    jBSalvar.setEnabled(false);
    jBNew.setEnabled(true);
}


                    
private void initComponents() {

    jLTitulo = new javax.swing.JLabel();
    jTFCodPerm = new javax.swing.JTextField();
    jLCod = new javax.swing.JLabel();
    jLPermi = new javax.swing.JLabel();
    jTFPermi = new javax.swing.JTextField();
    jBSair = new javax.swing.JButton();
    jBUlt = new javax.swing.JButton();
    jBProx = new javax.swing.JButton();
    jBAnt = new javax.swing.JButton();
    jBPri = new javax.swing.JButton();
    jBDel = new javax.swing.JButton();
    jBAtu = new javax.swing.JButton();
    jBSalvar = new javax.swing.JButton();
    jBNew = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTCad = new javax.swing.JTable();
    jLBG = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("GESTÃO DE PERMISSÕES");
    getContentPane().setLayout(null);

    jLTitulo.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
    jLTitulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLTitulo.setText("GESTÃO DE PERMISSÕES");
    getContentPane().add(jLTitulo);
    jLTitulo.setBounds(0, 20, 680, 40);

    jTFCodPerm.setEditable(false);
    jTFCodPerm.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTFCodPermActionPerformed(evt);
        }
    });
    getContentPane().add(jTFCodPerm);
    jTFCodPerm.setBounds(90, 100, 60, 30);

    jLCod.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLCod.setText("Código:");
    getContentPane().add(jLCod);
    jLCod.setBounds(30, 110, 60, 17);

    jLPermi.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLPermi.setText("Tipo de Permissao: ");
    getContentPane().add(jLPermi);
    jLPermi.setBounds(160, 110, 140, 17);
    getContentPane().add(jTFPermi);
    jTFPermi.setBounds(300, 100, 360, 30);

    jBSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/sair40x40.png"))); // NOI18N
    jBSair.setToolTipText("Sair");
    jBSair.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBSairActionPerformed(evt);
        }
    });
    getContentPane().add(jBSair);
    jBSair.setBounds(530, 150, 40, 50);

    jBUlt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/ultimo40x40.png"))); // NOI18N
    jBUlt.setToolTipText("Último");
    jBUlt.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBUltActionPerformed(evt);
        }
    });
    getContentPane().add(jBUlt);
    jBUlt.setBounds(480, 150, 40, 50);

    jBProx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/proximo40x40.png"))); // NOI18N
    jBProx.setToolTipText("Próximo");
    jBProx.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBProxActionPerformed(evt);
        }
    });
    getContentPane().add(jBProx);
    jBProx.setBounds(430, 150, 40, 50);

    jBAnt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/anterior40x40.png"))); // NOI18N
    jBAnt.setToolTipText("Anterior");
    jBAnt.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBAntActionPerformed(evt);
        }
    });
    getContentPane().add(jBAnt);
    jBAnt.setBounds(380, 150, 40, 50);

    jBPri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/primeiro40x40.png"))); // NOI18N
    jBPri.setToolTipText("Primeiro");
    jBPri.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBPriActionPerformed(evt);
        }
    });
    getContentPane().add(jBPri);
    jBPri.setBounds(330, 150, 40, 50);

    jBDel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/deletar40x40.png"))); // NOI18N
    jBDel.setToolTipText("Excluir");
    jBDel.setEnabled(false);
    jBDel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBDelActionPerformed(evt);
        }
    });
    getContentPane().add(jBDel);
    jBDel.setBounds(280, 150, 40, 50);

    jBAtu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/atualizar40x40.png"))); // NOI18N
    jBAtu.setToolTipText("Atualizar");
    jBAtu.setEnabled(false);
    jBAtu.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBAtuActionPerformed(evt);
        }
    });
    getContentPane().add(jBAtu);
    jBAtu.setBounds(230, 150, 40, 50);

    jBSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/salvar40x40.png"))); // NOI18N
    jBSalvar.setToolTipText("Salvar");
    jBSalvar.setEnabled(false);
    jBSalvar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBSalvarActionPerformed(evt);
        }
    });
    getContentPane().add(jBSalvar);
    jBSalvar.setBounds(180, 150, 40, 50);

    jBNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/novo40x40.png"))); // NOI18N
    jBNew.setToolTipText("Novo");
    jBNew.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBNewActionPerformed(evt);
        }
    });
    getContentPane().add(jBNew);
    jBNew.setBounds(130, 150, 40, 50);

    jTCad.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {},
            {},
            {},
            {}
        },
        new String [] {

        }
    ));
    jScrollPane1.setViewportView(jTCad);

    getContentPane().add(jScrollPane1);
    jScrollPane1.setBounds(30, 220, 630, 230);

    jLBG.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/BackgroundESQ.png"))); // NOI18N
    jLBG.setRequestFocusEnabled(false);
    getContentPane().add(jLBG);
    jLBG.setBounds(0, -60, 790, 680);

    setSize(new java.awt.Dimension(707, 511));
    setLocationRelativeTo(null);
}// </editor-fold>                        

private void jTFCodPermActionPerformed(java.awt.event.ActionEvent evt) {                                           
    // TODO add your handling code here:
}                                          

private void jBSairActionPerformed(java.awt.event.ActionEvent evt) {                                       
    dispose();
}                                      

private void jBUltActionPerformed(java.awt.event.ActionEvent evt) {                                      
    ult();
}                                     

private void jBProxActionPerformed(java.awt.event.ActionEvent evt) {                                       
    prox();
}                                      

private void jBAntActionPerformed(java.awt.event.ActionEvent evt) {                                      
    ant();
}                                     

private void jBPriActionPerformed(java.awt.event.ActionEvent evt) {                                      
    prim();
}                                     

private void jBDelActionPerformed(java.awt.event.ActionEvent evt) {                                      
    deletar();
}                                     

private void jBAtuActionPerformed(java.awt.event.ActionEvent evt) {                                      
    atualizar();
}                                     

private void jBSalvarActionPerformed(java.awt.event.ActionEvent evt) {                                         
    salvar();
}                                        

private void jBNewActionPerformed(java.awt.event.ActionEvent evt) {                                      

    jTFCodPerm.setText("");
    jTFPermi.setText("");

    jBAtu.setEnabled(true);
    jBDel.setEnabled(true);
    jBSalvar.setEnabled(true);
    jBNew.setEnabled(false);
}                                     

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(GerPerm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(GerPerm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(GerPerm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(GerPerm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new GerPerm().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton jBAnt;
private javax.swing.JButton jBAtu;
private javax.swing.JButton jBDel;
private javax.swing.JButton jBNew;
private javax.swing.JButton jBPri;
private javax.swing.JButton jBProx;
private javax.swing.JButton jBSair;
private javax.swing.JButton jBSalvar;
private javax.swing.JButton jBUlt;
private javax.swing.JLabel jLBG;
private javax.swing.JLabel jLCod;
private javax.swing.JLabel jLPermi;
private javax.swing.JLabel jLTitulo;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTCad;
private javax.swing.JTextField jTFCodPerm;
private javax.swing.JTextField jTFPermi;
// End of variables declaration                   

}

CREATE TABLE IF NOT EXISTS public.permissao
(
permi character varying COLLATE pg_catalog.“default”,
id_perm integer NOT NULL DEFAULT nextval(‘permissao_id_perm_seq’::regclass),
CONSTRAINT pk_perm PRIMARY KEY (id_perm)
)


Inserção em Acesso
Inserção em Permissao novamente

2ª PARTE

public class ModAcesso extends ModPermissao {

private int id_acess;
private String tipoacs;

/**
 *
 * @param id_perm
 * @param permi
 */


public ModAcesso() {
    this.id_acess = id_acess;
    this.id_perm = id_perm;
    this.permi = permi;
    this.tipoacs = tipoacs;
}

public int getId_acess() {
    return id_acess;
}

/**
 * @param id_acess the id_acess to set
 */
public void setId_acess(int id_acess) {
    this.id_acess = id_acess;
}

/**
 * @return the tipoacs
 */
public String getTipoacs() {
    return tipoacs;
}

/**
 * @param tipoacs the tipoacs to set
 */
public void setTipoacs(String tipoacs) {
    this.tipoacs = tipoacs;
}

}

public class ControlAcs {

ConectBD conectacs = new ConectBD();
ModAcesso modacs = new ModAcesso();
int codPermissao;

 public void Inseriracs (ModAcesso modacs){

    buscacodigo(modacs.getPermi());
    conectacs.conecta();
    
     
    try{
        PreparedStatement pst = conectacs.conn.prepareStatement("insert into acesso (tipoacs, permi, id_perm)values(?,?,?)");
        
        //pst.setString(2,modacs.getPermi());
        pst.setString(1,modacs.getTipoacs());
        pst.setString(2, modacs.getPermi());
        pst.setInt(3, codPermissao);
        
        pst.execute();
        
        JOptionPane.showMessageDialog(null, "Dados de Tipo de Acesso: "+modacs.getTipoacs()+"+ armazenados com sucesso!");
    }catch(SQLException ex){
        JOptionPane.showMessageDialog(null, "Erro ao cadastrar Tipo de Acesso:" + ex);
    }
    conectacs.desconecta();
}
 
public void buscacodigo(String pms){

    try {
        conectacs.conecta();
        conectacs.executaSQL("select * from permissao where permi='"+pms+"'");
        conectacs.rs.first();
        
        codPermissao = conectacs.rs.getInt("id_perm");
    } catch (SQLException ex) {
        Logger.getLogger(ControlAcs.class.getName()).log(Level.SEVERE, null, ex);
    }
    
}


public void Excluiracs (ModAcesso modacs){
    conectacs.conecta();
    
    try{
        PreparedStatement pst = conectacs.conn.prepareStatement("delete from acesso where id_acess=?");
       
        pst.setInt(1,modacs.getId_acess());

        pst.execute();
        
        JOptionPane.showMessageDialog(null, "Dados Tipo de Acesso"+modacs.getTipoacs()+" deletados com sucesso!");
    }catch(SQLException ex){
        JOptionPane.showMessageDialog(null, "Erro ao deletar Tipo de Acesso:" + ex);
    }
    conectacs.desconecta();
}

public void Alteraracs (ModAcesso modacs){
    conectacs.conecta();
    
    try{
        PreparedStatement pst = conectacs.conn.prepareStatement("update acesso set permi=?, tipoacs=? where id_acess=?");

        pst.setString(1,modacs.getPermi());
        pst.setString(2,modacs.getTipoacs());
        
        pst.execute();
        
        JOptionPane.showMessageDialog(null, "Dados Tipo de Acesso: "+modacs.getTipoacs()+" alterados com sucesso!");
    }catch(SQLException ex){
        JOptionPane.showMessageDialog(null, "Erro ao atualizar Tipo de Acesso:" + ex);
    }
    conectacs.desconecta();
}

}

public class GerAcs extends javax.swing.JFrame {

    ConectBD conperm = new ConectBD(); 
   
    ConectBD conacs = new ConectBD();
    ControlAcs cta = new ControlAcs();
    ModAcesso modacs = new ModAcesso();
    
public GerAcs() {
    initComponents();

    conacs.conecta();
    conperm.conecta();
    preencherCombo();
    preencherTabela("select * from acesso order by id_acess");
}

public void preencherCombo(){
    
    conperm.executaSQL("select * from permissao order by id_perm");
    
    try{

        conperm.rs.first();            
        jCBPerm.removeAllItems();
        
        do {
            jCBPerm.addItem(conperm.rs.getString("permi"));
            
        }while (conperm.rs.next());
    } catch (SQLException ex){
        JOptionPane.showMessageDialog(rootPane, "Erro ao preencher CBPerm: " + ex);
    }
    
}

public void preencherTabela(String SQL){
    ArrayList dados = new ArrayList();
    
    String[] Colunas = new String[]{"CodAcesso", "Tipo","CodPermissao", "Permissão"};

    conacs.executaSQL(SQL);
    try{
        conacs.rs.first();
        do{
            dados.add(new Object[]{conacs.rs.getInt("id_acess"),conacs.rs.getString("tipoacs"),conacs.rs.getString("id_perm"),conacs.rs.getString("permi")});
        }while(conacs.rs.next());
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(rootPane, "Erro ao preencher a ArrayList!\n Erro:" + ex);
    } 
    
    ModeloTabela modtab = new ModeloTabela(dados, Colunas);
    
    jTCad.setModel(modtab);
    jTCad.getColumnModel().getColumn(0).setPreferredWidth(80);
    jTCad.getColumnModel().getColumn(0).setResizable(false);
    jTCad.getColumnModel().getColumn(1).setPreferredWidth(200);
    jTCad.getColumnModel().getColumn(1).setResizable(false);
    jTCad.getColumnModel().getColumn(2).setPreferredWidth(200);
    jTCad.getColumnModel().getColumn(2).setResizable(false);
    jTCad.getColumnModel().getColumn(3).setPreferredWidth(200);
    jTCad.getColumnModel().getColumn(3).setResizable(false);
    
    jTCad.getTableHeader().setReorderingAllowed(false);
    jTCad.setAutoResizeMode(jTCad.AUTO_RESIZE_OFF);
    jTCad.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //jTCadSec.setSelectionModel(ListSelectionModel.SINGLE_SELECTION);
}

public void novo (){
    jTFCod.setText("");
    jTFNome.setText("");

    jTFCod.setEnabled(true);
    jTFNome.setEnabled(true);

    jBAtu.setEnabled(true);
    jBDel.setEnabled(true);
    jBSalvar.setEnabled(true);
}

public void salvar (){

        /*try {
            
            modacs.setTipoacs(jTFNome.getText());
            //conperm.executaSQL("select * from permissao order by permi"+jCBPerm.getSelectedItem());
            modacs.setPermi((String) jCBPerm.getSelectedItem());
            conperm.rs.first();
           // modacs.setId_perm(conperm.rs.getInt("id_perm"));
            
            cta.Inseriracs(modacs);
        } catch (SQLException ex) {
            Logger.getLogger(GerAcs.class.getName()).log(Level.SEVERE, null, ex);
        }*/
        
    modacs.setPermi((String) jCBPerm.getSelectedItem());
    modacs.setTipoacs(jTFNome.getText());
    cta.Inseriracs(modacs);
    
    jTFNome.setText("");

    jTFNome.setEnabled(true);

    jBAtu.setEnabled(false);
    jBDel.setEnabled(false);
    jBSalvar.setEnabled(false);
    jBNew.setEnabled(true);
    
}

public void prim () {

    jBAtu.setEnabled(true);
    jBDel.setEnabled(true);
    
    jTFNome.setEnabled(true);
    
        try {
            conacs.executaSQL("select * from acesso order by id_acess");
            conacs.rs.first();
            
            jTFCod.setText(String.valueOf(conacs.rs.getInt("id_acess")));
            jTFNome.setText(conacs.rs.getString("tipoacs"));
            
            conperm.executaSQL("select * from permissao where id_perm=" + conacs.rs.getString("id_perm"));
            conacs.rs.first();
            jCBPerm.setSelectedItem(conperm.rs.getString("permi"));
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao setar o primeiro registro!\nERRO: " + ex);
        }

}

public void ult () {
   
    jBAtu.setEnabled(true);
    jBDel.setEnabled(true);
    
    jTFNome.setEnabled(true);
    
        try {
            conacs.executaSQL("select * from acesso order by id_acess");
            conacs.rs.last();
            
            jTFCod.setText(String.valueOf(conacs.rs.getInt("id_acess")));
            jTFNome.setText(conacs.rs.getString("tipoacs"));
            
            conperm.executaSQL("select * from permissao where id_perm=" + conacs.rs.getString("id_perm"));
            conacs.rs.first();
            jCBPerm.setSelectedItem(conperm.rs.getString("permi"));
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao setor o último registro!\nERRO: " + ex);
        }
}

public void ant () {
   
    jBAtu.setEnabled(true);
    jBDel.setEnabled(true);
    
    jTFNome.setEnabled(true);
    
        try {
            conacs.executaSQL("select * from acesso order by id_acess");
            conacs.rs.previous();
            
            jTFCod.setText(String.valueOf(conacs.rs.getInt("id_acess")));
            jTFNome.setText(conacs.rs.getString("tipoacs"));
            
            conperm.executaSQL("select * from permissao where id_perm=" + conacs.rs.getString("id_perm"));
            conacs.rs.first();
            jCBPerm.setSelectedItem(conperm.rs.getString("permi"));
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao setor o último registro!\nERRO: " + ex);
        }
}
 
public void prox () {
   
    jBAtu.setEnabled(true);
    jBDel.setEnabled(true);
    
    jTFNome.setEnabled(true);
    
        try {
            conacs.executaSQL("select * from acesso order by id_acess");
            conacs.rs.next();
            
            jTFCod.setText(String.valueOf(conacs.rs.getInt("id_acess")));
            jTFNome.setText(conacs.rs.getString("tipoacs"));
            
            conperm.executaSQL("select * from permissao where id_perm=" + conacs.rs.getString("id_perm"));
            conacs.rs.first();
            jCBPerm.setSelectedItem(conperm.rs.getString("permi"));
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao setor o último registro!\nERRO: " + ex);
        }
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jTFCod = new javax.swing.JTextField();
    jTFNome = new javax.swing.JTextField();
    jLPerm = new javax.swing.JLabel();
    jCBPerm = new javax.swing.JComboBox<>();
    jBNew = new javax.swing.JButton();
    jBSalvar = new javax.swing.JButton();
    jBAtu = new javax.swing.JButton();
    jBDel = new javax.swing.JButton();
    jBPri = new javax.swing.JButton();
    jBAnt = new javax.swing.JButton();
    jBProx = new javax.swing.JButton();
    jBUlt = new javax.swing.JButton();
    jBSair = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTCad = new javax.swing.JTable();
    jLTitulo = new javax.swing.JLabel();
    jLNome = new javax.swing.JLabel();
    jLCod = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jLBGCadUsu = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("GESTÃO DE ACESSOS");
    getContentPane().setLayout(null);

    jTFCod.setEditable(false);
    getContentPane().add(jTFCod);
    jTFCod.setBounds(90, 100, 60, 30);
    getContentPane().add(jTFNome);
    jTFNome.setBounds(220, 100, 150, 30);

    jLPerm.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLPerm.setText("Permissão:");
    getContentPane().add(jLPerm);
    jLPerm.setBounds(380, 110, 90, 17);

    jCBPerm.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1", "2" }));
    getContentPane().add(jCBPerm);
    jCBPerm.setBounds(460, 100, 130, 30);

    jBNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/novo40x40.png"))); // NOI18N
    jBNew.setToolTipText("Novo");
    jBNew.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBNewActionPerformed(evt);
        }
    });
    getContentPane().add(jBNew);
    jBNew.setBounds(200, 150, 40, 50);

    jBSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/salvar40x40.png"))); // NOI18N
    jBSalvar.setToolTipText("Salvar");
    jBSalvar.setEnabled(false);
    jBSalvar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBSalvarActionPerformed(evt);
        }
    });
    getContentPane().add(jBSalvar);
    jBSalvar.setBounds(250, 150, 40, 50);

    jBAtu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/atualizar40x40.png"))); // NOI18N
    jBAtu.setToolTipText("Atualizar");
    jBAtu.setEnabled(false);
    jBAtu.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBAtuActionPerformed(evt);
        }
    });
    getContentPane().add(jBAtu);
    jBAtu.setBounds(300, 150, 40, 50);

    jBDel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/deletar40x40.png"))); // NOI18N
    jBDel.setToolTipText("Excluir");
    jBDel.setEnabled(false);
    jBDel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBDelActionPerformed(evt);
        }
    });
    getContentPane().add(jBDel);
    jBDel.setBounds(350, 150, 40, 50);

    jBPri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/primeiro40x40.png"))); // NOI18N
    jBPri.setToolTipText("Primeiro");
    jBPri.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBPriActionPerformed(evt);
        }
    });
    getContentPane().add(jBPri);
    jBPri.setBounds(400, 150, 40, 50);

    jBAnt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/anterior40x40.png"))); // NOI18N
    jBAnt.setToolTipText("Anterior");
    jBAnt.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBAntActionPerformed(evt);
        }
    });
    getContentPane().add(jBAnt);
    jBAnt.setBounds(450, 150, 40, 50);

    jBProx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/proximo40x40.png"))); // NOI18N
    jBProx.setToolTipText("Próximo");
    jBProx.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBProxActionPerformed(evt);
        }
    });
    getContentPane().add(jBProx);
    jBProx.setBounds(500, 150, 40, 50);

    jBUlt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/ultimo40x40.png"))); // NOI18N
    jBUlt.setToolTipText("Último");
    jBUlt.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBUltActionPerformed(evt);
        }
    });
    getContentPane().add(jBUlt);
    jBUlt.setBounds(550, 150, 40, 50);

    jBSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/sair40x40.png"))); // NOI18N
    jBSair.setToolTipText("Sair");
    jBSair.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBSairActionPerformed(evt);
        }
    });
    getContentPane().add(jBSair);
    jBSair.setBounds(600, 150, 40, 50);

    jTCad.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {},
            {},
            {},
            {}
        },
        new String [] {

        }
    ));
    jScrollPane1.setViewportView(jTCad);

    getContentPane().add(jScrollPane1);
    jScrollPane1.setBounds(40, 220, 680, 130);

    jLTitulo.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
    jLTitulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLTitulo.setText("GESTÃO DE ACESSOS");
    getContentPane().add(jLTitulo);
    jLTitulo.setBounds(0, 20, 770, 40);

    jLNome.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLNome.setText("Acesso:");
    getContentPane().add(jLNome);
    jLNome.setBounds(160, 110, 60, 17);

    jLCod.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLCod.setText("Código:");
    getContentPane().add(jLCod);
    jLCod.setBounds(30, 110, 60, 17);

    jButton1.setBackground(new java.awt.Color(51, 0, 102));
    jButton1.setFont(new java.awt.Font("Skranji", 1, 12)); // NOI18N
    jButton1.setForeground(new java.awt.Color(255, 255, 255));
    jButton1.setText("Add Permissão");
    jButton1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    getContentPane().add(jButton1);
    jButton1.setBounds(600, 100, 120, 30);

    jLBGCadUsu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMGS/BackgroundESQ.png"))); // NOI18N
    getContentPane().add(jLBGCadUsu);
    jLBGCadUsu.setBounds(0, -60, 790, 680);

    setSize(new java.awt.Dimension(758, 424));
    setLocationRelativeTo(null);
}                   

private void jBNewActionPerformed(java.awt.event.ActionEvent evt) {                                      
    novo();

}                                     

private void jBSalvarActionPerformed(java.awt.event.ActionEvent evt) {                                         
    salvar();
    
}                                        

private void jBAtuActionPerformed(java.awt.event.ActionEvent evt) {                                      
    //atucadmodal();
}                                     

private void jBDelActionPerformed(java.awt.event.ActionEvent evt) {                                      
    //delcadmodal();}
           
                           

private void jBSairActionPerformed(java.awt.event.ActionEvent evt) {                                       
    dispose();
}                                      

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    GerPerm gp = new GerPerm();
    gp.setVisible(true);
}                                        
public static void main(String args[]) {

    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(GerAcs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(GerAcs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(GerAcs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(GerAcs.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new GerAcs().setVisible(true); } });
}
              
private javax.swing.JButton jBAnt;
private javax.swing.JButton jBAtu;
private javax.swing.JButton jBDel;
private javax.swing.JButton jBNew;
private javax.swing.JButton jBPri;
private javax.swing.JButton jBProx;
private javax.swing.JButton jBSair;
private javax.swing.JButton jBSalvar;
private javax.swing.JButton jBUlt;
private javax.swing.JButton jButton1;
private javax.swing.JComboBox<String> jCBPerm;
private javax.swing.JLabel jLBGCadUsu;
private javax.swing.JLabel jLCod;
private javax.swing.JLabel jLNome;
private javax.swing.JLabel jLPerm;
private javax.swing.JLabel jLTitulo;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTCad;
private javax.swing.JTextField jTFCod;
private javax.swing.JTextField jTFNome;           

}

CREATE TABLE IF NOT EXISTS public.acesso
(
– Inherited from table public.permissao: permi character varying COLLATE pg_catalog.“default”,
tipoacs character varying COLLATE pg_catalog.“default”,
– Inherited from table public.permissao: id_perm integer NOT NULL DEFAULT nextval(‘permissao_id_perm_seq’::regclass),
id_acess integer NOT NULL DEFAULT nextval(‘acesso_id_acess_seq’::regclass),
CONSTRAINT pk_acs PRIMARY KEY (id_acess),
CONSTRAINT fk_permacs FOREIGN KEY (id_perm)
REFERENCES public.permissao (id_perm) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
)
INHERITS (public.permissao)

1 curtida

Desculpe a minha ignorância, pois já faz bastante tempo que não estudo Java.
Mas só uma dica: Voce poderia postar onde acontece o erro exatamente, tratando melhor os try catch.

E tambem acredito que essa tela poderia ser simplificada.
(Codigo, Acesso, Permissão), parecem ser muitos ambíguos. É uma tela de login, onde há usuários para acesso ao sistema como Clientes, e para administradores::>>Pergunta<<

Acho que o problema está na logica, no modelo. No diagrama.

Se está inserindo duas vezes.

Foque apenas nos codigos relacionados ao INSERT…

Justamente, eu não sei onde é o erro

Já que para o código em si está salvando corretamente, aí clicar no botão salvar ele salva, não tem erro pra ser capturado pelo catch

A questão de ter 2 classes é que posso ter níveis de permissões com diferentes tipos de acesso então não faz sentido ter uma classe só

No insert de Controle de Acesso tem apenas o inseto na tabela de acesso

Estou em dúvidas se tem haver com o this, se eu teria que chamar como super, mas já tentei com super e não tive sucesso, dá erro
Só consigo passar os paramentos com o this