Just to provide an example, IJ has the following RUN command to run sql files.

C:\p4clients\sat_52>java -Dij.protocol=jdbc:derby: org.apache.derby.tools.ij
ij version 10.1
ij> run 'test.sql';
ij> connect 'jdbc:derby:tdb;create=true';
ij> create table t (i int, j int, c char(10));
0 rows inserted/updated/deleted
ij> insert into t values (1, 1, 'satheesh'), (2,2, 'bandaram');
2 rows inserted/updated/deleted

Type help; in IJ to see all other options.

Satheesh

Jeremy Boynes wrote:
Ruta Kadhe wrote:
Hi,
Consider Derby in embeded mode.
When database is to be created in embeded mode, is their any support
in Derby to run .sql file which has Database Creation scripts?


You can use ij to execute SQL scripts (although you may tweak the syntax e.g. for statement delimiters if you are porting from another database).

You can also use the <sql> Ant task to execute scripts during a build.

In both cases you would not start your application but use the embedded driver from ij/ant to create it directly; once created, you can run the application normally.

The resulting database is portable between servers (and encryptable) so you may not need to run scripts in a target environment.

--
Jeremy


Reply via email to