Lesson 1.3: Create a connection to a database
In this lesson you will learn how to add a connection to a sample Derby database.
Before you begin, complete Lesson 1.2: Add JPA support to the project.
Add a connection to the Derby sample database
- In Project Explorer, right-click
JPATutorial and select
Properties. The Properties for JPATutorial window opens.
- Click
JPA.
- Make sure that
RAD JPA Platform is selected in the Platform list.
- Click
Add connection. The New Connection Profile wizard opens.
- In the connection profile type list, click
Derby. In the Name field, type a name for your connection (for example, name it Myconn) and then click Next.
The New Derby Connection Profile wizard opens
- From the Drivers list at the top of the wizard, select Derby 10.2 - Embedded JDBC Driver Default.
- Select
Connect every time the workbench is started.
- On the General tab of the Specify a Driver and Connection Details page of the Derby Embedded Database wizard, click Browse and select
<workspace_location>JPATutorial\WebContent\sample and click OK.
- Click
Test connection to ensure that you can connect to the Derby database. On the Success dialog-box, click OK. Click Next.
- Click Finish to complete the connection to the derby database.
- On the JPA properties page, select
Override default schema from connection and then select
SAMP in the
Schema list. Click
Apply to apply the changes to your Web project, and then click OK.
Lesson checkpoint
You have completed Lesson 1.3. In this lesson, you learned how to add a connection to a Derby database.