Java com MsAccess jdbc

Boa tarde pessoal, venho aqui com um probleminha que me está a dar cabo da cabeça.

Estou aqui com um programa que é uma agenda com uma ligação a uma bd de MsAccess e tudo funciona bem a exepção de sempre que eu quero introduzir mais que um dado não deixa, ou seja, não consigo introduzir mais que um contato de cada vez e se eu tiver mais que um tenho que fechar a aplicação e voltar a abrir.

Obrigado.

[code]import java.io.IOException;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

public final class Agenda extends javax.swing.JFrame {
Connection con;
Statement st;
ResultSet rs;

public Agenda() throws IOException {

    initComponents();
    connect();
}

public void connect()
{

try{
        String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
        Class.forName(driver);
        String DB = "jdbc:odbc:java";
        con = DriverManager.getConnection(DB);

        st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

        String sql = "select * from Agenda";

        rs = st.executeQuery(sql);

        rs.next();
        jTexNome.setText(rs.getString("Nome"));
        jTextMorada.setText(rs.getString("Morada"));
        jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
        jTextAndar.setText(rs.getString("Andar"));
        jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
        jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
        jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
        jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
        jTextEmail.setText(rs.getString("Email"));
        
    }catch (Exception ex)
    {
        System.out.print(ex);
    }
    return;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jBActualizar1 = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jTexNome = new javax.swing.JTextField();
    jTextMorada = new javax.swing.JTextField();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();
    jLabel3 = new javax.swing.JLabel();
    jTextNumero = new javax.swing.JTextField();
    jLabel4 = new javax.swing.JLabel();
    jTextCP1 = new javax.swing.JTextField();
    jTextCP2 = new javax.swing.JTextField();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jTextEmail = new javax.swing.JTextField();
    jTextTelefone = new javax.swing.JTextField();
    jTextTelemovel = new javax.swing.JTextField();
    jBActualizar = new javax.swing.JButton();
    jBApagar = new javax.swing.JButton();
    jBApagar2 = new javax.swing.JButton();
    jBApagar3 = new javax.swing.JButton();
    jLabel8 = new javax.swing.JLabel();
    jTextAndar = new javax.swing.JTextField();

    jBActualizar1.setText("Actualizar");
    jBActualizar1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBActualizar1ActionPerformed(evt);
        }
    });

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Agenda V 0.1");
    setName("Agenda "); // NOI18N

    jLabel1.setText("Nome");

    jLabel2.setText("Morada");

    jTexNome.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTexNomeActionPerformed(evt);
        }
    });

    jTextMorada.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextMoradaActionPerformed(evt);
        }
    });

    jButton1.setText("Seguinte");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jButton2.setText("Anterior");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    jButton3.setText("Último");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    jButton4.setText("Primeiro");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    jLabel3.setText("Nº");

    jTextNumero.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextNumeroActionPerformed(evt);
        }
    });

    jLabel4.setText("Código Postal");

    jTextCP1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextCP1ActionPerformed(evt);
        }
    });

    jTextCP2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextCP2ActionPerformed(evt);
        }
    });

    jLabel5.setText("Telefone");

    jLabel6.setText("Telemóvel");

    jLabel7.setText("E-Mail");

    jTextEmail.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextEmailActionPerformed(evt);
        }
    });

    jTextTelefone.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextTelefoneActionPerformed(evt);
        }
    });

    jTextTelemovel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextTelemovelActionPerformed(evt);
        }
    });

    jBActualizar.setText("Atualizar");
    jBActualizar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBActualizarActionPerformed(evt);
        }
    });

    jBApagar.setText("Apagar");
    jBApagar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBApagarActionPerformed(evt);
        }
    });

    jBApagar2.setText("Novo");
    jBApagar2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBApagar2ActionPerformed(evt);
        }
    });

    jBApagar3.setText("Salvar");
    jBApagar3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBApagar3ActionPerformed(evt);
        }
    });

    jLabel8.setText("Andar");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel4)
                .addComponent(jLabel1)
                .addComponent(jLabel2)
                .addComponent(jLabel3)
                .addComponent(jLabel5)
                .addComponent(jLabel7)
                .addComponent(jLabel6))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jTexNome, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jTextTelefone, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jTextCP1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextCP2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTextTelemovel, javax.swing.GroupLayout.Alignment.LEADING))
                .addComponent(jTextMorada, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jTextEmail, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jTextNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(53, 53, 53)
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(jTextAndar, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addContainerGap())
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
            .addContainerGap(126, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jBActualizar)
                .addComponent(jBApagar2))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                    .addComponent(jBApagar3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jBApagar)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton4))
                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                    .addComponent(jButton1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton3)))
            .addGap(80, 80, 80))
    );

    jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jBActualizar, jBApagar, jBApagar2, jBApagar3, jButton1, jButton2, jButton3, jButton4});

    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1)
                .addComponent(jTexNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel2)
                .addComponent(jTextMorada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel3)
                .addComponent(jTextNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel8)
                .addComponent(jTextAndar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4)
                .addComponent(jTextCP2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jTextCP1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel5)
                .addComponent(jTextTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(17, 17, 17)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel6)
                .addComponent(jTextTelemovel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel7)
                .addComponent(jTextEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1)
                .addComponent(jButton2)
                .addComponent(jButton3)
                .addComponent(jBActualizar))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jBApagar2)
                .addComponent(jBApagar3)
                .addComponent(jBApagar)
                .addComponent(jButton4))
            .addContainerGap(16, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    pack();
}// </editor-fold>                        

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

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

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try{
        if(rs.next())
        {
            jTexNome.setText(rs.getString("Nome"));
            jTextMorada.setText(rs.getString("Morada"));
            jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
            jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
            jTextAndar.setText(rs.getString("Andar"));
            jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
            jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
            jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
            jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
            jTextEmail.setText(rs.getString("Email"));
        }
        else
        {
             rs.previous();
            JOptionPane.showMessageDialog(null, "Não existe mais registos");
        }
    }catch(Exception ex){
    JOptionPane.showMessageDialog(null, ex, "ERRO", JOptionPane.ERROR_MESSAGE);
    }
}                                        

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       try{
        if(rs.previous())
        {
            jTexNome.setText(rs.getString("Nome"));
            jTextMorada.setText(rs.getString("Morada"));
            jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
            jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
            jTextAndar.setText(rs.getString("Andar"));
            jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
            jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
            jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
            jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
            jTextEmail.setText(rs.getString("Email"));
        }
        else
        {
             rs.next();
            JOptionPane.showMessageDialog(null, "Não existe mais registos");
        }
    }catch(Exception ex){
    JOptionPane.showMessageDialog(null, ex, "ERRO", JOptionPane.ERROR_MESSAGE);
    }
}                                        

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

    try{
       rs.last();
       jTexNome.setText(rs.getString("Nome"));
       jTextMorada.setText(rs.getString("Morada"));
       jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
       jTextAndar.setText(rs.getString("Andar"));
       jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
       jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
       jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
       jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
       jTextEmail.setText(rs.getString("Email"));
    }catch(Exception ex)
    {
    JOptionPane.showMessageDialog(null, ex, "ERRO", JOptionPane.ERROR_MESSAGE);
    }
}                                        

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
     try{
       rs.first();
        jTexNome.setText(rs.getString("Nome"));
        jTextMorada.setText(rs.getString("Morada"));
        jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
        jTextAndar.setText(rs.getString("Andar"));
        jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
        jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
        jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
        jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
        jTextEmail.setText(rs.getString("Email"));
    }catch(Exception ex){
    JOptionPane.showMessageDialog(null, ex, "ERRO", JOptionPane.ERROR_MESSAGE);
    }
}                                        

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

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

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

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

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

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

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

    String nome = jTexNome.getText();
    String morada = jTextMorada.getText();
    int  numero = Integer.valueOf(jTextNumero.getText());
    String andar = jTextAndar.getText();
    int codpostal1 = Integer.valueOf(jTextCP1.getText());
    int codpostal2 = Integer.valueOf(jTextCP2.getText());
    int telefone = Integer.valueOf(jTextTelefone.getText());
    int telemovel = Integer.valueOf(jTextTelemovel.getText());
    String email = jTextEmail.getText();

    try
    {
        rs.updateString("Nome", nome);
        rs.updateString("Morada", morada);
        rs.updateInt("Numero", numero);
        rs.updateInt("CodPostal1", codpostal1);
        rs.updateInt("CodPostal2", codpostal2);
        rs.updateInt("Telefone", telefone);
        rs.updateInt("Telemovel", telemovel);
        rs.updateString("Email", email);
        rs.updateRow();

        JOptionPane.showMessageDialog(null, "Actualização feita");

    }catch(Exception ex)
    {
        JOptionPane.showMessageDialog(null, ex);
    }
}                                            

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

