Apache Derby

From Fukudat.com

Jump to: navigation, search

Contents

1 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.

2 How to Install

This page discribes how to install Apache Derby on a standard PC running Windows or Linux operating system. We will need to install the following software on the target PC.

The following subsections briefly describe how to install the required software.

2.1 Java DK

  • From SUN Developer Network, get an appropriate package of J2SE.
    • Choose a package without NetBeans, since we don't it.
    • Either J2SE 1.4.x or J2SE 5.0 (1.5.x) is fine.
    • For Windows, j2sdk-1_4_*-windows-i568-p.exe or jdk-1_5_*-windows-i568-p.exe.
    • For Linux, j2sdk-1_4_*-linux-i586-rpm.bin or jdk-1_5_*-linux-i586-rpm.bin.
    • where * is a version number.
  • Run the file you got, and follow the instruction.
    • For Windows, run *.exe file you obtained.
    • For Linux, run *.bin file (shell script) you obtained.
 sh jdk-1_5_*-linux-i586-rpm.bin

2.2 Eclipse

Some Linux distributions (e.g., Fedora) contain Eclipse. If you are using such a distribution, you don't have to manually install Eclipse.

When you need to manually install Eclipse, follow the instructions below.

  • Open http://www.eclipse.org/ with your browser and click Downloads.
  • Choose an appropriate package for you:
    • For Windows, eclipse-SDK-*-win32.zip
    • For Linux, eclipse-SDK-*-linux-gtk.tgz
    • where * stands for a version number (as of 2005/12/02, 3.1.1 is the latest)
  • Extract the content in a directory.
    • For Windows, C:\eclipse is typically used.
    • For Linux, /opt/eclipse is typically used.
 cd /opt; tar xvfz eclipse-SDK-*-linux-gtk.tgz
  • Run Eclipse
    • For Windows, run c:\eclipse\eclipse.exe
    • For Linux, run /opt/eclipse/eclipse
  • Select the location of your workspace.
    • In your workspace, everything you will create using Eclipse will be placed.
    • For Linux, ~/workspace is used typically
    • For Windows, C:\workspace is used typically

2.3 Apache Derby

Apache Derby plug-in is now bundled with Eclipse. You don't have to manually install Apache Derby plug-in unless you want to use newer version of Apache Derby than that comes with Eclipse.

  • Get Apache Derby plug-in for Eclipse from http://db.apach.org/
    • Click download tab and choose the latest offcial release (as of 2009/5/20, 10.5.1.1 is the latest).
    • Get two plugins derby_core_plugin_*.zip and derby_ui_doc_plugin_*.zip.
  • Terminate Eclipse if it is running.
  • Extract the zip files in Eclipse installation directory.

3 How to Use Interactively

You can use Apache Derby interactively from the console of Eclipse.

3.1 Getting Started

  • Start Eclipse
  • Create a new Java project
    • Click menu "File" -> "New" -> "Project..." ->
    • Choose "Java Project" and click Next ->
    • Input a project name whatever you like, and click Finish
  • Enable Apache Derby feature in the created project
    • Open Java Perspective (Click Open Perspective icon on the right top of Eclipse window)
    • Find the project just created in Package Explorer view and Right-Click it -> Apache Derby -> Add Apache Derby nature
  • Start Derby Network Server
    • In Package Explorer view, Right-click the project, again -> Apache Derby -> Start Derby Network Server.
  • Start Interactive SQL Processor
    • In Package Explorer view, Right-click the project, again -> Apache Derby -> "ij" (Interactive SQL). Then "ij" comes up in Console view.
 ij version 10.1
 ij> 
  • You can now type in any SQL command against the "ij>" prompt.
    • Don't forget to put a semicolon after a SQL command.

3.2 Important Commands

3.2.1 Connect to a Database

 connect 'URL'; 

例) Connect to "myDB" (create if it does not exist).

 connect 'jdbc:derby:myDB;create=true'; 

URL must be surrounded by single quotes (').

3.2.2 Exit the interactive shell (ij)

 exit; 

3.2.3 Show help

 help; 

3.2.4 Execute commands in a file

 run 'file'; 

例) run SQL statements in a file named "foo.sql".

 run 'foo.sql';

A file name must be surrounded by single quotes (')

3.3 Finish using Derby

  • Stop ij
    • In Console view, click the red square (■) of ij.
  • Stop Network Server
    • In Console view, click the red square (■) of Network Server.

4 How to Use Programmatically

  • Eclipse を起動
  • 新規プロジェクトを作成
    • プルダウンメニュー "File" ⇒ "New" ⇒ "Project..." ⇒
    • "Java Project" を選んで Next ⇒
    • 適当なプロジェクト名を入力して Finish
  • to be continued...
Personal tools
In other languages