Ejemplo n.º 1
0
 private void loadConfig() {
   dataSource = new MysqlDataSource();
   dataSource.setServerName(configFile.getDatabaseName());
   dataSource.setUser(configFile.getDatabaseUser());
   dataSource.setPassword(configFile.getDatabasePassword());
   this.jdbcTemplate = new JdbcTemplate(dataSource);
 }
Ejemplo n.º 2
0
  /** Imports data into database by executing the sql datadump script */
  private void importData() {
    context = new AnnotationConfigApplicationContext(SpringConf.class);

    CustomResourceLoader customResourceLoader =
        (CustomResourceLoader) context.getBean("customResourceLoader");

    try {
      Resource query = customResourceLoader.getDataDumpResource(configFile.getDatadumpPath());
      ScriptUtils.executeSqlScript(dataSource.getConnection(), query);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ScriptException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }