title: How to dynamically change database/catalog when using Spring JdbcTemplate
body: <p>Consider a situation where all client data is stored in its own database/catalog and all such databases are stored in a single RDBMS (client-data). Master data (e.g. clients, ...) is kept in another RDBMS (master-data). How can we dynamically access a particular database in client-data RDBMS by means of <code>JdbcTemplate</code>?</p>
  
  <p>Defining <code>DataSource</code> for each database in client-data RDBMS and then dynamically select one as suggested <a href="https://stackoverflow.com/questions/7960397/using-abstractroutingdatasource-to-dynamically-change-the-database-schema-catalo">here</a> is not an option for us since the databases are created and destroyed dynamically.</p>
  
  <p>I would basically need something like JDBC's <code>Connection.setCatalog(String catalog)</code> but I have not found anything like that available in Spring <code>JdbcTemplate</code>.</p>