Not creating tables in h2
application is running fine but not creating tables in the h2 dev tools. please help
You can exclusively add this in the properties file in case your console has a preloaded JDBC URL from previous dev
spring.datasource.url=jdbc:h2:mem:testdb;
same issue, tables are not created in h2. not able to find the issue, please suggest the way forward.
You can add this in the properties file
spring.datasource.url=jdbc:h2:mem:testdb spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true spring.h2.console.path=/h2
spring.jpa.show-sql=true spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto=update
The list of option which is used in the spring boot are
- validate: validate the schema, makes no changes to the database.
- update: update the schema.
- create: creates the schema, destroying previous data.
- create-drop: drop the schema at the end of the session
- none: is all other cases.
So for avoiding the data lose you use update
If H2 is run as a server separately (either in local or in remote) then the following property need to be set
spring.batch.jdbc.initialize-schema=always
for spring boot BatchDataSourceScriptDatabaseInitializer.java to create tables
Yup application is running fine but not connecting to h2-console. In the JDBC URL its showing jdbc:h2:~/test instead of jdbc:h2:mem:test. Please help