private void jBApagarActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try{
        rs.deleteRow();
        st.close();
        rs.close();
        
        st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
        String sql = "select * from Agenda";
        rs = st.executeQuery(sql);

        rs.next();
        jTexNome.setText(rs.getString("Nome"));
        jTextMorada.setText(rs.getString("Morada"));
        jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
        jTextAndar.setText(rs.getString("Andar"));
        jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
        jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
        jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
        jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
        jTextEmail.setText(rs.getString("Email"));

    }catch(Exception ex){}
}                                        

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

    jTexNome.setText("");
    jTextMorada.setText("");
    jTextNumero.setText("");
    jTextAndar.setText("");
    jTextCP1.setText("");
    jTextCP2.setText("");
    jTextTelefone.setText("");
    jTextTelemovel.setText("");
    jTextEmail.setText("");
}                                         

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

    String nome = jTexNome.getText();
    String morada = jTextMorada.getText();
    int numero = Integer.valueOf(jTextNumero.getText());
    String andar = jTextAndar.getText();
    int codpost1 = Integer.valueOf(jTextCP1.getText());
    int codpost2 = Integer.valueOf(jTextCP2.getText());
    int telefone = Integer.valueOf(jTextTelefone.getText());
    int telemovel = Integer.valueOf(jTextTelemovel.getText());
    String email = jTextEmail.getText();

    try{
        rs.moveToInsertRow();
        rs.updateString("Nome", nome);
        rs.updateString("Morada", morada);
        rs.updateInt("Numero", numero);
        rs.updateInt("CodPostal1",codpost1);
        rs.updateInt("CodPostal2",codpost2);
        rs.updateInt("Telefone", telefone);
        rs.updateInt("Telemovel", telemovel);
        rs.updateString("Email", email);
        rs.insertRow();

        st.close();
        rs.close();

        st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
        String sql = "select * from Agenda";
        rs = st.executeQuery(sql);

        rs.next();

        jTexNome.setText(rs.getString("Nome"));
        jTextMorada.setText(rs.getString("Morada"));
        jTextNumero.setText(Integer.toString( rs.getInt("Numero")));
        jTextCP1.setText(Integer.toString(rs.getInt("CodPostal1")));
        jTextCP2.setText(Integer.toString(rs.getInt("CodPostal2")));
        jTextTelefone.setText(Integer.toString(rs.getInt("Telefone")));
        jTextTelemovel.setText(Integer.toString(rs.getInt("Telemovel")));
        jTextEmail.setText(rs.getString("Email")); 

    }catch(Exception ex){
        JOptionPane.showMessageDialog(null, ex);
    }
}                                         

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                new Agenda().setVisible(true);
            } catch (IOException ex) {
                Logger.getLogger(Agenda.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton jBActualizar;
private javax.swing.JButton jBActualizar1;
private javax.swing.JButton jBApagar;
private javax.swing.JButton jBApagar2;
private javax.swing.JButton jBApagar3;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTexNome;
private javax.swing.JTextField jTextAndar;
private javax.swing.JTextField jTextCP1;
private javax.swing.JTextField jTextCP2;
private javax.swing.JTextField jTextEmail;
private javax.swing.JTextField jTextMorada;
private javax.swing.JTextField jTextNumero;
private javax.swing.JTextField jTextTelefone;
private javax.swing.JTextField jTextTelemovel;
// End of variables declaration                   

}
[/code]

CQuando se fala de Access com JDBC, tudo o que você sabe sobre JDBC é bom jogar fora, porque basicamente não funciona. O driver ODBC (Jet) é bastante bugado.

ResultSets atualizáveis, por exemplo, que é o que você está tentando fazer, não rola de modo algum. Você vai ter de criar um preparedstatement e enviar os parametros pra este.

Obrigado pela resposta, tem ai algum exemplo no forum?

Ou é melhor usar mysql ou outro banco de dados?

Neste caso, eu recomendo você usar qualquer outra coisa. Eu trabalhei anos com a dobradinha Java/Access e posso te dizer com segurança: sua vida vira um inferno, porque você precisa usar o OdbcJdbcBridge, que conecta no driver ODBC Jet que é muito, muito problemático. Basicamente tudo o que você faz convencionalmente com Java você precisa esquecer. Depois, se tiver curiosidade, vá ao meu blog (http://devkico.com.br) e busque por “Access”. Eu postei algumas dicas lá pra esta sua situação.

Se quiser um BD embarcado (esta é a razão pela qual as pessoas usam o Access), experimenta o HSQLDB. É massa e muito melhor.

Obrigado.

O link não funciona do blog não funciona.

Opa, claro! Te mandei o link errado! :smiley:

Obrigado e já vi as dicas de MSAccess, agora exite algum tuto sobe HSQLDB, estive a ver e achei interessante, eu uso o NetBeans 6.9.1, desde já obrigadissímo pela ajuda.

Opa, da uma olhada neste aqui: http://www.guj.com.br/java/81539-tutorial-de-hsqldb-e-java-para-netbeans-e-eclipse

Obrigado. :smiley:

Fiz tudo como diz o Tuto e ficou a trabalhar muito bem. aqui tem uma imagem.


Tópico movido para o fórum de persistência.

Peço desculpa por estar a utilizar esse post mas não encontrei o outro para onde foi movido.

Era só para dizer Obrigado ao kicolobo pela ajuda e informar que já fiz o porte de MsAccess para HSQLDB em 5 minutos e tudo funciona muito bem, desta vez consigo inserir mais que um registo de cada vez.

Ai fica um screen.

O post continua o mesmo, só o local dele mudou. Você abriu no fórum de Java Básico, mas o correto, já que se trata de JDBC, seria tê-lo aberto no fórum de persistência.

Antes de postar um tópico, sempre leia com atenção a Descrição dos fóruns.