For the conditional drop table in derby you can use the following:
1. create this class in some package.
Code:
public class DerbyDropTable {
public static void dropTable(String schema, String table) {
try {
Connection conn = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement ps = conn.prepareStatement("drop table " + schema + "." + table);
ps.execute();
ps.close();
} catch (SQLException e) {
}
}
}
Make sure the class is on your classpath.
2. create a procedure in derby that call the created method: (should be created in your scripts before the drop calls are made)
Code:
create procedure DROP_TABLE
( schemaName varchar( 128 ), tableName varchar( 128 ) )
parameter style java
modifies sql data
language java
external name 'somepackage.DerbyDropTable.dropTable'
;
3. call the procedure for every table you want to drop:
Code:
call DROP_TABLE( 'SA', 'tablename' );
This works fine, it would be better if derby or spring had a way to shutdown the database, so i still will create the jira issue, but at least it offers a workaround.
cheers
Job de Noo