/** * Updates multiple proxy data stores in a single transaction * * @param ds The Array of DataStores to update * @throws DataStoreException */ public static void update(DataStoreProxy[] ds) throws DataStoreException { int i = 0; DSDataSourceProxy out = ds[0].getDataSourceProxy(); try { out.preUpdate(ds[0]); for (i = 0; i < ds.length; i++) { out.writeDSHeader(ds[i]); ds[i].setRemoteUpdateReturnValue(null); ds[i].updateDs(out); } out.commit(ds[0]); out.postUpdate(ds, true); for (i = 0; i < ds.length; i++) ds[i].resetStatus(); } catch (DataStoreException e) { try { out.postUpdate(ds, false); } catch (Exception ex) { System.err.println("DataStoreProxy.update() -- postUpdate:" + ex); } throw (e); } catch (Exception e) { try { out.postUpdate(ds, false); } catch (Exception ex) { System.err.println("DataStoreProxy.update() -- postUpdate:" + ex); } String message = e.getMessage(); if (message.equals("$Update$") || message.equals("$Insert$") || message.equals("$Delete$")) { throw new DataStoreException("DataStore updated canceled."); } else throw new DataStoreException(e.toString()); } }
/** * This method will cause the database to reflect the changes made in the data store's buffer. * * @exception com.salmonllc.sql.DataStoreException If a SQLError occurs while the datastore is * updating. */ public void update() throws DataStoreException { waitForRetrieve(); DSDataSourceProxy out = _dataSource; _updateResults = null; DataStoreProxy[] proxy = {this}; try { out.preUpdate(this); out.writeDSHeader(this); updateDs(out); out.commit(this); out.postUpdate(proxy, true); resetStatus(); notifyListeners(ModelChangedEvent.TYPE_DATA_LOADED); } catch (DataStoreException e) { try { out.postUpdate(proxy, false); } catch (Exception ex) { System.err.println("DataStoreProxy.update() -- postUpdate:" + ex); } throw (e); } catch (Exception e) { try { out.postUpdate(proxy, false); } catch (Exception ex) { System.err.println("DataStoreProxy.update() -- postUpdate:" + ex); } String message = e.getMessage(); if (message.equals("$Update$") || message.equals("$Insert$") || message.equals("$Delete$")) { throw new DataStoreException("DataStore updated canceled."); } else throw new DataStoreException(e.toString()); } }