spring-batch-example-1 icon indicating copy to clipboard operation
spring-batch-example-1 copied to clipboard

Not creating tables in h2

Open anujvictor opened this issue 6 years ago • 5 comments

application is running fine but not creating tables in the h2 dev tools. please help

anujvictor avatar Mar 05 '19 11:03 anujvictor

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;

Okwori avatar Jun 10 '19 06:06 Okwori

same issue, tables are not created in h2. not able to find the issue, please suggest the way forward.

HasmithaSaravanan avatar Jul 23 '20 12:07 HasmithaSaravanan

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

pathus90 avatar Aug 19 '20 10:08 pathus90

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

srchaitanya avatar Jul 29 '22 05:07 srchaitanya

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

Aafaquegit avatar Jan 26 '24 08:01 Aafaquegit