本文整理匯總了Java中org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.setIgnoreFailedDrops方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceDatabasePopulator.setIgnoreFailedDrops方法的具體用法?Java ResourceDatabasePopulator.setIgnoreFailedDrops怎麽用?Java ResourceDatabasePopulator.setIgnoreFailedDrops使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
的用法示例。
在下文中一共展示了ResourceDatabasePopulator.setIgnoreFailedDrops方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nonBootDataSourceInitializer
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
@ConditionalOnProperty("pgcopy.initialize")
@Bean
public DataSourceInitializer nonBootDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
databasePopulator.setIgnoreFailedDrops(true);
dataSourceInitializer.setDatabasePopulator(databasePopulator);
if ("true".equals(properties.getInitialize())) {
databasePopulator.addScript(new DefaultInitializationScriptResource(properties.getTableName(),
properties.getColumns()));
} else {
databasePopulator.addScript(resourceLoader.getResource(properties.getInitialize()));
}
return dataSourceInitializer;
}
示例2: nonBootDataSourceInitializer
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
@ConditionalOnProperty("jdbc.initialize")
@Bean
public DataSourceInitializer nonBootDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
databasePopulator.setIgnoreFailedDrops(true);
dataSourceInitializer.setDatabasePopulator(databasePopulator);
if ("true".equals(properties.getInitialize())) {
databasePopulator.addScript(new DefaultInitializationScriptResource(properties.getTableName(),
properties.getColumnsMap().keySet()));
}
else {
databasePopulator.addScript(resourceLoader.getResource(properties.getInitialize()));
}
return dataSourceInitializer;
}
示例3: executeSql
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
protected void executeSql(String path) {
logger.info("executeSql : " + path);
Resource resource = new ClassPathResource(path, getClass());
ResourceDatabasePopulator rdp = new ResourceDatabasePopulator();
rdp.addScript(resource);
rdp.setSqlScriptEncoding("UTF-8");
rdp.setIgnoreFailedDrops(true);
rdp.setContinueOnError(false);
try (Connection conn = DataSourceUtils.getConnection(dataSource)) {
rdp.populate(conn);
}
catch (Exception e) {
throw new IllegalStateException("executeSql failed, path=" + path, e);
}
}
示例4: databasePopulator
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
@Bean
public DatabasePopulator databasePopulator(DataSource dataSource) {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.setContinueOnError(true);
populator.setIgnoreFailedDrops(true);
populator.addScripts(new ClassPathResource("/db/h2schema.sql"),
new ClassPathResource("/db/h2data.sql"));
try {
populator.populate(dataSource.getConnection());
} catch (SQLException ignored) {
}
return populator;
}
示例5: databasePopulator
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
private DatabasePopulator databasePopulator() {
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.setIgnoreFailedDrops(true);
populator.setContinueOnError(true);
populator.addScript(dropScript);
populator.addScript(schemaScript);
return populator;
}
示例6: nonBootDataSourceInitializer
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
@ConditionalOnProperty("jdbc.initialize")
@Bean
public DataSourceInitializer nonBootDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
dataSourceInitializer.setDataSource(dataSource);
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
databasePopulator.setIgnoreFailedDrops(true);
dataSourceInitializer.setDatabasePopulator(databasePopulator);
if ("true".equals(properties.getInitialize())) {
databasePopulator.addScript(new DefaultInitializationScriptResource(properties));
} else {
databasePopulator.addScript(resourceLoader.getResource(properties.getInitialize()));
}
return dataSourceInitializer;
}
示例7: createResourceDatabasePopulator
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
protected ResourceDatabasePopulator createResourceDatabasePopulator() {
ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
resourceDatabasePopulator.setCommentPrefix(getCommentPrefix());
resourceDatabasePopulator.setContinueOnError(isContinueOnError());
resourceDatabasePopulator.setIgnoreFailedDrops(isIgnoreFailedDrops());
resourceDatabasePopulator.setSqlScriptEncoding(getSqlScriptEncoding());
return resourceDatabasePopulator;
}
示例8: prepareDatabase
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
private void prepareDatabase() {
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(new ClassPathResource("prepare-database.sql"));
populator.setIgnoreFailedDrops(true);
TransactionTemplate trxTemplate = new TransactionTemplate(transactionManager());
trxTemplate.execute(new TransactionCallback<Void>() {
@Override
public Void doInTransaction(TransactionStatus status) {
DatabasePopulatorUtils.execute(populator, DatabaseConfiguration.this.dataSource);
return null;
}
});
}