How to use a h2 database java code example
Example 1: H2 enabling remote database creation first
//Try this in your application.properties. It worked for me:
spring.datasource.url=jdbc:h2:~/test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
Example 2: connecting to h2 database from java
Connection conn = DriverManager.getConnection ("jdbc:h2:~/test", "sa","");