- For an application--You can create a database connection owned by and deployed with the current application, which is listed in Application Resource
- For the IDE as a whole--You can also create a connection that can be added to any application (i.e., IDE Connections), which is listed in both Resource Palette and Database Navigator.
Before you can use an IDE connection, you need to add it to your application as shown in the figure:
Creating Database ConnectionsIf the data sources of your business components are from database, you need to create database connections to access them in your applications. Creating database connection can be either initiated by the user or triggered by other events such as creating the first business component in your application or importing an ADF library JAR which includes a connection.
In this article, we'll look at these different scenarios.
Creating the First Business ComponentWhen you create the first business component, say, use the following steps:
- New > Business Tier > ADF Business Components > Business Components from Tables
Importing an ADF Library JAR with Connections
If the project you are packaging into an ADF Library JAR includes a database connection, that information can be included in the JAR and may be available to the consuming project. Oracle ADF uses connection architecture which defines a connection as two parts:
- Connection name
- Connection details (or endpoint definition).
If a connection is present in the project, the packaged ADF Library JAR will contain a jar-connections.xml file and a jar-adf-config.xml file. They will be added to the META-INF directory. The jar-connections.xml file contains the connection name and other relevant connection information. The jar-adf-config.xml file stores the information about the credentials used for the connections. If connection credentials were also specified, then a jar-credential-jazn-data.xml will also be included for the credential store.
If the connection defined in the JAR is fully configured and there are no connection name conflicts with the consuming project, a new application connection will be added.
If you don't create extra business components after importing the packaged ADF Library JAR, you don't need to go through Initialize Project for Business Components step as described below. Just make sure your database connection settings are correct by opening it in Application Resources panel.
Initialize Project for Business Components
If you choose, you can create database connections in advance and initialize your project for business components using them.
As described before, IDE connections are located in either Resource Palette or Database Navigator. You can create new database connections from context menu as shown below:
After creating your IDE connections, you then add them to your application. Besides IDE connections, you can also create database connections for your application only. All database connections used by your application will be listed in Application Resources panel.
Besides creating database connections from context menu, you can also create database connections (in either IDE or application scope) from New Gallery using the following steps:
- New > General > Connections > Database Connection
After creating database connections in your application, the next step is to initialize your project for business components. Selecting model project from your application, open its property from the context menu.
Selecting Business Component tab, check "Initialize Project for Business Components" and then select the database connection to be used for creating business components. Note that this connection is used specifically for:
- JDeveloper Design-time and
- Business Components Tester
and it is different from the one used at runtime when your web application is deployed to an Application Server. That's another topic for the next time.