Wednesday, 14 November 2018

Apache Derby - It's almost like my first time

Back with Apache Derby, after quite a long while ( it was IBM Cloudscape back in the day, and it's a core part of a lot of IBM products ), I wanted to create a simple DB to test my Java Persistence Architecture (JPA) skills against.

Using these sources: -




mkdir ApacheDerby
cd ApacheDerby/
unzip -j ~/Downloads/db-derby-10.10.2.0-lib.zip "db-derby-10.10.2.0-lib/lib/derby.jar"

...
Archive:  /Users/davidhay/Downloads/db-derby-10.10.2.0-lib.zip
  inflating: derby.jar               

...

unzip -j ~/Downloads/db-derby-10.10.2.0-lib.zip "db-derby-10.10.2.0-lib/lib/derbytools.jar"

...

Archive:  /Users/davidhay/Downloads/db-derby-10.10.2.0-lib.zip
  inflating: derbytools.jar          


ls -al

...
total 5976
drwxr-xr-x   4 davidhay  staff      128 14 Nov 14:21 .
drwxr-xr-x+ 75 davidhay  staff     2400 14 Nov 14:09 ..
-rw-r--r--@  1 davidhay  staff  2838580 27 Mar  2014 derby.jar
-rw-r--r--@  1 davidhay  staff   214415 27 Mar  2014 derbytools.jar
...

java -cp derby.jar org.apache.derby.tools.sysinfo

...
------------------ Java Information ------------------
Java Version:    1.8.0_181
Java Vendor:     Oracle Corporation
Java home:       /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre
Java classpath:  derby.jar
OS name:         Mac OS X
OS architecture: x86_64
OS version:      10.14.1
Java user name:  davidhay
Java user home:  /Users/davidhay
Java user dir:   /Users/davidhay/ApacheDerby
java.specification.name: Java Platform API Specification
java.specification.version: 1.8
java.runtime.version: 1.8.0_181-b13
--------- Derby Information --------
[/Users/davidhay/ApacheDerby/derby.jar] 10.10.2.0 - (1582446)
------------------------------------------------------
----------------- Locale Information -----------------
------------------------------------------------------
------------------------------------------------------

...

java -cp derby.jar:derbytools.jar org.apache.derby.tools.ij

...
ij version 10.10
ij>

...

connect 'jdbc:derby:HelloWorld;create=true';
exit;

ls -al

...
total 5984
drwxr-xr-x   6 davidhay  staff      192 14 Nov 14:23 .
drwxr-xr-x+ 75 davidhay  staff     2400 14 Nov 14:09 ..
drwxr-xr-x   6 davidhay  staff      192 14 Nov 14:23 HelloWorld
-rw-r--r--@  1 davidhay  staff  2838580 27 Mar  2014 derby.jar
-rw-r--r--   1 davidhay  staff     1113 14 Nov 14:23 derby.log
-rw-r--r--@  1 davidhay  staff   214415 27 Mar  2014 derbytools.jar

...

java -cp derby.jar:derbytools.jar org.apache.derby.tools.ij

connect 'jdbc:derby:HelloWorld';

create table names(num int, name varchar(40));

...
0 rows inserted/updated/deleted
...

insert into names values (1,'Marge Simpson');

...
1 row inserted/updated/deleted
...

insert into names values (2,'Homer Simpson');

...
1 row inserted/updated/deleted
...

insert into names values (3,'Lisa Simpson');

...
1 row inserted/updated/deleted
...

insert into names values (4,'Maggie Simpson');

...
1 row inserted/updated/deleted
...

insert into names values (5,'Bart Simpson');

...
1 row inserted/updated/deleted
...

insert into names values (6,'Grandpa Simpson');

...
1 row inserted/updated/deleted
...

select * from names;

...
NUM        |NAME                                    
----------------------------------------------------
1          |Marge Simpson
2          |Homer Simpson
3          |Lisa Simpson
4          |Maggie Simpson
5          |Bart Simpson
6          |Grandpa Simpson

6 rows selected

...

exit;


No comments:

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...