title: How to use Hibernate with multiple databases on a single server
body: <p>Our application allows our customer to have multiple databases, all running on one instance of the database server.</p>
  
  <p>For example, databases might be  dbcommon, dbLive, dbStaging, dbUAT, dbDev, dbSandbox.  The common database and the Production database always exists, but the others are optional (and there is no limit). In dbcommon there is a table that tells us all the databases....so that's where I would need to start. The tables in common are different from the others, and the others all have the same schema (subscriber data)</p>
  
  <p>Using Hibernate, how can I dynamically create/use a connection to either Live or Staging (or any of the others)? I am using Spring if that helps.</p>
  
  <p>I have come across answers that suggest creating different connections in configuration, but because the number of subscriber databases can vary (per install, not while the app is running), this isn't an option for me.  </p>