title: In-memory Java database that I can persist (as a single huge blob of memory)
body: <p>I am looking for an in-memory relational (SQL) database for Java (something like HSQLDB), whose whole state I can serialise.</p>
  
  <pre><code>wholeDatabase.serialize(outputStream);
  newCopyOftheDatabase.loadFrom(inputStream);
  </code></pre>
  
  <p>Or maybe the DB only uses a byte[] that I give it on initialization:</p>
  
  <pre><code>byte[] memory = new byte[10 *1024*1024];
  new InMemoryDatabase(memory);
  </code></pre>
  
  <p>The database will not be too huge, low tens of MB, but I cannot write files, so I need to stream everything off the machine before I shut the VM down (and periodically for backup).</p>
  
  <p>I could use plain (and easily serializable) Java data structures like arrays or maps instead of a DB, but I want to be able to use SQL.</p>