Friday, 2 December 2016

Jdeveloper Features: Database Navigator

For any application to work nowadays, we need a backing database or some sort of web service which deals with database. So, let's check the connection with database with JDeveloper.
For the web service connections, we'll deal with another post.

If you want to know how you can install Oracle Database 11G Express Edition, check here.

To Open the Database Navigator, we'll navigate View -> Database -> Database Navigator

When you open database navigator, it shows all the available connections for use. Basically three types of connections are available for use.

  • IDE Connections
    These are the connections which are available in the IDE. So it means that any application in the IDE can share this connection.
  • Application Connections
    These are the connections which are specific to an application. Means that, if you have two applications open in the IDE and both have their own connections, this section will show two connections. But one application connection can not be used in the ther one.
  • Cloud Connections
    These are Oracle Cloud connections which you have licensed from Oracle.
This is the database navigator window,

Now let us see how we can create a connection and use it. Also, we'll check what we can do with a database connection. For simplicity and availability, I will use the default HR Schema that comes with Oracle 11G Database Express Edition.
First we'll create a new connection, then we'll name it something recognizable, then we'll define the connection.

At this point, you can test the database connection, before saving it. Once you are done with database credentials, you can save it and it will show in the Database Navigator.4

Now, you are ready with the database connection and you can do different operations on the connection. This will work much more like Oracle SQL Developer.

Here are some operations, I will show you.

Explore database

Execute Script

Explore and modify tables graphically

On the following video, I've captured all the steps from opening JDeveloper to exploring table data.

ADF can also work with MySQL, Maria DB. To check how to connect MySQL/MariaDB from ADF, please follow this article. Also, please let me know, if you need to connect ADF to any other database.

In our next article we'll check some other feature of JDeveloper.

Monday, 4 July 2016

Connecting MySQL database through Oracle ADF/JDeveloper

Database connection is an important task in any application development. Due to this fact, each and every language has provided useful API to connect to database. In case of pure Java, we have the facility to work with the JDBC API. While JDBC is itself a giant API for Database connection, we get many other tools/API to connect to database from Java application like Hibernate, iBatis, Spring ORM etc.

On the other hand, we have multiple database engines as well like Oracle, MySQL, Microsoft SQL Server, PostgreSQL, IBM DB2 etc.

Connecting with Oracle Database is pretty easy in Oracle JDeveloper and indeed it is very common to use Oracle ADF with Oracle Database. However, many people ask how to connect to MySQL from ADF Applications. There might be different reasons for that. Let's explore why many ask about this feature,

  1. Oracle is heavy and comes with lots of features. For educational purposes many will stay back from taking the heavy load on their system.
  2. Many people use Cloud Hosted MySQL for educational purposes (mostly you can opt for a free account for MySQL hosting). This can save developers from the hassles of installing any database to their system.
  3. MySQL is light and installation requires less space and system resources.
  4. Many people just want to learn ADF and not Oracle Database or they may be expert in MySQL. So, they are reluctant to move to Oracle. So, for them also, this feature may be useful.
