本文整理汇总了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) {
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
};
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例14: databasePopulator
import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
private DatabasePopulator databasePopulator() {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(schemaScript);
return populator;
}
示例15: databasePopulator
import org.springframework.jdbc.datasource.init.DatabasePopulator; //导入依赖的package包/类
@Bean
public DatabasePopulator databasePopulator() {
return null;
}