Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Bean(name = "jdbcTemplateForFileH2DataBaseInRealisation")
- public JdbcTemplate buildTemplate() throws SQLException, IOException {
- try {
- // For server with classpath: WEB-INF/classes/init_db2
- RunScript.execute(dataSource.getConnection(), new FileReader(new ClassPathResource("init_db2").getFile()));
- } catch (final IOException e) {
- LOGGER.error("new ClassPathResource(\"init_db2\").getFile() NOT FOUND. USING CONFIGURATION FOR LOCAL MACHINE." , e);
- // For local machine with resource: ./src/main/resources/init_db2
- RunScript.execute(dataSource.getConnection(), new FileReader("./src/main/resources/init_db2"));
- }
- return new JdbcTemplate(dataSource);
- }
Add Comment
Please, Sign In to add comment