本文整理汇总了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;
}
});
}