當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceDatabasePopulator.setSqlScriptEncoding方法代碼示例

本文整理匯總了Java中org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.setSqlScriptEncoding方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceDatabasePopulator.setSqlScriptEncoding方法的具體用法?Java ResourceDatabasePopulator.setSqlScriptEncoding怎麽用?Java ResourceDatabasePopulator.setSqlScriptEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.jdbc.datasource.init.ResourceDatabasePopulator的用法示例。


在下文中一共展示了ResourceDatabasePopulator.setSqlScriptEncoding方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例4: contextInitialized

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
@Override
public void contextInitialized(final ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);

    try {
        Server h2TestDb = new Server();
        h2TestDb.runTool("-tcp", "-tcpDaemon", "-web", "-webDaemon",
                "-webPort", ctx.getBean("testdb.webport", String.class));

        context.setAttribute(H2_TESTDB, h2TestDb);
    } catch (SQLException e) {
        LOG.error("Could not start H2 test db", e);
    }

    DataSource datasource = ctx.getBean(DataSource.class);

    ResourceDatabasePopulator populator = new ResourceDatabasePopulator(ctx.getResource("classpath:/testdb.sql"));
    populator.setSqlScriptEncoding("UTF-8");
    DataSourceInitializer init = new DataSourceInitializer();
    init.setDataSource(datasource);
    init.setEnabled(true);
    init.setDatabasePopulator(populator);
    init.afterPropertiesSet();
    LOG.info("Database successfully initialized");
}
 
開發者ID:apache,項目名稱:syncope,代碼行數:27,代碼來源:H2StartStopListener.java

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

示例6: databasePopulator

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
protected ResourceDatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setSqlScriptEncoding(StandardCharsets.UTF_8.name());
    populator.addScript(drops);
    populator.addScript(sqlCreateTablesForm);
    populator.addScript(sqlCreateTables);
    populator.addScript(sqlCreateTablesActor);
    populator.addScript(sqlCreateSequencesServer);
    populator.addScript(sqlCreateSequencesForm);
    populator.addScript(sqlCreateConstraints);
    populator.addScript(sqlCreateConstraintsForm);
    populator.addScript(insertSingularData);
    return populator;
}
 
開發者ID:opensingular,項目名稱:singular-server,代碼行數:15,代碼來源:SingularDefaultPersistenceConfiguration.java

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

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

示例9: 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;
}
 
開發者ID:vladmihalcea,項目名稱:vladmihalcea.wordpress.com,代碼行數:9,代碼來源:DatabaseScriptLifecycleHandler.java

示例10: databasePopulator

import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; //導入方法依賴的package包/類
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setSqlScriptEncoding("utf-8");
    populator.addScript(dataScript);
    return populator;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:7,代碼來源:DatabaseConfiguration.java


注:本文中的org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.setSqlScriptEncoding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。