当前位置: 首页>>代码示例>>Java>>正文


Java ResourceDatabasePopulator.setContinueOnError方法代码示例

本文整理汇总了Java中org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.setContinueOnError方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceDatabasePopulator.setContinueOnError方法的具体用法?Java ResourceDatabasePopulator.setContinueOnError怎么用?Java ResourceDatabasePopulator.setContinueOnError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jdbc.datasource.init.ResourceDatabasePopulator的用法示例。


在下文中一共展示了ResourceDatabasePopulator.setContinueOnError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@PostConstruct
protected void initialize() {
	if (this.properties.getInitializer().isEnabled()) {
		String platform = getDatabaseType();
		if ("hsql".equals(platform)) {
			platform = "hsqldb";
		}
		if ("postgres".equals(platform)) {
			platform = "postgresql";
		}
		if ("oracle".equals(platform)) {
			platform = "oracle10g";
		}
		ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
		String schemaLocation = this.properties.getSchema();
		schemaLocation = schemaLocation.replace("@@[email protected]@", platform);
		populator.addScript(this.resourceLoader.getResource(schemaLocation));
		populator.setContinueOnError(true);
		DatabasePopulatorUtils.execute(populator, this.dataSource);
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:22,代码来源:BatchDatabaseInitializer.java

示例2: runScripts

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
private void runScripts(List<Resource> resources, String username, String password) {
	if (resources.isEmpty()) {
		return;
	}
	ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
	populator.setContinueOnError(this.properties.isContinueOnError());
	populator.setSeparator(this.properties.getSeparator());
	if (this.properties.getSqlScriptEncoding() != null) {
		populator.setSqlScriptEncoding(this.properties.getSqlScriptEncoding().name());
	}
	for (Resource resource : resources) {
		populator.addScript(resource);
	}
	DataSource dataSource = this.dataSource;
	if (StringUtils.hasText(username) && StringUtils.hasText(password)) {
		dataSource = DataSourceBuilder.create(this.properties.getClassLoader())
				.driverClassName(this.properties.determineDriverClassName())
				.url(this.properties.determineUrl()).username(username)
				.password(password).build();
	}
	DatabasePopulatorUtils.execute(populator, dataSource);
}
 
开发者ID:muxiangqiu,项目名称:spring-boot-multidatasource,代码行数:23,代码来源:DataSourceInitializer.java

示例3: runScripts

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
private void runScripts(List<Resource> resources, DataSource dataSource) {
	if (resources.isEmpty()) {
		return;
	}
	ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
	populator.setContinueOnError(configuration.isContinueOnError());
	populator.setSeparator(configuration.getConfigPropertyValue(SpringDataSourceConfigProperties.SEPARATOR, ";"));
	String encoding = configuration.getConfigPropertyValue(SpringDataSourceConfigProperties.SQL_SCRIPT_ENCODING,
			null);
	if (encoding != null) {
		populator.setSqlScriptEncoding(encoding);
	}
	for (Resource resource : resources) {
		populator.addScript(resource);
	}
	DatabasePopulatorUtils.execute(populator, dataSource);
}
 
开发者ID:holon-platform,项目名称:holon-jdbc,代码行数:18,代码来源:DataContextDataSourceInitializer.java

示例4: build

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
public DataSource build() {
  DataSource dataSource;

  if (url == null || url.contains("hsqldb:mem")) {
    // Start an in-process, in-memory HSQL server
    dataSource = new EmbeddedDatabaseBuilder().setType(HSQL).setName("c2mondb").build();
  } else if (url.contains("hsql://")) {
    // Start an externally visible, file-based HSQL server
    HsqlServer.start("file:///tmp/c2mondb", "c2mondb");
    url += ";sql.syntax_ora=true;hsqldb.default_table_type=cached;hsqldb.cache_rows=1000;hsqldb.result_max_memory_rows=2000;hsqldb.cache_size=100";
    dataSource = DataSourceBuilder.create().url(url).username(username).password(password).build();

  } else {
    throw new RuntimeException("The given URL was not a valid HSQL JDBC URL!");
  }

  if (!scripts.isEmpty()) {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator(scripts.toArray(new Resource[scripts.size()]));
    populator.setContinueOnError(true);
    DatabasePopulatorUtils.execute(populator, dataSource);
  }

  return dataSource;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:25,代码来源:HsqlDatabaseBuilder.java

示例5: 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);
    }
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:18,代码来源:SpringTestBase.java

示例6: serverStartup

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@Override
public void serverStartup()
{
    LOG.info("Initializing MySQL DB for highlighter");
    try (Connection connection = DriverManager.getConnection(url, user, password))
    {
        final ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
        resourceDatabasePopulator.setContinueOnError(true);
        resourceDatabasePopulator.addScript(new FileSystemResource("../webapps/ROOT/plugins/highlighter-plugin/sql/mysql_init_db.sql"));
        resourceDatabasePopulator.addScript(new FileSystemResource("../webapps/ROOT/plugins/highlighter-plugin/sql/mysql_init_table.sql"));
        resourceDatabasePopulator.populate(connection);

        LOG.info("Initialization complete!");
    }
    catch (Exception e)
    {
        LOG.log(Level.SEVERE, "MySQL DB initialization failed for highlighter", e);
    }
}
 
开发者ID:jpfeffer,项目名称:teamcity-highlighter,代码行数:20,代码来源:MySQLDBAdapter.java

示例7: runScripts

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
private void runScripts(List<Resource> resources, String username, String password) {
    if (resources.isEmpty()) {
        return;
    }
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setContinueOnError(this.properties.isContinueOnError());
    populator.setSeparator(this.properties.getSeparator());
    if (this.properties.getSqlScriptEncoding() != null) {
        populator.setSqlScriptEncoding(this.properties.getSqlScriptEncoding().name());
    }
    for (Resource resource : resources) {
        populator.addScript(resource);
    }
    DataSource dataSource = this.dataSource;
    if (StringUtils.hasText(username) && StringUtils.hasText(password)) {
        dataSource = DataSourceBuilder.create(this.properties.getClassLoader())
                .driverClassName(this.properties.determineDriverClassName())
                .url(this.properties.determineUrl()).username(username)
                .password(password).build();
    }
    DatabasePopulatorUtils.execute(populator, dataSource);
}
 
开发者ID:drtrang,项目名称:druid-spring-boot,代码行数:23,代码来源:DruidDataSourceInitializer.java

示例8: 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;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:14,代码来源:H2Config.java

示例9: 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;
}
 
