Recover SQL Developer editing session

Recently, in Windows 10, SQL Developer locked up and stopped responding. I had spent a couple hours on my really awesome query and I wasn’t sure when I had saved last. Once it has stopped responding, I couldn’t get SQL Developer to save the file.

After a reboot I opened the file in SQL Developer. It was blank. I opened it usign Sublime Text and saw that it contained all zeros.

As it was a new file, I did not have any history in git so there was no opportunity to recover that way.


Poking around in SQL Developer’s application files did provide some relief.

In C:\Users\SomeUser\AppData\Roaming\SQL Developer I found an SqlHistory folder. Opening each file in that folder, again using Sublime Text, proved quite helpful. I was able to locate a version close to my final edit.

Digging deeper I found in \AppData\Roaming\SQL Developer\system4. \ .history a cache of files, the most recent of which contained my SQL almost right up to the lock up as well as the verison containing all zeros. I suspect the zeroed version arose because I had opened the file after the reboot.

The files in this cache opened easily by dropping them onto Sublime Text.

Taking this information back to SQL Developer, I looked around for a way to access this history directly. I found you can right-click on the worksheet and select SQL history. This provides a nice, filterable listing that you can double-click to paste to your SQL worksheet. This was the UI equivalent of looking through the xml files in the SqlHistory folder. My entire script was found, however, in the .history cache.