Setting up APACHE DERBY DB
(1) Create user myderby
# useradd -m -c "Derby Admin" myderby
# passwd myderby
Password: password
(2) Install Java
# yum install java-1.8.0-openjdk -y
(3) Download Derby file
https://db.apache.org/derby/releases/release-10.14.2.0.cgi
# mkdir /opt/derbydata
# chown myderby:myderby /opt/derbydata
# useradd -m -c "Derby Admin" myderby
# passwd myderby
Password: password
(2) Install Java
# yum install java-1.8.0-openjdk -y
(3) Download Derby file
https://db.apache.org/derby/releases/release-10.14.2.0.cgi
# mkdir /opt/derbydata
# chown myderby:myderby /opt/derbydata
# su - myderby
$ cd /opt/derbydata
$ tar -zxvf db-derby-10.14.2.0-bin.tar.gz
$ mv db-derby-10.14.2.0-bin /opt/
(4) Setup home path
$ mv db-derby-10.14.2.0-bin /opt/
(4) Setup home path
$ vi /home/myderby/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64/jre
export DERBY_HOME=/opt/db-derby-10.14.2.0-bin
export PATH=$JAVA_HOME/bin:$DERBY_HOME/bin:$PATH
(5) Create Derby DB & Table
$ java -jar /opt/db-derby-10.14.2.0-bin/lib/derbyrun.jar ij
ij> connect 'jdbc:derby:/opt/derbydata/dbphone;create=true';
ij> create table tphone (id int primary key, name varchar(15), phone varchar(10));
ij> insert into tphone values (1,'Romeo','0193830000');
ij> insert into tphone values (2,'Juliet','0123490000');
ij> select * from tphone;
ID |NAME |PHONE
--------------------------------------
1 |Romeo |0193830000
2 |Juliet |0123490000
2 rows selected
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64/jre
export DERBY_HOME=/opt/db-derby-10.14.2.0-bin
export PATH=$JAVA_HOME/bin:$DERBY_HOME/bin:$PATH
(5) Create Derby DB & Table
$ java -jar /opt/db-derby-10.14.2.0-bin/lib/derbyrun.jar ij
ij> connect 'jdbc:derby:/opt/derbydata/dbphone;create=true';
ij> create table tphone (id int primary key, name varchar(15), phone varchar(10));
ij> insert into tphone values (1,'Romeo','0193830000');
ij> insert into tphone values (2,'Juliet','0123490000');
ij> select * from tphone;
ID |NAME |PHONE
--------------------------------------
1 |Romeo |0193830000
2 |Juliet |0123490000
2 rows selected
(6) Start DB Derby to listen to port 1527
# /opt/db-derby-10.14.2.0-bin/bin/startNetworkServer -h 0.0.0.0 &
Thu Nov 23 20:19:49 MYT 2017 : Apache Derby Network Server - 10.14.1.0 - (1808820) started and ready to accept connections on port 1527
# netstat -an|grep 1527
tcp6 0 0 0.0.0.0:1527 :::* LISTEN
(7) Connect to Derby from your application
DB Type: Derby
DB Name: /opt/derbydata/dbphone
DB Host/IP: <server ip>
Port no: 1527
Username: myderby
Password: password
0 Comments:
Post a Comment
<< Home