Now, you will use the Derby??ij tool to load the Derby database engine. You will use the Derby embedded driver to create and connect to the firstdb database. You will also use a few basic SQL statements to create and populate a table.
ijOtherwise, you can use the java command to start the ij tool.
Operating System | Command |
---|---|
UNIX |
java -jar $DERBY_HOME/lib/derbyrun.jar ij ij version 10.7 |
Windows |
java -jar %DERBY_HOME%\lib\derbyrun.jar ij ij version 10.7 |
CONNECT 'jdbc:derby:firstdb;create=true';
CREATE TABLE FIRSTTABLE (ID INT PRIMARY KEY, NAME VARCHAR(12)); 0 rows inserted/updated/deleted
INSERT INTO FIRSTTABLE VALUES (10,'TEN'),(20,'TWENTY'),(30,'THIRTY'); 3 rows inserted/updated/deleted
SELECT * FROM FIRSTTABLE; ID |NAME ------------------------ 10 |TEN 20 |TWENTY 30 |THIRTY 3 rows selected
SELECT * FROM FIRSTTABLE WHERE ID=20; ID |NAME ------------------------ 20 |TWENTY 1 row selected
run 'ToursDB_schema.sql'; ij> ... CREATE TABLE AIRLINES ( AIRLINE CHAR(2) NOT NULL , AIRLINE_FULL VARCHAR(24), BASIC_RATE DOUBLE PRECISION, ... 0 rows inserted/updated/deleted ... Other output messages not shown ...
run 'loadTables.sql'; ij> run 'loadCOUNTRIES.sql'; ij> insert into COUNTRIES values ( 'Afghanistan','AF','Asia'); 1 row inserted/updated/deleted ij> insert into COUNTRIES values ( 'Albania','AL','Europe'); 1 row inserted/updated/deleted ... Other output messages not shown ...
exit;You should be returned to the DERBYTUTOR directory.
---------------------------------------------------------------- Thu Nov 04 15:43:01 EDT 2010: Booting Derby version The Apache Software Foundation - Apache Derby - 10.7.1.0 - (1031070): instance a816c00e-012c-1869-e1d2-000000bc30c8 on database directory C:\DERBYTUTOR\firstdb with class loader sun.misc.Launcher$AppClassLoader@7d772e Loaded from file:C:\db-derby-10.7.1.0-bin\lib\derby.jar java.vendor=Sun Microsystems Inc. java.runtime.version=1.6.0_21-b06 Database Class Loader started - derby.database.classpath='' ---------------------------------------------------------------- Thu Nov 04 15:43:40 EDT 2010: Shutting down Derby engine ---------------------------------------------------------------- Thu Nov 04 15:43:40 EDT 2010: Shutting down instance a816c00e-012c-1869-e1d2-000000bc30c8 on database directory C:\DERBYTUTOR\firstdb with class loader sun.misc.Launcher$AppClassLoader@7d772e ----------------------------------------------------------------