use of org.springframework.jdbc.datasource.init.ScriptStatementFailedException in project spring-framework by spring-projects.
the class EmbeddedDatabaseBuilderTests method createSameSchemaTwiceWithoutUniqueDbNames.
@Test
public void createSameSchemaTwiceWithoutUniqueDbNames() throws Exception {
EmbeddedDatabase db1 = //
new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())).addScripts("db-schema-without-dropping.sql").build();
try {
//
new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())).addScripts("db-schema-without-dropping.sql").build();
fail("Should have thrown a ScriptStatementFailedException");
} catch (ScriptStatementFailedException e) {
// expected
} finally {
db1.shutdown();
}
}
use of org.springframework.jdbc.datasource.init.ScriptStatementFailedException 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