Oracle ADF data sources provide a convenient framework by which to query data from your applications. ADF settings can be exported and zipped for easy transfer and re-use in different JDeveloper environments. However you need to know how to configure ADF settings where server or database name, or to troubleshoot connectivity problems with your applications.
This Oracle ADF tutorial will show you how to configure and amend Oracle ADF settings.
Before you start
Before you configure ADF data sources, you will need:
- An Oracle 11g database that is installed and running.
- Properly installed and configured JDeveloper tools instance.
- Credentials and permissions to launch the listener control and access the server on which your database is hosted.
To verify ADF set-up
You can check and edit your ADF settings from the JDeveloper environment so:
- Select Open Application from the left-hand navigation pane:
- Select an existing application from the Open dialog. Use the Application navigation tree to locate your application module – in this example ours is called ‘AppModule’Right-click App Module and select RunThis will then launch the ADF model tester.
- Because the ADF Data Sources have been incorrectly configured, the application will generate an error telling you the target data store is unavailable:
Click OK to continue.
To correct ADF set-up
Where your application fails to connect to the data source, you need to verify and correct your ADF configuration:
- From the left hand Application Resources pane, expand Connections -> Database. You should then see the database connection causing the error – in this case HRCONN – which is denoted by a small red cross:
- Right click HRCONN and select Properties from the context menu:
- This will open the Edit Database Connection screen, showing the current configuration settings. Initially you should check whether the issue is caused by the database itself being down, rather than a configuration error. You can check this really quickly by clicking the Test Connection button.The info panel just below the button will then display a message confirming connection, or providing additional details of any problems.
- If the database is definitely running but you still cannot connect, fire up your command line (DOS prompt) and launch the listener control by typing lsnrctrl:
- At the LSNRCTRL prompt, type status to assess whether the database listeners are functioning correctly, along with the names of the services currently running.
In this example you will notice that there is no instance with the name orcl as specified in the ADF settings. You should also check the host name and port number for each connection to see whether there is a mismatch in these settings too. - Go back to the Edit Database Connection screen and change the Service name value to match the correct value from the DOS prompt. In our example this means changing the name from orcl to orcl2:
Click Test Connection again – this time you should see a Success! Message. Click OK to close the configuration window. - The Application Resources pane of the main JDeveloper screen will now refresh, showing you a collection of database objects for HRCONN:
- Re-run your original application by right-clicking App Module and then selecting Run:
This time everything should complete successfully and the Oracle ADF Model Tester application window should pop up without any errors:
Deploying your model
When it comes time to deploy your model, you can pre-define some of the connection settings to reduce the scope for error.
- Right-click on your model in the Application pane and select Project Properties
- In the Project Properties window, select Deployment from the left-hand tree menu. Highlight the relevant Deployment Profile on the right of the screen, then click Edit…
- In the Edit ADF Library JAR Deployment Profile Properties screen which pops up, select Connections to view the details that will be saved as part of the deployment process:
You can amend these settings to include all of the same connection details (which could lead to the configuration errors described above), or just the Connection Name Only (in which case the user will have to configure all of the connection settings themselves). Click OK to save the settings.
Obviously these are just some very simple examples that show how to use ADF data sources, but building on these techniques you will be able to access and display data from your Oracle database in any way you need. You will learn this when you take one of our Oracle ADF training courses, click here for more. For a video version of this tutorial, visit the Firebox Training YouTube channel.
Please Share This Knowledge With Others!