Manjula G Kutty wrote:
> You can write all your SQL statements in a sql file and just pass that
> sql file name as a string in your application. I think your application
> is in java, then you can pass the file name like this
>
> org.apache.derby.tools.ij.main(new String[ ] {"-fr", "schema.sql"});
One clarification, the -fr flag gets the file as a resource, thus the
file must be in the classpath, e.g. as an entry in the jar of your
application. If you put the file in a top-level scripts directory then
the correct name would be
/scripts/schema.sql
or if you put it in a package hierarchy then the name would be something
like
/com/acme/myapp/scripts/schema.sql
One minor issue with this is that, at least in embedded mode, ij will
shut Derby down once the script is complete. This is not a huge problem
since the engine is easily started by creating an instances of the JDBC
driver again. It would be nice to add a command line option here to
defeat the shutting down, or maybe a specific method on ij that took ran
a script given an existing connection.
Dan.