With all these considerations, let's see how we can connect to MySQL Database from JDeveloper.


  1. MySQL Database or MariaDB (I'm using MariaDB)
  2. HR Schema. You can get it from here.
  3. Oracle JDeveloper
  4. MySQL Java Driver. You can obtain from the MySQL Website itself.

Database Installation

  1. You can get MySQL from MySQL website( Navigate to the site and download the required version for your system. Similar goes for MariaDB  (
  2. Install the database
  3. Get the HR Schema from the website mentioned.
  4. From terminal run the sql script
    mysql -t -u <user name> -p <password> < hr_schema.sql
  5. Now login to MySQL Database and verify that all the tables are created and data has been populated.

Connect from JDeveloper

  1. Open JDeveloper

  2. Create on New Application and Select Generic Application and provide name 'EmployeeModelApp'
  3. Provide project name 'EmployeeModel' and select ADF Business Components in the Project Technologies tab
  4. Click Finish
  5. Now Right Click on the EmployeeModel Project and click New
  6. Select Business Components from Table and click OK
  7. Now the wizard will ask you to select a connection.
  8. Click on the plus icon.
  9. In this window, you need to provide the details of your database and the appropriate library to connect to the database.
  10. Provide all the database details and for library selection, click on the Browse button and select User from the left pane and click on New.

  11. Now click on Class Path and click Add Entry button. This will open the explorer to select the MySQL Driver jar. Select the appropriate jar and click OK
  12. Now, you will be back to Library Selection Window, click OK
  13. Again you will be back to Database Connection Creation Window, Click on Test Connection button. If you provided everything properly, you will get Success.
  14. Now Click OK and you will be back to Business Component Initialization Window. Where you can find that SQL Flavor has automatically changes to SQL92. This means that this connection will use Ansi SQL format for all the database operations.
  15. Click OK and you will be directed to Database Object Selection Window. Click on the Query button and you will see the tables and views created by the hr_schema script.
  16. From Here On, everything goes exactly same as that of using Oracle Connection.
That's all. Hope you've successfully connected to MySQL Database from JDeveloper and your application is running fine.

Wednesday, 3 February 2016

Introduction to Oracle ADF Framework

Welcome to enterprise development. In this section, I will try to detail about one of the Java EE platform Rapid Development Framework provided by Oracle, known as Oracle Application Developer Framework, in short, ADF.

One question may arise here, Why ADF, we have many popular frameworks like Spring, Primefaces, MyFaces etc. Then why dive into this new technology ?

Well, the answer is quite subjective. It depends on the usage of the Java EE stack and the complexity of the application to be built, the interface that needs to be designed etc. Based on the usage, different framework suits different development needs.

Rather going into this discussion, we'll look into the features that ADF provides.

What is Oracle ADF ?

Oracle ADF is an extensible end to end Java EE framework. Let's look at the features ADF provides.

Features at a glance

  1. ADF is based on Java platform and works on MVC Design pattern.
  2. ADF is more like a meta-data driven tool which encapsulates the basic low level architecture of different systems. So, developers are free from the hassles of wiring different technologies together and can concentrate on the business layer.
    For example, if you are using Primefaces, Spring and Hibernate in conjunction, you have to wire these three different technologies as mentioned in this article. But for ADF, this is completely done in a declarative and visual approach.
  3. ADF provides visual and declarative development experience.
  4. ADF provides more than 150 rich AJAX based  UI components which can be wired to the business services easily.
  5. Clear separation between the business layer and the presentation layer is notable in ADF.
  6. ADF can be used to develop different applications targeting different platforms like web browser based application, mobile device application, desktop application.
  7. ADF also provides built-in security features for easily handling the application's security needs.
  8. All these a developer can do using drag and drop components available with Oracle JDeveloper or using manual coding.
  9. ADF also provides high level of customization. In case, your application needs some sort of customization in it, you are free to customize any component.
You may wonder how ADF handles all this things. Well, let's look into its architecture from a ver high level. We'll get into these parts as we'll be going through them.

High Level Architecture

Oracle ADF clearly separates different layers as follows,
  1. The model layer which is responsible for the data of UI
  2. The view layer which is responsible for the User Interaction, basically facilitating the user to view and modify the data.
  3. The controller layer which holds accountability for page navigation and page navigation outcomes.
  4. Business Service layer which handles the data access and business logic.
Image Courtesy: Oracle

Oracle JDeveloper

To facilitate the development of Oracle ADF Applications, we need to use an IDE for the development to be smooth. Oracle provides the Oracle JDeveloper for this purpose. Oracle JDeveloper is the tool for Oracle Fusion Middleware stack. Using JDeveloper, we can easily build fusion applications using declarative and visual approach. JDeveloper also comes with an integrated Weblogic Server to facilitate the deployment of ADF Applications. We'll be using this tool for our learning purpose.

All that said, let's look at the customer success stories,

Now, let's come to the point where you may raise questions.

Is ADF Open Source ?
Well, ADF is not open source. ADF comes with a license fee for commercial development.
Interested reader can check the price list.
However, Oracle has stripped down the ADF and provided this as open source. It is known as ADF Essentials. For details, check this FAQ.

So, that's all about Oracle ADF in a very high level context. In our next discussion, we'll be looking into the development environment set-up.

Introduction to JDeveloper

In this article, we'll be looking into an IDE to help the development of ADF Applications.

You may raise questions, why not using Eclipse/Netbeans/IntelliJ to develop ADF applications.

The simple answer is, if you want to develop an ADF Application, JDeveloper is the best suit for your needs.

Well, let's start with a simple definition of this IDE.

Oracle JDeveloper:  Oracle JDeveloper, also known as JDeveloper is a 100% Java based IDE to facilitate development of Java based applications.
In practical scenarios, it is best suited for Oracle Fusion Middleware applications like Oracle  ADF, Oracle SOA Suite etc.

Can we use Eclipse ?
Well, you can use it provided that, you have to deal with all the coding manually. Meaning, you will be dealing with different xml files. In this case, it is more error prone and if you lose a file or configuration, surely this will be a nightmare for you.

Well, there is a good news, Oracle provides an Eclipse Plugin known as OEPE. This plug in helps you develop ADF Applications in Eclipse as well. The key point is that, you will loose many of the advanced features that a full version of ADF uses. Its basically to support ADF Essentials (stripped down version of Oracle ADF).

Here is video from Oracle Product Manager demonstrating the process of using this plug in for development. Interested readers must watch this video end to end.

Oracle ADF Development in Eclipse

Well, for others (including me), we are simply be going through Oracle JDeveloper 11g version. You can download and install it from Oracle Website. I will refrain myself from detailing the details of IDE Installation. Because, I assume that, if you are trying to develop applications, you are indeed a Java developer. So the installation won't surprise you. Its fairly simple.

Still if you are stuck at any point, comments are always welcome.

With said that, here you go with the download link.

Apart from JDeveloper, we'll also be requiring a database for development. Because, using Oracle ADF we build data driven applications. I recommend using Oracle 11g XE database download for this purpose. Here is the download link.
Download the database, install it and unlock the HR Schema. Below you see the SQL code to unlock the HR Schema.

If you are facing issues while doing this, check this link.
You may argue that, we do not need a database all the time, we simply can invoke web services for persistence. To your argument, I would like to remind you that, we are just going with a very basic application building approach where we'll be exploring all the features ADF provides to us and as we are here to explore things, we'll also get to know that, the underneath data service is quite irrelevant when we are talking about ADF. Because, once you get the concept, its really simple to change the underlying data service to change from database to web services.

Come back when your environment is ready.

So, you have installed JDeveloper or OEPE and we are now in a good shape to look at the features Oracle JDeveloper provides,

If we think of an application, what we usually think ?

  • What would be the design of the application ?
  • How the data structure should look like ?
  • What are technology we should use ?
  • Do we require any service consumption ?
  • How do we test our application ?
  • What about the security ?
  • How to deploy the application ?
Once you are through these, you think of implementation. At this point you may think,
  • Design is in place, what about implementing the database part.
  • I have got all the use cases, validations, business rules and the data layer. Let's start our development of the business service.
  • At this time you are relaxed because major business implementation is complete. Now you think of creating the UI layer.
  • UI is complete, now what about integrating the UI with the business services through controllers.
  • Well, how the navigation should look like. Where the user can start and where does it end. What about different event handling ?
  • When you are done with all these stuff, you work with deployment and testing.
So, that's basically a pretty scenario of any application development. Now let's see where JDeveloper helps us in this case. An IDE is good if it provides you with tooling support for faster development. Let's now look into JDeveloper features.
  • When you create an application, JDeveloper provides you with a status tracker of each step of development. This is great for planning and tracking.
  • JDeveloper comes with support for offline database modelling. You can create an offline replica of your database.
  • Not all the applications will use the same technology. In JDeveloper you can choose technologies in your projects based on your requirement.
  • If we need to consume a web service, JDeveloper comes with built-in support for web services.
  • When you are completed with your basic business service and yet to develop the UI, you are in agood shape to test the business services. Guess what. You don't even have to write a single line of code to test your business layer. JDeveloper comes with an ultra cool support for this. Well, its my personal favourite. I will detail this one when we'll be going through this.
  • ADF provides you with a framework security which you can configure declaratively in a very short time. If you are using the free version of ADF (ADF Essentials) you will not see the security feature.
  • ADF Database navigator is more like SQL Developer. If you have ever used it, you will surely like the database navigator in JDeveloper.
  • When writing business services, you can even enforce business rules using declarative approach. No need to write codes for simple business validations. Also, if you are into a complex validation, you get groovy support for the same. So, using only a few lines of codes, you can achieve complex business validation rules.
  • For UI, you get more than 150 rich Ajax based UI components including graphs, charts etc. You need to simply drag and drop the component you require and your UI is complete.
  • Using drag & Drop features, you can easily wire between the UI components and the business layer.
  • Using task flows you can have a smooth control over UI navigation. Task flows are reusable controller components. So, you can reuse the controller layer itself for various purposes. Here you will also observe that framework is capable of handling two phase commit without much of development effort. We'll see this feature in detail.
  • JDeveloper comes with a deployer which can build and deploy your applications in local or remote host.
  • If you don't like a feature or need cream on top of your coffee, just customize it. That's pretty easy in almost all the layers of implementation.
So, we can see that using JDeveloper, we can pretty much leave many stuffs over the framework and have our peace in mind to concentrate on the core business logic. Well, this is pretty cool feature of JDeveloper/ADF combination.

Come On, everything cannot be a plus. It must have some difficulties too.
Well yes. "There are no free lunch" is true here as well. Not everything is a plus, some minus is also there. You should also check them,
  • As it takes care of most of the things, the deployment becomes heavy.
  • The IDE is a bit slower than Eclipse/IntelliJ.
  • Full version of ADF comes with license fee.
  • The performance of the application is also a bit slow due to internal configuration and caching. But this one is somewhat so small in effect that we can safely ignore. ADF also provides support for performance management. You can freely use this feature.
  • Although it provides a lot of UI components, customizing them is a bit tough.
That's all about an introduction to Oracle JDeveloper.

Now, you have installed JDeveloper in your system and has known about different features it provides. We also took a look on the negative sides of this tool. Now its time to open the tool and have a look on very basics of this tool.

So, launch JDeveloper. It will show a pop up to choose for a particular role.

So, you see we have to choose a role.
Actually JDeveloper customizes the view based on the role selected.
So, if you choose Database Edition over Java EE Edition, you are most likely to miss the view/windows.navigators/tool support for Java. You only see a set of required tools for Database development. Similar is the case for any other edition. If you choose a particular set of tools in the view, it basically increases performance. But again, it all depends on your needs.

So, which one to choose ?
Well, for our cases selecting the Default Role works fine.

Now, if you see below the Role selection menu, you can actually disable this Role Selection for the next executions. Well, I suggest not to do that. Because, you may be working with different projects and technology according to diferent needs. So, better you retain this.

After this, the JDeveloper opens the actual workspace. Now, let's take a look on the views that we see when we open JDeveloper.

So, we can see some major views in the JDeveloper.

Let's detail each window.

Application Navigator

Application Navigator is the place, where you can see different applications you are working with. You can see that we are working with an application which has two different projects. Actually JDeveloper encapsulates all the project into a single big module known as an Application. You may have more that two projects in your application for Developers' convenience but when we build the application, we get a single EAR file for deployment.

Application Resource Panel

Application resource panel shows us the different resources the application using like Database, File System, Application Server etc.

Data Control Panel

Data controls are the main encapsulation of business layer to UI. We'll check this one in detail later.

Structure Window

This window shows us all the structure of the particular selected element.
For example, you page consists of multiple components. Structure window will show you this one in a tree structure for your convenience. My Personal Experience with this view is pretty awesome. It saves a hell lot of search time in the element.

Visual Editor

When you are working with any element in your application, the element is opened in this view. Depending on the element, you can choose different view of the element. Like for a page you can choose between Design View and Source Code view.

Log Window

Whatever you do in JDeveloper comes with a log. Any execution shows some message to this window. Any execution will trigger a new log window.

Component Palette

When you are working with a file in the editor, you see a relevant component list in this window. This allows us to drag and drop the required elements. It also comes with a search box for convenient use.

Property Inspector

Most of the elements in JDeveloper come with a set of properties. You can view all the properties and can configure them according to your needs.
For example, if we are working with a text box element, you can see the different properties you have with a textbox like its size, width, maximum number of characters etc. This helps save the characters you type in for an element. Pretty much of use for a developer.

That's all what we see in the default view when we open JDeveloper. Well, you won't be seeing this window if you are opening JDeveloper for the first time.

We'll be going through the section where we open JDeveloper for the first time in our next article and we'll start with building a very basic application as well.

JDeveloper Features: Application Navigator

Now with our introduction to JDeveloper, we can move ahead with each of the frequently used features of this tool.

First thing we will discuss about the left panel of this tool. This is known as Application Navigator.

Application Navigator

When we look into this panel for the first time, we'll see two options there, New Application and Open Application.

If you click on the New Application button, you will be provided with a window to select the application template and you have to choose according to your requirement. In our case, we'll start with a Fusion Web Application,

In this window, we've to provide a name for our application. For now, we can go with the default value provided by the tool. We can also select a directory to store the application files and configurations. Next thing we need to provide is the package name. You can provide a desired package name here.

One thing, I want to discuss here is that, an application in JDeveloper consists of different projects. Initially it comes with two different projects Model and ViewController but according to the requirement we are free to add as many projects as we want. We'll discuss this in our subsequent discussions. For now, we are going with the default.

When we are done with all the stuffs, we can move to the next window to provide details of our Model project.

In this window we have to provide a project name and as earlier we are going with the default value, same for the directory as well.
Now, we have to choose the technology we want to use in our model project. By default ADF Business Components and Java is selected. If you want to choose other values, you can choose as well. Choosing the right technologies will help you with the UI and Component Browser. Because, every technology has its specific set of libraries associated with it.
We are going with the default value here.

Now, click on the Next button to move to the next window.

I think, this window is self explanatory and any Java Developer familiar with build tools or IDE can understand these settings. So, moving to the next window.

This time we are dealing with the View Controller project which basically is responsible for UI rendering. We provide the Project name and the directory to store the application files and then we are moving ahead with the technology selection.

Here you can see by default the list is pre-populated with some values and those cannot be changed. Well, you can try to shuttle between the technologies if you want. You will notice that for some technologies, you are provided some extra values.

Let me explain this to you.

For example if you add ADF Swing, you will get Swing/AWT by default and if you remove Swing/AWT, by default ADF Swing will be removed from the list. This happens because, ADF is built on top of multiple technologies to facilitate the development. So, if you choose any ADF component, you will get the base technology into the list and if you remove the base technology, you will loose the ADF library you want to use.

For our case, we are using ADF Faces and ADF Page Flows, which are dependent of JSF and XML which in turn are dependent on JSP and Servlet and XML. In turn JSP and Servlet depend on Java and HTML. So, all these technologies are selected for you.

Similar thing happened when we had the Model project configuration. We had ADF Business Components which depends on Java. So, Java appeared in the list.

Key point to remember: If you are selecting a technology, you are bound to include the depending technologies.

Well, that was all about the projects and technology selection. Move to the next to provide values for package, source directory and output directory and click on Finish button.

Wait for sometime for JDeveloper to create the necessary files and configurations. After this is complete, you will see in the editor window something like Application Overview. Well, we'll look into this later. Let's concentrate on the Application Navigator panel.

This is the application navigator window we'll work with. If you closed this window by chance, you can open this in the View menu. It comes Under View -> Application Navigator, as shown below.

Now, let's look into each part of Application Navigator.

In the top, you have a dropdown to select the application you want to work. Next you will see the Projects associated with the selected applications.

This window facilitates you with different project files. You can see that there are two projects in this view, Model and ViewController. These are the basic projects we'll be dealing with. We can also check that many files have been generated for us automatically. Basically this is the basic structure of an ADF Application. We'll look into each of this section later. Let's move into the second section of Application Navigator.

The next section is Application Resources,
This section gives you access to the different resources used by your application. You may be using database connection, file system resources, server connections. These all are shown in Connections directory.
In the descriptors, we can find different project descriptor files.
When we'll be dealing with these, we'll look into this section in detail.

Next section is Data Controls.
This is empty for now. We'll look into this part when we'll work with the model project.

And the last section of Application Navigator, Recently Opened Files

As the name suggests, this section shows the latest used files.

Well, that's all the sections Application Navigator shows you. Each of these panels can be expanded or collapsed for convenient view purpose.

That was all about the Application Navigator of JDeveloper.

In our next section, we'll look into other features of JDeveloper.