views:

39

answers:

3

I have an application that uses hibernate and JPA to handle the database. I know that hibernate can create the database tables for me, however, I've found that I must first create the database files and the database user account before hibernate can create the tables. Is there a way for hibernate to do create the database and user account for me?

A: 

Unfortunately not.

For one, Hibernate/JPA relies on the persistence.xml and specifically the JDBC connection URL required -- which contain the name and user of your database.

Hibernate/JPA are ORM frameworks: Object Relational mapping frameworks designed to map Java code to database objects.

Marco
+1  A: 

If this was possible, it would mean that an external process can create accounts, databases and tables in the database without any access rights. I think we don't want this.

Adriaan Koster
A: 

What are your reasons for wanting this? I can only think for testing purposes, in that case you can use an in memory database (such as HSQLDB).

Ross