I want to create database at the first time of an application deploying process. I am using JPA. So I consider two ways.
1) I have a full connection description in my persistence.xml:
<property name="mysql.jdbc.user" value="root"/>
<property name="mysql.jdbc.password" value=""/>
<property name="mysql.jdbc.url" value="jdbc:mysql://localhost:3306/DB"/>
<property name="mysql.jdbc.driver" value="com.mysql.jdbc.Driver"/>
When an application is started, it cannot connect to DB and reports about this trouble advising to go to the install page. In this install page I launch a DB creation with explicit SQL queries.
2) I have a connection to a database server:
<property name="mysql.jdbc.user" value="root"/>
<property name="mysql.jdbc.password" value=""/>
<property name="mysql.jdbc.url" value="jdbc:mysql://localhost:3306/"/>
<property name="mysql.jdbc.driver" value="com.mysql.jdbc.Driver"/>
An application informs me that it is a first conneciton and redirect me to the install page. During a DB installation persistence.xml should be modified. The property mysql.jdbc.url
must be changed a new value assignment which declares a database name.
What do you think about this? How to do this?