use of org.springframework.jdbc.datasource.init.DatabasePopulator in project leopard by tanhaichao.
the class DomainWhiteListConfigImpl method createTable.
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) {
}
}
Aggregations