Néstor Boscán wrote:

I have an application that needs to autoinstall and autoupgrade without user
intervention. I wanted to know if I can put the scripts in a JAR file and
run a command in derby that will run it.

Include derbytools.jar in your classpath then use something like the following, where /sql/myscript.sql is the location of the SQL script in your JAR file:

String enc = System.getProperty("file.encoding");
InputStream sql = new BufferedInputStream(MyClass.class.getResourceAsStream("/sql/myscript.sql"));
if (ij.runScript(db, sql, enc, System.out, enc) != 0) {
    throw new Exception("Database script failed");
}
sql.close();

--
Alan Burlison
--

Reply via email to