Eclipse: How to integrate Derby

1. Quite often, we need to test dao in our project.

    And derby is a good choice for this specific purpose.

2. Installation:

1) DTP Installation

Help->Install New Software...

2) Download Derby JDBC JAR

1> In Non-maven project

     We need to download the latest derby jar from the official download link.

2> In Maven project

     We need to include derby jar in pom file

<dependency>
	<groupId>org.apache.derby</groupId>
	<artifactId>derby</artifactId>
	<version>10.10.1.1</version>
</dependency>

3) Register Derby JDBC Driver

1> Window->Open Perspective->Other->Database Development

2> Database Connections->New...







Extensions:

1> How to delete Driver/Connection Profiles?

Window->Preferences->Data Management->Connectivity->Driver Definitions

2> Sometimes after we added a connection, we may encounter exception like this:

Failed to create database 'C:\Program Files\MyApp\myDB', see the next exception for details.

To me, it is because there is already a directory "c:/Program Files/MyApp/myDB" exists.

1> Remove Driver Definitions and connection profiles.

2> Close eclipse, and restart computer(To dissolve the occupation of myDB directory).

3> Delete myDB directory.

4> Start Eclipse, and then create connection profiles.

The exception just disappeared.

 

Reference Links:

1) http://www.vogella.com/articles/EclipseDataToolsPlatform/article.html#dtpintro_dtp Introduction how to enable DTP and integrate Derby.

2) http://download.eclipse.org/releases/kepler The DTP URL.

3) http://db.apache.org/derby/derby_downloads.html Download for Derby JAR.

4) http://www.binarytides.com/create-autoincrement-columnfield-in-apache-derby/ Simple Auto-increment Primary Key DDL Definition.

5) http://stackoverflow.com/questions/4999106/fail-to-create-embedded-derby-java Possible other solution for db creation exception.

6) http://www.eclipse.org/forums/index.php/t/14650/ Possible other solution for db creation exception.

猜你喜欢

转载自davyjones2010.iteye.com/blog/1994144