1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
//working path is /tmp/derby cd /tmp/derby //Download Derby - xxxxx-bin.tar.gz //http://db.apache.org/derby/derby_downloads.html //Unzip Derby //tar xzvf xxxxx-bin.tar.gz //Set DERBY_INSTALL export DERBY_INSTALL=/tmp/derby/xxxxx-bin //Configure Embedded Derby export CLASSPATH=$DERBY_INSTALL/lib/derby.jar:$DERBY_INSTALL/lib/derbytools.jar:. cd $DERBY_INSTALL/bin //***Next time, When want to run ij need run below first export DERBY_HOME=/tmp/derby/xxxxx-bin . setEmbeddedCP //Verify Derby java org.apache.derby.tools.sysinfo //Run Derby & Open new terminal run this command then back the previous screen java -jar /tmp/derby/xxxxx-bin/lib/derbyrun.jar server start //Enter Derby cd /tmp/derby/xxxxx-bin/bin java org.apache.derby.tools.ij //Connect DB ij> connect 'jdbc:derby://localhost:1527/new;create=true;user=root;password=root'; //Execute SQL statements ij> create table derbyDB(num int, addr varchar(40)); ij> insert into derbyDB values (1956,'Webster St.'); ij> insert into derbyDB values (1910,'Union St.'); ij> update derbyDB set num=180, addr='Grand Ave.' where num=1956; ij> select * from derbyDb; //Run SQL Scripts // /tmp/derby/xxxxx-bin/bin/my_file.sql ij> run 'my_file.sql'; //Disconnect DB ij> disconnect; //Exit ij> exit; //Tips: //想起teminal run java 指返落Driver,記住意下STEP: // export DERBY_HOME=/tmp/derby/xxxxx-bin // /tmp/derby/xxxxx-bin/setEmbeddedCP // export CLASSPATH=$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar:. // Run! |