Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute an SQL script for Derby DB from a ksh script

Tags:

unix

ksh

jdbc

derby

I am trying to write a small program that utilizes a sql script I wrote, to access data within a Derby DB (let's call it "myscript.sql") from within a ksh script.

I seem to be running into problems however since my ksh script can only launch the "ij" tool, and is not able to input any further commands in the ij shell once opened (thus, can not connect to the DB).

Is there any way that the ksh script can echo commands to the ij shell, so I can connect/execute my query as needed ?

like image 571
while-looper Avatar asked Apr 28 '26 21:04

while-looper


1 Answers

You can accomplish this by redirecting stdin to the ij tool and running it using java:

Name an input file as a command-line argument. For example:

java org.apache.derby.tools.ij myscript.sql

Redirect standard input to come from a file. For example:

java org.apache.derby.tools.ij < myscript.sql

Source: Derby documentation

like image 197
Andy Guibert Avatar answered May 02 '26 04:05

Andy Guibert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!