Guest User

Untitled

a guest
Mar 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. @Bean(name = "jdbcTemplateForFileH2DataBaseInRealisation")
  2. public JdbcTemplate buildTemplate() throws SQLException, IOException {
  3. try {
  4. // For server with classpath: WEB-INF/classes/init_db2
  5. RunScript.execute(dataSource.getConnection(), new FileReader(new ClassPathResource("init_db2").getFile()));
  6. } catch (final IOException e) {
  7. LOGGER.error("new ClassPathResource(\"init_db2\").getFile() NOT FOUND. USING CONFIGURATION FOR LOCAL MACHINE." , e);
  8. // For local machine with resource: ./src/main/resources/init_db2
  9. RunScript.execute(dataSource.getConnection(), new FileReader("./src/main/resources/init_db2"));
  10. }
  11.  
  12. return new JdbcTemplate(dataSource);
  13. }
Add Comment
Please, Sign In to add comment