If you are on Mac OS X and with IntelliJ IDEA 14, this will be stored here:
~/Library/Caches/IntelliJIdea14/userHistory/*.xml
I suspect that OS X updates sometimes clear ~/Library/Caches
because after updating OS X 10.10.2 I lost the history of the database console. If the contents of your database console are important to you, make sure that you back up this folder and do not exclude it in a Time Machine backup!
Update (2016/09/23): at some point, they pulled it out of the cache and into the settings folder, which is good because you no longer have to worry about macOS updates destroying it. For example, it is here in the current version:
~/Library/Preferences/IntelliJIdea2016.2/consoles/db/
source share