JRSofty
JRSofty

Reputation: 1256

Is it possible for hibernate to create the database and database user?

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?

Upvotes: 2

Views: 203

Answers (3)

Ross
Ross

Reputation: 3008

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).

Upvotes: 0

Adriaan Koster
Adriaan Koster

Reputation: 16209

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.

Upvotes: 1

Marco
Marco

Reputation: 9097

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.

Upvotes: 0

Related Questions