You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Néstor Boscán <ne...@tcsapp.com.ve> on 2007/09/02 09:29:38 UTC
How to run Scripts from JDBC?
Hi
Is it possible with Derby to run Scripts from JDBC?
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.
Regards,
Néstor Boscán
Re: How to run Scripts from JDBC?
Posted by Alan Burlison <Al...@sun.com>.
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
--
RE: How to run Scripts from JDBC?
Posted by Néstor Boscán <ne...@tcsapp.com.ve>.
Knut thanks a lot for the info.
Regards,
Néstor Boscán
-----Mensaje original-----
De: Knut.Hatlen@Sun.COM [mailto:Knut.Hatlen@Sun.COM]
Enviado el: Domingo, 02 de Septiembre de 2007 04:33 a.m.
Para: Derby Discussion
Asunto: Re: How to run Scripts from JDBC?
Néstor Boscán <ne...@tcsapp.com.ve> writes:
> Hi
>
> Is it possible with Derby to run Scripts from JDBC?
Yes, if you have derbytools.jar in the classpath you can use the method
runScript() in org.apache.derby.tools.ij. See
http://db.apache.org/derby/docs/10.3/publishedapi/jdbc4/org/apache/derby/too
ls/ij.html
for details.
--
Knut Anders
Re: How to run Scripts from JDBC?
Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Néstor Boscán <ne...@tcsapp.com.ve> writes:
> Hi
>
> Is it possible with Derby to run Scripts from JDBC?
Yes, if you have derbytools.jar in the classpath you can use the method
runScript() in org.apache.derby.tools.ij. See
http://db.apache.org/derby/docs/10.3/publishedapi/jdbc4/org/apache/derby/tools/ij.html
for details.
--
Knut Anders