0
votes

I can use acceptChanges, jdbcRowSet1.acceptChanges(); , with my jdbcRowSet data source to accept the changes (updates, deletes, etc). How would I rollback or cancel any updates, deletions, etc.???

I tried jdbcRowSet1.rollback(); but got an error.

Error while executing JavaScript action expression Script interpreter error, line=1, col=13: Unknown member 'rollback' in Java class 'com.ibm.xsp.extlib.jdbc.model.JdbcRowSetAccessor'

JavaScript code

1: jdbcRowSet1.rollback();

Anyone try this yet?

thanks, Howard

2

2 Answers

1
votes

The jdbcRowSet data source does not currently support rollback(). We could add support for this in the future perhaps (no guarantees). From my reading, there is a method RowSet.cancelRowUpdates() that we could use in our jdbcRowSet implementation for this, but it only cancels updates to a row, and doesn't cancel deletions/insertions.

A simple potential solution for your issue would be to reload the page via javascript call, context.reloadPage(), and that will discard the current rowSet. Simplistic solution, but it may do the trick for you.

0
votes

Your questions is really less XPages specific, and more about general SQL management in Java, so if you want a more indepth answer than I provide, you may want to update your tags.

More than likely your connection has autocommit set to true. This forces the data set to commit changes as you make them immediately, so there is nothing to roll back. The rollback() method is from the connection object related to the row set, and will not provide a rollback when autocommit is true, hence the error you get.

You need to look into changing your auto commit to false, then make sure you call commit() or rollback() when you are done with your changes. If you have multiple transactions occurring, you should look into the the connection manager as well. I touch in this briefly in the chapter on the SQL controls in the Extension Library book from IBM Press.