How to use Apache Derby on Eclipse
Introduction
As a continuation of the previously written [Eclipse] Installing DB Viewer, I summarized how to use Apache Derby with DB Viewer.
What is Apache Derby
- RDBMS made in Java.
- Has both "client / server mode" like Oracle and MySQL and "embedded mode" like SQLite.
Preparing Apache Derby
download
- Download the JAR file from the Apache Derby site.
- If you look at the Download page, the available versions of Apache Derby differ depending on the Java version, so check the Java version you have. And then download.
- In my case, my Java version was Java8, so I downloaded Apache Derby-10.14.2.0.
Installation
- Extract the ZIP file and place it in the desired folder.
- This time, I placed it under
C: \ Program Files
.
- This time, I didn't do any work such as passing through the PATH.
Settings on Eclipse
DB registration
- Open the DBViewer perspective, right-click DBViewerPlugin and select Register.
![Derby_DBViewer_01.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/d37c6158-8ab6-2a8a-b82a-edc0206c2166.png)
- When the [Database definition-Register database definition] screen opens, enter an arbitrary definition name.
- Next, click [Add File] and set the path of Apache Derby (derby.jar) that you placed earlier as the JDBC driver.
![Derby_DBViewer_02.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/01cc5362-4c3f-7197-3269-f2177465b4f4.png)
- In the screen called Database Definition-Set Connection Information, select the type of JDBC driver.
- This time, I chose ʻorg.apache.derby.jdbc.EmbeddedDriver` to operate in embedded mode.
- Next, create a connection string, but when you select the driver type, a template will be created, so specify only the folder for DB.
- This time, I specified
C: \ Users \ NKOJIMA \ DerbyTest
as the folder for DB.
- Also,
create = true
is written on the screenshot, but this is specified when the specified folder does not exist.
![Derby_DBViewer_03.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/8dd9a219-c7e3-26e3-7436-0c3367317487.png)
Connection to DB
- Go back to the DB Viewer perspective again, select the
DerbyTest
you just created and click Connect.
![Derby_DBViewer_04.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/449f110e-0b2d-6981-b3d8-8e3647c4e28a.png)
- If the connection to the DB is successful, you can list the schemas in the DB as shown in the figure below.
![Derby_DBViewer_05.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/c4625921-6fb0-4bcc-2ceb-7576ddfe8333.png)
Use of DB
- In the DBViewer perspective, open the SQL Execution View tab located at the bottom (bottom right) and create the schema.
![Derby_DBViewer_06.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/beb846b7-b062-4610-9d4f-669f48f06718.png)
- If the schema is created successfully, the created schema will be displayed as shown in the figure below.
![Derby_DBViewer_06-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/895427f1-b18d-c3b7-b580-9461caf17cc8.png)
- Continue to create the table.
![Derby_DBViewer_07.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/1e427c5b-d4f0-b426-de28-9306874b8bb1.png)
Data type |
Range of values |
Remarks |
INTEGER |
-2147483648~2147483647 |
|
DOUBLE |
-1.7976931348623157E+308~1.7976931348623157E+308 |
|
VARCHAR |
Up to 32,Up to 672 characters |
|
DATE |
- |
java.Any date recognized by sql |
TIME |
- |
java.Any time recognized by sql |
TIMESTAMP |
- |
Value(dateandtime) of DATE and TIME combined |
- Once the table is created, you can see the definition of the created table as shown in the figure below.
![Derby_DBViewer_08.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/5a26ba3f-0fb8-8e68-f9ce-0d138fa788ef.png)
- With the created table selected, you can manually add records by clicking [+] on the right (upper right) panel of the DB Viewer perspective.
![Derby_DBViewer_09.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/312166/316de35c-004f-6ee9-7ab8-e6d2d038068e.png)
- When the data is entered, it will be displayed like this.
- You can also search the entered data by writing a SELECT statement in the [SQL Execution / View] tab located on the lower side (lower right).
[Eclipse] Install DB Viewer
Reference URL