In JPA you would just use multiple persistence units, and create one EntityManagerFactory per persistence unit/database.
Then, when calling EntityManagerFactory.createEntityManager() you would pass in a Properties instance that you would build dynamically, and set the hibernate.connection.url property to the URL of your newly created database.
And how to create the database? Just use JDBC and execute your create database statement, and then schema DDL statements.
Andy.
_________________ http:// www.techfoundry.com
|