I'm trying to create a Spring Boot project with H2 database, which would be accessible by other programs.
application.properties
spring.datasource.url = jdbc:h2:tcp://localhost:8084/~/./db/tech
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.initialization-mode=always
SpringBootMyApplication.java
@SpringBootApplication
public class SpringBootMyApplication{
public static void main(String[] args) {
SpringApplication.run(SpringBootMyApplication.class, args);
}
@Bean(initMethod = "start", destroyMethod = "stop")
public Server h2Server() throws SQLException {
return Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", "8084");
}
}
The exception is:
Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/onz03589/db/tech" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200]
How to actually "allow remote database creation"?
-tcpAllowOthers
, it effectively creates a remote security hole in your system. Do you really have a reason to enable remote access to your server? – Alderson