To configure a Derby JDBC data source, we will need to create a JDBC provider and then create a data source associated with the new provider.
Creating a Derby JDBC provider
1. To configure a new JDBC provider for Derby, we will need to follow similar steps as outlined for the Oracle JDBC provider we created earlier. Then select JDBC providers from the JDBC section on the left-hand navigation panel of the admin console. Select Cell scope and then click New, as shown in the following screenshot:
2. You will now be presented with the Create new JDBC provider screen. Select Derby from the Database Type select-list. Select Derby Network Server using Derby client 40 from the Provider Type select-list. For the Implementation type field, choose Connection pool data source. We do not choose an XA Data source, as this application does not have transactional management. Please type in MyDerbyJDBCProvider in the Name field. You can use the default value for the Description field, as shown in the following screenshot:
3. Click Next to continue on to the summary screen and click Finish and then Save. You will then be taken back to the JDBC Drivers list and you will now see the new Derby JDBC Provider.
Creating a Derby JDBC data source
1. To create a new JDBC data source, click on the Data sources link located in the JDBC section of the left-hand side navigation panel of the admin console. Select Cell scope and you should see the existing HR data source called HRDatasource. Click New to begin the wizard to define a new data source which the HR Lister application will use to connect to Derby instead of Oracle.
2. In the Create Data source screen, type HRDerbyDataSource in the Data source name field, type jdbc/hrderbydatasource in the JNDI Name field, and then click Next.
3. In the next screen, you will be prompted to select a JDBC provider. Choose Select an existing JDBC provider, select the Derby provider you created as an example MyDerbyJDBCProvider, and then click Next.
4. On the next screen, you will be asked to fill in the Database name field. Type hr and click Next.
5. On the Setup security aliases page, click Next, click Finish, and then Save.
Creating a new JAAS for Derby data source
For a Derby JDBC data source, we need to provide an authentication alias just like we did for the Oracle JDBC data source. To create a new J2C authentication alias and assign to the new data source we just created, use the following steps:
1. Click on the Data sources link located in the JDBC section of the lefthand side navigation panel of the admin console. Select the Cell scope and you should see the existing HR data source for Derby called HRDerbyDatasource. Select the data source and then click on the link called JAAS – J2C authentication data, located in the section titled Related Items.
2. Click New to create a new J2C authentication alias and type SYS in the name field and SYS for both the username and password fields. The value SYS is the default username and password that the Derby network server uses for the default SYS schema.
3. Click OK. Navigate to the data source’s list, re-open the HRDerbyDatasource configuration, and set the Component-managed authentication alias to the SYS alias you have just created, as shown in the following screenshot:
4. Click OK and then Save to ensure the configuration is set. You have now configured a Derby data source with a JAAS username and password alias.
It is good practice to test your data source using the test button located in the data source’s list screen. This ensures that the data source can connect. It is better to resolve connection issues at this stage, before involving an application.