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


Java ResourceDatabasePopulator.setSeparator方法代码示例

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


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

示例1: 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

示例2: 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

示例3: applyScripts

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
private void applyScripts(String url) throws SQLException, IOException {
    log.info("Apply Scripts ...");
    Connection connection = getConnection(url);
    DataSource ds = new SingleConnectionDataSource(connection, false);
    FileSystemScanner scanner = new FileSystemScanner();
    for (String location : builder.locations) {
        File directory = new File(location);
        if (directory.exists() && directory.isDirectory()) {
            Resource[] resources = scanner.scanForResources(location, "", ".sql");
            ResourceDatabasePopulator populator = new ResourceDatabasePopulator(resources);
            populator.setSeparator(builder.separator);
            populator.execute(ds);
        } else {
            // log not existing directory
        }
    }
    log.info("Scripts applied!");
}
 
开发者ID:zalando-stups,项目名称:booties,代码行数:19,代码来源:PostgreSqlRule.java

示例4: 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

示例5: createFunctionInitializer

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //导入方法依赖的package包/类
@Bean
@DependsOn("scriptsInitializer")
public DataSourceInitializer createFunctionInitializer(final DataSource dataSource) {
    final DataSourceInitializer initializer = new DataSourceInitializer();
    initializer.setDataSource(dataSource);
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setSeparator("#");
    populator.setSqlScriptEncoding(StandardCharsets.UTF_8.name());
    populator.addScript(sqlCreateFunction);
    initializer.setDatabasePopulator(populator);
    initializer.setEnabled(isDatabaseInitializerEnabled());
    return initializer;
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:14,代码来源:SingularDefaultPersistenceConfiguration.java

示例6: 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


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