Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not creating tables in h2 #4

Open
anujvictor opened this issue Mar 5, 2019 · 5 comments
Open

Not creating tables in h2 #4

anujvictor opened this issue Mar 5, 2019 · 5 comments

Comments

@anujvictor
Copy link

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

@Okwori
Copy link

Okwori commented Jun 10, 2019

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;

@HasmithaSaravanan
Copy link

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

@pathus90
Copy link

pathus90 commented Aug 19, 2020

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

@srchaitanya
Copy link

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

@Aafaquegit
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants