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 fi开发者_如何学Gorst 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?
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.
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.
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).
精彩评论