How to create database automatically when we run war file in tomcat

Hi,

I am facing issue while running the war file at first time. It was not creating database automatically while running. I need to create one empty database for it. So can you please tell me how to create database dynamically while running the war in tomcat for the first time.

Thanks.

Hi @mithibai17

It is not possible as you are probably expecting. Take a look at Execution of Database Scripts by Server:

However, unlike the Gradle createDb task described in the previous section, the database must exist to be initialized – the server does not create the database automatically but only executes scripts on it.

However, you can Initialize and Update Database from Command Line. I think this is the only way that you may be able to achieve what you want.

Regards,
Peterson.

1 Like