public static DBHandle cloneDbHandle(DBHandle dbh) throws IOException {

		try {
			File tmpFile = Application.createTempFile("tmp", ".db");
			tmpFile.delete();

			LocalBufferFile bf = new LocalBufferFile(tmpFile, dbh.getBufferSize());
			dbh.saveAs(bf, dbh.getDatabaseId(), false, TaskMonitor.DUMMY);
			tmpFile.deleteOnExit();

			return new DBHandle(bf);
		}
		catch (CancelledException e) {
			throw new IOException(e); // unexpected
		}
	}
Clone a DBHandle backed by a new temporary source buffer file.
The specified dbh will remain associated with its original source buffer file.
@param dbh DBHandle to clone
@return new DBhandle
@throws IOException if a file IO error occurs
Ghidra/Framework/DB/src/test/java/db/DBTestUtils.java