Last active
March 11, 2018 23:35
-
-
Save gitjs77/03f365db08dccf70a29cf8e203ecaae3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment