Napisalem program, ktory umozliwia odczyt i edycje danych z tabeli products. Do tego celu uzywam klasy CachedRowSet. Na razie mam tyle:

class MainPanel extends JPanel {

    private final int WIDTH = 600;
    private final int HEIGHT = 400;
    private CachedRowSet crs;
    private List<JTextField> fields = new LinkedList<>();

    MainPanel() {
        setPreferredSize(new Dimension(WIDTH, HEIGHT));
        try {
            //Zapełnienie stosu danymi
            crs = new CachedRowSetImpl();
            crs.setUrl("jdbc:postgresql:testdb");
            crs.setUsername("username");
            crs.setPassword("password");
            crs.setCommand("SELECT * FROM products");  
            crs.execute();
            //Utworzenie pol tekstowych z etykietami
            ResultSetMetaData meta = crs.getMetaData();
            for (int a = 1; a <= meta.getColumnCount(); a++) {
                JTextField field = new JTextField(10);
                add(new JLabel(meta.getColumnLabel(a)));
                fields.add(field);
                add(field);
            }
            //Zapełenienie
            crs.next();
            updateFields();
            //Przyciski
            JButton nextButton = new JButton("Next");
            nextButton.addActionListener(...);
            add(nextButton);
            
            JButton prevButton = new JButton("Previous");
            prevButton.addActionListener(...);
            add(prevButton);
            
            JButton saveButton = new JButton("Save changes");
            saveButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent event) {
                    try {
                        for (int a=0; a<fields.size(); a++) {
                            crs.updateString(a+1, fields.get(a).getText());
                        }
                        crs.updateRow();
                        crs.acceptChanges();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
            });
            add(saveButton);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

    private void updateFields() throws SQLException {
        for (int a = 0; a < fields.size(); a++) {
            fields.get(a).setText(crs.getString(a + 1).trim());
        }
    }
}

Sledzenie stosu:

org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.commit(AbstractJdbc2Connection.java:705)
    at com.sun.rowset.internal.CachedRowSetWriter.commit(CachedRowSetWriter.java:1396)
    at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:893)
    at test.MainPanel$3.actionPerformed(MainPanel.java:85)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    ...

Wyrzucony jest wyjatek ale mimo to rekord JEST ZMIENIONY. Gdy nastepnym razem wlaczam aplikacje to widze ze rekord zostal zmieniony. Jezeli usune wywolanie acceptChanges() to nie ma wyjatku, rekord jest zmieniony ale tylko w CachedRowSet, nie w bazie danych. Dlaczego tak sie dzieje, co zrobic zeby nie bylo wyjatku a rekord byl zmieniany?