November 2016
Intermediate to advanced
944 pages
21h 1m
English
For prototyping and test environments, it is a good idea to use Java-based embedded databases to quickly start up the project and configure easily. They are lightweight and easily testable. Spring supports the HSQL, H2, and Derby database engines for that purpose natively. Here is a sample DataSource configuration for an embedded HSQL database:
@Bean
DataSource getHsqlDatasource() {
return new
EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL)
.addScript("db-scripts/hsql/db-schema.sql")
.addScript("db-scripts/hsql/data.sql")
.addScript("db-scripts/hsql/storedprocs.sql")
.addScript("db-scripts/hsql/functions.sql")
.setSeparator("/").build();
}The XML version of this would look like the following code:
<jdbc:embedded-database ...
Read now
Unlock full access