Attaching version 2 of the patch, which makes ij run with java/demo/toursdb as working directory (so that it finds the scripts invoked indirectly by loadTables.sql), and sets derby.system.home to make sure the database and derby.log ends up in the generated/toursdb directory.
The patch also changes the toursdb.insertMaps class so that its main() method shuts down the database cleanly before exiting. This removes the need for a new invocation of ij just to perform recovery and shut down the database after on, so the disconnect.sql script could be removed from the source tree.
The patch reduces the number of ij invocations from 9 to 1. Now that toursdb is actually built, it takes a little longer than with the previous patch, but I still see a 25 second speedup of "ant all" compared to a clean trunk.