The in memory database in spring boot configuration is working fine, with below code. But the url is not picking up from from YAML configuration. though the h2 console is enabled
In log the url is printing as memory db.
- how can i change the jdbc url from memory to file.
Log File
2020-09-03 14:22:42.595 [RMI TCP Connection(2)-10.44.33.51] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
2020-09-03 14:22:42.595 [RMI TCP Connection(2)-10.44.33.51] DEBUG o.s.j.d.SimpleDriverDataSource - Creating new JDBC Driver Connection to [jdbc:h2:mem:testdb;MODE=Oracle;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false]
@Configuration
public class DataSourceConfiguration {
@Bean
@Primary
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.setName("testdb;MODE=Oracle")
.addScript("classpath:sql/Create-table.sql")
.build();
}
}
YAML Configuration
spring:
h2:
console:
enabled: true
path: /h2
datasource:
url: jdbc:h2:file:C:/db/test
username: test
password: password
driverClassName: org.h2.Driver