Ciao a tutti , ho un'applicazione divisa in 2 pannelli , in un pannello a sinistra ho un albero dove al clik di un nodo viene lanciata una query che mostrerà poi i dati in una tabella nel pannello di destra .

Allora , ho una prima classe che estende AbstractTableModel ,

codice:
class ResultSetTableModel extends AbstractTableModel {
    private ResultSet rs;
    private ResultSetMetaData rsdata;
    
    public ResultSetTableModel (ResultSet rset){
        rs = rset;
        try{
            rsdata = rs.getMetaData();
        }
        catch(SQLException sql){
            sql.printStackTrace();
        }
    }
    
    public String getColumnName(int c){
        try{
            return rsdata.getColumnName(c + 1);
        }
        catch(SQLException sql){
            sql.printStackTrace();
            return "";
        }
    }
    
    public int getColumnCount(){
        return 4;
    }
    
    public Object getValueAt(int r, int c){
        try{
            rs.absolute(r + 1);
            return rs.getObject(c + 1);
        }
        catch(SQLException sql){
            sql.printStackTrace();
            return null;
        }
    }
    
    public int getRowCount(){
        try{
            rs.last();
            return rs.getRow();
        }
        catch(SQLException sql){
            sql.printStackTrace();
            return 0;
        }
    }
}
e poi la classe che estende JPanel dove è presente la jtable

codice:
public class TablePanel extends JPanel {
    private ResultSetTableModel rstm;
    /** Creates new form TablePanel */
    public TablePanel(String s) {
        try{
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            Connection c = DriverManager.getConnection("jdbc:derby:maildb");
            String sql = "select mail.m_from, mail.m_oggetto, mail.m_data, m_read, cartelle.* " +
                    "from cartelle inner join mail on cartelle.id_cartella = mail.id_cartella where " +
                    "cartelle.nome = '"+ s +"'";
            Statement stat = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
            ResultSet rs = stat.executeQuery(sql);
            rstm = new ResultSetTableModel(rs);
            rs.close();
            stat.close();
            c.close();
        }
        catch(ClassNotFoundException cnf){}
        catch(SQLException sql){
            while(sql != null){
                sql.printStackTrace();
                sql = sql.getNextException();
            }            
        }
        initComponents();
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        table = new javax.swing.JTable();

        table.setModel(rstm);
        jScrollPane1.setViewportView(table);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>                        
    
    
                        
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable table;
    // End of variables declaration                   
}
Come db sto usando apache derby embedded . Al clik sul nodo però mi viene fuori un'eccezzione che dice :
java.sql.SQLException: ResultSet not open. Operation 'last()' not permitted. Verify that autocommit is OFF.

Ma non sembrerebbe essere un problema di legato al metodo last() , perchè se lo commento mi da lo stesso errore sul metodo getRow(), più tosto non capisco la voce "Verify that autocommit is OFF."
Qualcuno sa aiutarmi ?
Ciao e grazie