开发者ID:vadivelmurugesan,项目名称:spring-batch-admin,代码行数:9,代码来源:DataSourceConfig.java

示例10: afterPropertiesSet

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
	if (dataSource != null && definitionInitializationEnable) {
		String platform = getDatabaseType(dataSource);
		if ("hsql".equals(platform)) {
			platform = "hsqldb";
		}
		if ("postgres".equals(platform)) {
			platform = "postgresql";
		}
		if ("oracle".equals(platform)) {
			platform = "oracle10g";
		}
		ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
		String schemaLocation = schema;
		schemaLocation = schemaLocation.replace("@@[email protected]@", platform);
		String commonSchemaLocation = schemaLocation;
		commonSchemaLocation = commonSchemaLocation.replace("@@[email protected]@", COMMON_SCHEMA_SUFFIX);
		logger.info(String.format("Adding dataflow schema %s for %s database", commonSchemaLocation,
				platform));
		populator.addScript(resourceLoader.getResource(commonSchemaLocation));

		String applicationssSchemaLocation = schemaLocation;
		applicationssSchemaLocation = applicationssSchemaLocation.replace("@@[email protected]@", APPLICATIONS_SCHEMA_SUFFIX);
		logger.info(String.format("Adding dataflow schema %s for %s database", applicationssSchemaLocation,
				platform));
		populator.addScript(resourceLoader.getResource(applicationssSchemaLocation));

		String deploymentSchemaLocation = schemaLocation;
		deploymentSchemaLocation = deploymentSchemaLocation.replace("@@[email protected]@", DEPLOYMENT_SCHEMA_SUFFIX);
		logger.info(String.format("Adding dataflow schema %s for %s database", deploymentSchemaLocation,
				platform));
		populator.addScript(resourceLoader.getResource(deploymentSchemaLocation));

		populator.setContinueOnError(true);
		logger.debug(String.format("Initializing dataflow schema for %s database", platform));
		DatabasePopulatorUtils.execute(populator, dataSource);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:40,代码来源:DataflowRdbmsInitializer.java

示例11: createDatabasePopulator

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
private DatabasePopulator createDatabasePopulator() {
	ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
	databasePopulator.setContinueOnError(true);
	// populate the database with required tables
	databasePopulator.addScript(new ClassPathResource("schema.sql"));
	return databasePopulator;
}
 
开发者ID:Itema-as,项目名称:dawn-marketplace-server,代码行数:8,代码来源:DatabaseConfiguration.java

示例12: initialize

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@PostConstruct
protected void initialize() {
	if (this.properties.getJdbc().getInitializer().isEnabled()) {
		ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
		String schemaLocation = this.properties.getJdbc().getSchema();
		schemaLocation = schemaLocation.replace("@@[email protected]@", getPlatform());
		populator.addScript(this.resourceLoader.getResource(schemaLocation));
		populator.setContinueOnError(true);
		DatabasePopulatorUtils.execute(populator, this.dataSource);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:JdbcSessionDatabaseInitializer.java

示例13: runScripts

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
private void runScripts(List<Resource> resources) {
	if (resources.isEmpty()) {
		return;
	}
	ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
	populator.setContinueOnError(this.properties.isContinueOnError());
	populator.setSeparator(this.properties.getSeparator());
	if (this.properties.getSqlScriptEncoding() != null) {
		populator.setSqlScriptEncoding(this.properties.getSqlScriptEncoding().name());
	}
	for (Resource resource : resources) {
		populator.addScript(resource);
	}
	DatabasePopulatorUtils.execute(populator, this.dataSource);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:16,代码来源:DataSourceInitializer.java

示例14: afterPropertiesSet

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
	if (dataSource != null &&
			taskInitializationEnable &&
			!StringUtils.hasText(this.tablePrefix)) {
		String platform = getDatabaseType(dataSource);
		if ("hsql".equals(platform)) {
			platform = "hsqldb";
		}
		if ("postgres".equals(platform)) {
			platform = "postgresql";
		}
		if ("oracle".equals(platform)) {
			platform = "oracle10g";
		}
		if ("mysql".equals(platform)) {
			platform = "mysql";
		}
		if ("sqlserver".equals(platform)){
			platform = "sqlserver";
		}
		ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
		String schemaLocation = schema;
		schemaLocation = schemaLocation.replace("@@[email protected]@", platform);
		populator.addScript(resourceLoader.getResource(schemaLocation));
		populator.setContinueOnError(true);
		logger.debug(String.format("Initializing task schema for %s database",
				platform));
		DatabasePopulatorUtils.execute(populator, dataSource);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-task,代码行数:32,代码来源:TaskRepositoryInitializer.java

示例15: initialize

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@PostConstruct
public void initialize(){
	ResourceDatabasePopulator populator=new ResourceDatabasePopulator();
	populator.setContinueOnError(true);
	populator.addScript(resourceLoader.getResource("classpath:/org/springframework/batch/core/schema-h2.sql"));
	
	DatabasePopulatorUtils.execute(populator, dataSource);
}
 
开发者ID:hantsy,项目名称:spring4-sandbox,代码行数:9,代码来源:JobConfig.java


注:本文中的org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.setContinueOnError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。