Apache Derby
From Fukudat
- Apache Derby is an implementation of Relational Database Management System (RDBMS) purely written in Java.
- It is distributed under Apache License, Version 2.0.
- Since it is fully written in Java, it runs on almost every platform that Java supports.
- Plug-ins for an Integrated Development Environment (IDE) Eclipse is provided.
Contents |
[edit]
History
- In 1997, Cloudscape Inc. released a Java database engine called JBMS. The product was renamed as Claudscape.
- In 1999, Informix Software acquired Cloudscape Inc.
- In 2001, IBM acquired the database assets of Informix Software. The rest of assets owned by Informix Software were succeeded by Ascential Software Corporation, which was also acquired by IBM in 2005.
- In 2004 IBM contributed the code to the Apache Software Foundation as Derby.
[edit]
How to Install
This page discribes how to install Apache Derby on a standard PC running Windows or Linux operating system. We will need the following software installed already on the target PC.
- Java JDK
- Eclipse
- Apache Derby
[edit]
Java DK
- SUN Developer Network からプラットフォームにあった J2SEのパッケージを入手。
- NetBeans は使用しないので、NetBeans なしのパッケージでよい。
- J2SE 1.4.x でも J2SE 5.0 (1.5.x) でもどちらでもよい。
- Windows の場合、 j2sdk-1_4_*-windows-i568-p.exe または jdk-1_5_*-windows-i568-p.exe
- Linux の場合 j2sdk-1_4_*-linux-i586-rpm.bin または jdk-1_5_*-linux-i586-rpm.bin。
- ただし * はバージョン番号。
- 入手したファイルを実行し、ガイドに従ってインストールする。
- Windows の場合、入手した *.exe ファイルを実行する。
- Linux の場合、入手した *.bin ファイル(shell script)を実行する。
sh jdk-1_5_*-linux-i586-rpm.bin
[edit]
Eclipse
Linux のディストリビューション Fedora Core (日本語情報はここ) には Eclipse がバンドルされているので、それを使えば Eclipse を手動でインストールする必要はない。
- http://www.eclipse.org から、Downloads を選択。
- Windowsは eclipse-SDK-*-win32.zip
- Linuxは eclipse-SDK-*-linux-gtk.tgz
- ただし * はバージョン番号 (2005/12/02現在 3.1.1 が最新。3.1以降は、インストール後 UPDATE 可能)。
- 入手したファイルを適当なディレクトリで展開。
- Windows の場合、例えば C:\eclipse に展開。
- Linux の場合、例えば /opt/eclipse に展開。
cd /opt; tar xvfz eclipse-SDK-*-linux-gtk.tgz
- Eclipse を起動。
- Windows の場合、c:\eclipse\eclipse.exe を実行。
- Linux の場合、/opt/eclipse/eclipse を実行。
- ワークスペースのパスを指定
- ワークスペース内には、これから Eclipse を使って自分が作成するプロジェクトやファイルが置かれる。
- Linux の場合、例えば ~/workspace
- Windows の場合、例えば C:\workspace
- 最新版にアップデート
- Welcome to Eclipse の画面が出たら、右上の矢印 (Go to the workbench) をクリック。
- プルダウンメニュー "Help" ⇒ "Software Updates" ⇒ "Find and Install" を選択
- Search for the updates of currently installed features を選んで Finish ボタン
- 後は指示に従って OK/Next/Finish を押していく。
[edit]
Apache Derby
- Apache Derbyから Eclipse plug-in を入手する。
- サイドメニュー "Downloads" ⇒ Latest Official Release (2005/12/02現在、10.1.2.1) ⇒
- Eclipse plug-in derby_core_plugin_*.zip と derby_ui_plugin_*.zip をダウンロード (2005/12/02現在、それぞれ derby_core_plugin_10.1.2.zip, derby_ui_plugin_1.1.0.zip が最新)。
- Eclipse が起動していたら、終了しておく。
- 入手したファイル(derby_*.zip)を Eclipse のインストールされているディレクトリの下に展開する。
[edit]
How to Use Interactively
Eclipse の中から、Apache Derby を対話的に使うことができる。対話的とは、プログラムを書かずに(この場合はコマンドをタイプして)操作できるということ。
[edit]
Getting Started
- Eclipse を起動。
- Windows の場合、c:\eclipse\eclipse.exe を実行。
- Linux の場合、/opt/eclipse/eclipse を実行。
- 新規プロジェクトを作成する
- プルダウンメニュー "File" ⇒ "New" ⇒ "Project..." ⇒
- "Java Project" を選んで Next ⇒
- 適当なプロジェクト名を入力して Finish
- 作成したプロジェクトで、Apache Derby が使えるようにする。
- Java Perspective を開く (ウィンドウ右上の Open Perspective アイコンを押して、Java を選択)
- Package Explorer view (エキスプローラ風) に作成したプロジェクトを見つけ、右クリック ⇒ Apache Derby ⇒ Add Apache Derby nature
- Derby Network Server を起動する
- もう一度、Package Explorer view で、プロジェクトを右クリック ⇒ Apache Derby ⇒ Start Derby Network Server を選択。Derby のサーバープロセスがバックグラウンドで起動する。
- インタラクティブ SQL プロセッサを使って、SQL を実行する。
- もう一度、Package Explorer view で、プロジェクトを右クリック ⇒ Apache Derby ⇒ "ij" (Interactive SQL) を選択すると、Console view に ij が現れる。
ij version 10.1 ij>
- (optional) Console タブをダブルクリックして最大化する。
- プロンプト ij> に対して、SQL文が入力できる。ただし、 SQL文の終りにはセミコロン (;) を付ける。
[edit]
Important Commands
[edit]
Connect to a Database
connect 'URL';
例) データベース "myDB" を新規作成して接続する。
connect 'jdbc:derby:myDB;create=true';
URL はシングルクォート (') で囲む。新規作成する場合は create=true を追加。
[edit]
Exit the interactive shell (ij)
exit;
[edit]
Show help
help;
[edit]
Execute commands in a file
run 'file';
例) ファイル "foo.sql" を実行する。
run 'foo.sql';
ファイル名はシングルクォート (') で囲む
[edit]
Finish using Derby
- ij を終了する。
- ij の Console view のストップボタン(赤い■)をクリック。
- Console を右クリック ⇒ Remove All Terminated
- Network Server を終了する。
- Network Server の Console view のストップボタン(赤い■)をクリック。
- Console を右クリック ⇒ Remove All Terminated
[edit]
How to Use Programmatically
- Eclipse を起動
- 新規プロジェクトを作成
- プルダウンメニュー "File" ⇒ "New" ⇒ "Project..." ⇒
- "Java Project" を選んで Next ⇒
- 適当なプロジェクト名を入力して Finish
- to be continued...
Categories: How-To | Freeware | To-Do
