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


Java DatabasePopulator类代码示例

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


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

示例1: createTable

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
protected void createTable() {
	StringBuilder sb = new StringBuilder();
	sb.append("CREATE TABLE  if not exists `leopard_domainwhitelist` (");
	sb.append("`domain` varchar(50) NOT NULL DEFAULT '',");
	sb.append("`username` varchar(50) NOT NULL DEFAULT '',");
	sb.append("`posttime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',");
	sb.append("`comment` varchar(255) NOT NULL DEFAULT '',");
	sb.append("PRIMARY KEY (`domain`)");
	sb.append(");");
	String sql = sb.toString();

	Resource scripts = new ByteArrayResource(sql.getBytes());
	DatabasePopulator populator = new ResourceDatabasePopulator(scripts);
	try {
		DatabasePopulatorUtils.execute(populator, jdbcTemplate.getDataSource());
	}
	catch (ScriptStatementFailedException e) {

	}
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:21,代码来源:DomainWhiteListConfigImpl.java

示例2: hiveInitializer

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
@Bean
DataSourceInitializer hiveInitializer(final DataSource dataSource) {
	final String ddl = "create external table if not exists tweetdata (value STRING) LOCATION '" + input + "'";
	final DataSourceInitializer dsi = new DataSourceInitializer();
    dsi.setDataSource(dataSource);
	dsi.setDatabasePopulator(new DatabasePopulator() {
		@Override
		public void populate(Connection conn) throws SQLException,
				ScriptException {
			Statement st = conn.createStatement();
			st.execute(ddl);
			st.close();
		}
	});
	return dsi;
}
 
开发者ID:SpringOne2GX-2014,项目名称:Intro-to-Spring-Hadoop,代码行数:17,代码来源:Application.java

示例3: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的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

示例4: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的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

示例5: createDatabasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的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

示例6: dataPopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
@Bean
public InitializingBean dataPopulator(final DataSource dataSource) {
	return () -> {
		final DatabasePopulator populator = new ResourceDatabasePopulator(new ClassPathResource("data.sql"));
		DatabasePopulatorUtils.execute(populator, dataSource);
	};
}
 
开发者ID:tuxdevelop,项目名称:spring-data-repositories,代码行数:8,代码来源:PersistenceConfiguration.java

示例7: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
@Bean
DatabasePopulator databasePopulator(DataSource dataSource) throws SQLException, InterruptedException {
	DatabasePopulator dbp = new ResourceDatabasePopulator(false, false, "UTF-8",
			new ClassPathResource("sqoop-test-schema-ddl.sql"),
			new ClassPathResource("sqoop-test-data.sql"));
	dbp.populate(DataSourceUtils.getConnection(dataSource));
	return dbp;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-task-modules,代码行数:9,代码来源:SqoopToolTaskApplicationTests.java

示例8: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
@Bean
DatabasePopulator databasePopulator(DataSource dataSource) throws SQLException, InterruptedException {
	DatabasePopulator dbp = new ResourceDatabasePopulator(false, false, "UTF-8",
			new ClassPathResource("sqoop-schema-ddl.sql"),
			new ClassPathResource("sqoop-root-data.sql"),
			new ClassPathResource("sqoop-sessions-data.sql"),
			new ClassPathResource("sqoop-test-schema-ddl.sql"),
			new ClassPathResource("sqoop-test-data.sql"));
	dbp.populate(DataSourceUtils.getConnection(dataSource));
	return dbp;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-task-modules,代码行数:12,代码来源:SqoopToolJobApplicationTests.java

示例9: dataSourcePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
private DatabasePopulator dataSourcePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setScripts(
            new ClassPathResource(dropScript),
            new ClassPathResource(schemaScript)
    );
    return databasePopulator;
}
 
开发者ID:cegeka,项目名称:batchers,代码行数:9,代码来源:TempConfigToInitDB.java

示例10: dataSourcePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
private DatabasePopulator dataSourcePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setScripts(
            new ClassPathResource("org/springframework/batch/core/schema-drop-hsqldb.sql"),
            new ClassPathResource("org/springframework/batch/core/schema-hsqldb.sql")
    );
    return databasePopulator;
}
 
开发者ID:cegeka,项目名称:batchers,代码行数:9,代码来源:EmployeeJobTestConfig.java

示例11: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
private DatabasePopulator databasePopulator() {
	ResourceDatabasePopulator populator = new ResourceDatabasePopulator();		
	populator.addScript(new ClassPathResource("Account.sql", JdbcAccountRepository.class));
	populator.addScript(new ClassPathResource("data.sql", JdbcAccountRepository.class));
	populator.addScript(new ClassPathResource("rememberme.sql", JdbcAccountRepository.class));
	return populator;
}
 
开发者ID:markoradinovic,项目名称:Vaadin4Spring-MVP-Sample-SpringSecurity,代码行数:8,代码来源:Application.java

示例12: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
private DatabasePopulator databasePopulator() {
	ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
	populator.addScript(new ClassPathResource("JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
	populator.addScript(new ClassPathResource("Account.sql", JdbcAccountRepository.class));
	populator.addScript(new ClassPathResource("data.sql", JdbcAccountRepository.class));
	return populator;
}
 
开发者ID:markoradinovic,项目名称:Vaadin4Spring-MVP-Sample-SpringSecuritySocial,代码行数:8,代码来源:Application.java

示例13: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的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

示例14: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    return populator;
}
 
开发者ID:rhawan,项目名称:microservices-tcc-alfa,代码行数:6,代码来源:AuthorizationServerConfiguration.java

示例15: databasePopulator

import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
@Bean
public DatabasePopulator databasePopulator() {
    return null;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:5,代码来源:MySqlConfig.java


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