2 Şubat 2021 Salı

SpringData Jdbc ResourceDatabasePopulator Sınıfı

Giriş
Şu satırı dahil ederiz
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
execute metodu
Örnek
Şöyle yaparız
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources(ExecuteSqlScriptRunner.BASE_SCRIPT_FOLDER +
dirName + "/*.sql");

public void executeScript(Resource script) {
  ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(script);
  boolean success = true;
  String error = null;
  try {
    databasePopulator.execute(this.dataSource);
  } catch (ScriptException e) {
    ...
  }
 }

Hiç yorum yok:

Yorum Gönder