private static SettingsDBAdapter upgrade(DBHandle dbHandle, SettingsDBAdapter oldAdapter,
			AddressMap addrMap, TaskMonitor monitor)
			throws VersionException, IOException, CancelledException {

		String tableName = oldAdapter.getTableName();
		monitor.setMessage("Upgrading " + tableName + "...");
		monitor.initialize(2 * oldAdapter.getRecordCount());
		int cnt = 0;

		AddressMap oldAddrMap = addrMap != null ? addrMap.getOldAddressMap() : null;

		DBHandle tmpHandle = new DBHandle();
		SettingsDBAdapter tmpAdapter = null;
		try {
			tmpHandle.startTransaction();

			tmpAdapter = new SettingsDBAdapterV1(tableName, tmpHandle, true);
			RecordIterator iter = oldAdapter.getRecords();
			while (iter.hasNext()) {
				if (monitor.isCancelled()) {
					throw new CancelledException();
				}
				DBRecord rec = iter.next();
				if (oldAddrMap != addrMap) {
					// updated address-based association ID if needed
					Address addr =
						oldAddrMap.decodeAddress(rec.getLongValue(SETTINGS_ASSOCIATION_ID_COL));
					rec.setLongValue(SETTINGS_ASSOCIATION_ID_COL, addrMap.getKey(addr, true));
				}
				tmpAdapter.createSettingsRecord(rec.getLongValue(SETTINGS_ASSOCIATION_ID_COL),
					oldAdapter.getSettingName(rec), rec.getString(SETTINGS_STRING_VALUE_COL),
					rec.getLongValue(SETTINGS_LONG_VALUE_COL));
				monitor.setProgress(++cnt);
			}

			// NOTE: If a V2 adapter is ever added multiple tables may need to be removed.
			dbHandle.deleteTable(tableName);

			SettingsDBAdapter newAdapter = new SettingsDBAdapterV1(tableName, dbHandle, true);
			iter = tmpAdapter.getRecords();
			while (iter.hasNext()) {
				if (monitor.isCancelled()) {
					throw new CancelledException();
				}
				DBRecord rec = iter.next();
				newAdapter.createSettingsRecord(rec.getLongValue(SETTINGS_ASSOCIATION_ID_COL),
					tmpAdapter.getSettingName(rec), rec.getString(SETTINGS_STRING_VALUE_COL),
					rec.getLongValue(SETTINGS_LONG_VALUE_COL));
				monitor.setProgress(++cnt);
			}
			return newAdapter;
		}
		finally {
			tmpHandle.close();
		}
	}
Get a settings adapter.
NOTE: Support for read-only mode for older versions must be retained.
@param tableName settings DB table name
@param handle database handle
@param openMode database open mode
@param addrMap address map (should only be specified when association IDs 
correspond to address key, otherwise should be null).
@param monitor task monitor
@return settings adapter instance
@throws VersionException if schema version does not match current version
@throws IOException if there was a problem accessing the database
@throws CancelledException if task cancelled
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/SettingsDBAdapter.java