Saturday, 25 March 2017

JDeveloper Feature: Database Navigator

Now we are accustomed with the JDeveloper and we know about one of the most used features of JDeveloper, Application Navigator. Now, we'll check another useful feature of JDeveloper, Database Navigator. Database navigator is the window, where you'll find all the available database connections. From this window, you can create a database connection, view existing database elements, delete connections and manage database objects in a visual manner, also you  will be able to import/export data from/to multiple formats. If you are not familiar with SQL also, you can complete your trivial database tasks using this feature.

To open the database navigator, you need to navigate from the menu bar - Window -> Database -> Databases.

The database navigator shows different type of connections, IDE Connections, application specific connections and Cloud connections. Let me describe the difference between them.

IDE Connection

This type of connections are available as part of the IDE itself. So, you can use them as and when required in the development stage but while deploying the application, these connections don't get exported. These connections are good for development  usage.

Application Connection

This type of connections are available in each application. When an application is open, you can see the corresponding connection in the application. If you thoroughly check the above screenshot, you will find that there are two application names present from our earlier post. We'll check this in our next section.

Cloud Connection

This type of connections are required when you have a cloud hosted Oracle Instance or DBaaS instance. This type of connection is not in the scope of this series as this is itself a major part of Cloud Computing.

Now, in this section, we'll check different operations we can perform on connections. For this, we need to first create some connections. We can use any database of our choice. For demonstration purpose, I will use the integrated JavaDB. So, you don't have to go to other applications for this purpose. To start the JavaDB Instance, you need to run the integrated WebLogic Server. To do this, click on the Start Server Instance option from Run option in the menu bar as shown in the picture,

If this is the first time you are starting server, you need to provide an administrator user id and password. This is the username, you will use to perform administrative task in WebLogic console.

For the first time it will take some time to prepare and configure the server domain. Depending on your system specification, it may take several minutes to complete. Also, you may observe lag in your system if you are running on low resources.  So, please be patient until the configuration completes.

Once the server is started, you can find the following in the log window,

Now, we are ready to create one database connection to the integrated JavaDB database. To do that, we will go to the Databases window and click on the Add button in the top left corner of Databases window, It will open a pop up to create a database connection as follows,

From here, you need to provide different configurations of this connection. I will use the Integrated Java Derby Database. For other database, you can configure this accordingly with the connection details as provided by the database administrator -

The previous screen is the default database provided with the Integrated Server. So, we can readily use it for our development purpose. If you cannot find Library class, simply click on the magnifier icon and it will show all the available Libraries, you can use the Java DB JDBC Driver for this connection. Once all the configuration is complete, simply click on Ok and it will create a connection in the Databases window for future uses. I've created the connection as IDE connection. Si, it is available through out all the applications present in the IDE, similarly you can creatte connections for a particular application as well. We'll create application connections as and when required.

Next step is to explore the connection.

If you click the expand icon the newly created connection, you can find all the available Schemas in it -

Similarly expanding any schema, you can view its related database objects

Now, if we right click on the tables, we can view different operations you can perform on it -
If we click on New Table, it will show another dialog to get the details of the table. Let's create a new table in App Schema -
Explore this window a little and you will be accustomed to it. Once you are satisfied with exploring this dialog, click on OK and it will create the table for you.
Now, if we double click on the table, it will show the database editor in the main editor pane. We can use this editor to do different database operations. Now, let's add some record in it and commit the data. Right click on the connection and click on Open SQL Worksheet

It will open a SQL Editor in the main Editor Pane with a Script Output Window, just below it.

Now, put the following SQL Command, in the editor -
insert into demo values (1, 'O');
insert into demo values (2, 'r');
insert into demo values (3, 'a');
insert into demo values (4, 'c');
insert into demo values (5, 'l');
insert into demo values (6, 'e');
commit;

Now in the top left corner of the SQL Worksheet, you can find a Play button, use the same to run the whole script at once. This will create all the data in the table.

Now, let's look at another feature where you can export all the data of a table in a long lists of formats (like html, insert query, html, pdf, csv, excel file etc.). Just right click on the table and select Export. It will open a dialog for preferences -


So, we can use this feature to share a very long table or we can use this feature to create a backup of data.

Also you might have figured out that, if you have knowledge on Standard ANSI SQL, you can work with any database using the SQL WorkSheet window. Apart from trivial tasks, you can perform administrative tasks as well.

Well, well. I know, you guys are thinking that, we have specialised database tools to do all these stuffs, why to use Oracle JDeveloper for that.

Yeah, you are right, there are lot of specialised tools to do all database stuffs in a single go. But do not forget, you are here to build Oracle ADF/SOA Applications. So,all the administrative tasks had already been performed before even you start. This is just a convenient to look or manipulate your data in a single tool  and trust me, when working with very long team, you will 90% of time ask for a mini DB to unit test your code. Once all problems are solved, you will look for integration. So, once you start working on it, you will love this feature of pre-installed database server.

Another point to mention, due to some bug in the tool, we are not able to use the declarative CRUD Operation functionality in the DB Object Viewer. You can only edit the table definitions using this Editor. But for DB Objects of Oracle, it supports full features of the tool. We'll go with another post on this part on how to effectively use the Database Navigator feature of Oracle JDeveloper with some standard Database Server Like Oracle DB.

Now, that's a lot of stuffs and requires lot of prctice to get acquainted with. So, roll your sleeves up and start practicing till I come up with the next part of it !!!

Tuesday, 21 February 2017

JDeveloper Feature: Application Navigator

Once we are all set with JDeveloper installation, we will move ahead to explore features JDeveloper offers.

The very first thing every developer notices and wants to know about is role selection.

Remember, after installation, I asked to select Studio Developer. So, you will get access to all the features JDeveloper offers.

The role selection window looks like the following,
Other roles are also there, different role has different set of components and windows available in the IDE. So, Database Developer role will have Database specific components available and you won't be able to create Java Projects and all in this role selection, similar thing happens for Java Developer role and any other role. Just play around a little bit with different roles and you will be accustomed to the system.

Moving forward, we will see JDeveloper IDE opened with a Start Page

This page is full of links connected to different tutorials and Oracle Documentation. If interested, you can check them. You can also deselect the 'Show on Startup' check box. This will stop JDeveloper to show this page from the next time.

In the left pane, you see Application Navigator, where you can see two buttons 'New Application' and 'Open Application'. While working with JDeveloper, you will create one or more projects, this panel keeps track of all the projects you create under one single hood. You can have more than one Applications in this window. If this window is not visible to you at any point of time, you can get this from here - Window > Applications


Next we'll create an application and a project in the application.
Click on the New Application button and it will open a new application window

As this is the first time we're creating an application and we want to make it simple, we'll go with Java Desktop Application, where we'll create Java Classes and run in console. Then gradually we'll move towards other features.

Click on OK and it will open another window to get input from user. Provide some meaningful name to the application and you may also want o change the directory of the application, if you don't bother for the location, just leave to default.

Then click Next and it will ask for more settings like project name, the directory to store the project files. You can give a name of your choice. Following the convention, I have named it as HelloWorld. Provide the details and click next. It will ask for Java Settings for the project you are developing.

In this window, you will provide the default package all java classes will be in. Also, it will ask you for source code directory and output directory. If you've worked with any build tool like Ant or Maven, you will relate these settings. If you are not getting what to select or provide, just leave it to default. Click Next.

In the last configuration window, you will have to select a build tool. From 12c, JDeveloper comes with two different build tools, Ant and Maven. You can configure your Ant/Maven settings accordingly. You can also select the default JDeveloper Build Tool. For simplicity, I will go with the default JDeveloper's build tool.

That's all the configuration you have to do while creating a Java Application. You can click Finish now and it will generate the complete project for you. You can see this in the Application Navigator now.
If you click on the + icon just beside your project name (HelloWorld in my case), you will find what all files, directories are there in the project.

Now let's create a new class which prints 'Hello World' to the console. Right click on the project and select New, it will open  a selection menu for you, choose Java Class,

Again it will pop up an window for different Java Class configuration. Provide a class name, you can also find that the default package is now coming in this section. I've also selected to provide a main method. Now click on OK.

What happens now is interesting. Take a closer look of each area of the IDE.

You can now see that in the Application Navigator, the project has been expanded and the class is residing in a package. In the editor, you now have your class and a main method in it. In the left pane, now you can check, there are some more accordions present, Application Resources, Data Controls and Recent Files. Also, another window has been populated with data just below Application Navigator - Structure.

Let's look at each of these.

Projects

This accordion shows the hierarchical view of all the available projects in the Application. In this window, there are four small buttons -
  1. Project Properties - if you click this button, you can see different project related properties. You can configure your project using the settings used here.
  2. Refresh - Refreshes the content of the project/application.
  3. Working sets - this button is useful, if you have a large list of projects in an application. Using this feature, you can make a subset of all the available projects in the application.
  4. Application Window options - this button will open a menu for different view configuration. I strongly suggest you to check with different options available. Play a little bit and you will understand what each option means.

Application Resources

This accordion shows all the application related resources like, Build Files, Database Connection, Server Connection, META Data, Related Libraries etc. In the subsequent sections, we will see the use of this window.

Data Controls

This accordion will show you different data related configuration while you will be working with Business Components.

Recent Files

As the name suggests, it shows the recent files.

Structure

This window shows the structure of the content in the editor. Like, in our case, It shows the structure of the HelloWorld class. This is useful when you have a large file open in the editor window. You can find all the related structure and click on it, the editor will show the specific part of the file.

Now, you might have not noticed, in the top of the Application Navigator, we have the application name and in its right side, there is a down arrow present. Click on it and you will find the 'New Application' and 'Open Application' Option. Click on the New Application Button. This time, follow the instructions for application creation, provided earlier.


Following is how it looks like in my system

Check different windows in this application. Now again click on the right Down Arrow beside the application Name in the Application Navigator and you will find two different applications. You can click on either of the projects and the IDE will show you the contents of that application.

You can also create other applications using the same method.

Now, to complete this part of the tutorial, we'll complete both the HelloWorld and HelloUser classes and run them.

Change the content of the classes as your choice. A quick information here, when a file is getting modified in the editor and it is not saved, the file name changes to italics. 

Another tip, while working with Oracle ADF/SOA Suite, you will come across situations where, you will only change a single file in the editor but it will internally modify many files. So, JDeveloper provides a feature to save all the files in the application, regardless of whether the file is modified in the editor. In the menu bar, you will find the Save All icon just beside the Save Icon.

So, you can use this button as well while you have multiple files to save. Now, right click the file and click Run and it will show the console just behind the editor window.

Similarly, with the next file run, I will conclude this section

Sunday, 19 February 2017

Introduction to Oracle JDeveloper

Introduction

JDeveloper is a freeware IDE supplied by Oracle Corporation for the development of different Java Based application. Oracle JDeveloper is a cross-platform application. So, you can use it any OS like Windows, Unix, Mac OS etc. JDeveloper started its life as a Java IDE but with time evolving, it gradually became more and more of an IDE for Oracle Fusion Middleware based development. Oracle JDeveloper provides with many ADF/SOA based development tools without which, the development task would become very painful. JDeveloper simplifies the development process by its visual and declarative approach. It offers features for development in Java, XML, HTML, JavaScript, PL/SQL and BPEL.

With time, JDeveloper evolved itself in a constructive fashion and with 12c release, it has become a robust and productive IDE with its express tooling support for Java based application, specially Oracle ADF and Oracle SOA Suite. Let's look at the features JDeveloper offers, which a developer needs for its development -
  1. An Integrated WebLogic Server, capable of running end-to-end Oracle ADF/SOA Application. So, no need to worry about any bulky server installation and configuration while on development stage.
  2. A lightweight JavaDB exposure, which you can use at the time development. So, in a nutshell, you won't have to install a Database Server to develop and test your application.
  3. A complete database IDE which you can use to connect to and explore your database. So, no need to install another software like SQL Developer/Toad to explore your database.
  4. A rich components palette, from where you can drag and drop components and in the back end JDeveloper writes the code for you. This feature saves a lot of time in development stage.
  5. A feature rich Source Code Editor.
  6. Easy to use installer.
  7. Testing tools like built-in browser and HTTP Analyser. So, no need of any other software to run your unit tests at development stage.
So, using JDeveloper, you can concentrate on your development completely without having to worry about any other software installation or any other configuration. Also, once you download the installer, it takes about half an hour to get into development with all the development tools handy with you.

In this series, we'll look into all the major features/tools, which most of the developers agree to be handy and productive in the development stage.

Prerequisite

JDeveloper heavily depends on Java, so, you must have JDK installed in your system before you proceed. If you do not have JDK installed in your system, you can ask your system administrator to do it for you. Also keep in mind that Oracle JDeveloper is resource intensive while in development stage, specially if you need integrated server instance running. So, my suggestion would be to use a system with at least 6 GB of RAM.

Download

Oracle JDeveloper downloads are available here. If you do not want to use SOA Suite features in JDeveloper, you can use this link and download Studio Edition for your development needs, but if you also want SOA Suite development features, it is recommended to use this link and download the latest Free Oracle SOA Suite 12c Installations generic version. With this installation, you'll get all the tools in a single hood for your development. I will be using this installation and the next section will guide you through this. If you are downloading any other version, you'll get the corresponding installation guide in the documentation tab.

Now, it's a nice time to have a coffee if you want. Because, the download will take some time, regardless of what version you are downloading. Come back once your download is ready.

Installation

Note: If you already have JDeveloper installed or you are using any other version of JDeveloper other than described in the previous section, you can safely skip this part and move to the next post in this series.

Now, we are ready to see the installation of Oracle JDeveloper. Assuming you are a developer, the simple navigation/java commands should not be a problem for you to figure out.

Once you have downloaded the Oracle SOA Suite 12.2.1 QuickStart Download, you should move to the downloads directory and unzip both the files. Please ensure that both the extracted files are in the same directory. Once done, you have to run the first file using java command. 
palash@Home-Computer ~ $ cd Downloads/
palash@Home-Computer ~/Downloads $ java -jar fmw_12.2.1.0.0_soa_quickstart.jar 
Launcher log file is /tmp/OraInstall2017-02-20_12-30-50AM/launcher2017-02-20_12-30-50AM.log.
Extracting files.............

Once the extraction is done, you should see the graphical installer which will guide you through the installation process.

This first window asks you for a location for the installation and also asks you for the user group, this installation is associated with. If not sure, leave these to default. Then the Welcome Screen appears, it is wise to read the welcome note. Click Next button.

This screen asks for Auto Updates, you can safely skip and click Next.

In the next screen, you have to choose the directory for Middleware Home to be installed. This is the directory which contains all the installation and user directory files, including you development works. So, take some time to think of the possibilities of the directory size and choose accordingly and click Next. Also, keep a note of this location.

The next screen checks your system for Operating System and JDK installation. You should match the requirements of the installer. Once everything satisfies the requirement, a green Tick will be placed.

In the next window, you should see all the details of the features, that are going to be installed. Check and click Install.

Once you have clicked Install, you will see the installation progress window and it will show the status of each sub tasks. Remember this is a resource intensive job and will take some time to complete. So, you might get some slowness while the installation is in progress. It is also recommended to close all other windows while installation is in progress.

Once all the tasks are performed successfully by the installer, you should see green ticks for all the tasks. Now, click Next. Optionally, you can view the log or messages by clicking on the appropriate buttons.

In the last screen, you will be shown all the successfully installed features. Check what features have been installed and in the Next Steps section, check Start JDeveloper. 

Now the JDeveloper starts.

You will be prompted to select a role. For the time being step ahead with Studio Developer.

Next the JDeveloper opens with its start page shown which indicates a successful installation.

Add Shortcut: After the installation is done, you may find it difficult to find the Jdeveloper shortcut. So, better to keep a shortcut handy. From the Oracle Home Location (You've chosen this in the Installation Location and in the Installation Complete section, you've been prompted), follow this path
palash@Home-Computer /mnt/sda3/install/Oracle/Middleware/Oracle_Home $ cd jdeveloper/

If you are on Windows System, you can shortcut to the jdeveloper.exe file in this directory. If on Linux, move  to the jdev/bin directory
palash@Home-Computer /mnt/sda3/install/Oracle/Middleware/Oracle_Home/jdeveloper $ cd jdev/bin/
Keep a shortcut of the jdev executable. This process varies for Linux distribution, please check the forum or community of your Linux Flavour on how to create a desktop shortcut.

This is how it looks like in my computer using a .desktop (Standard Shortcut file for Ubuntu based distribution) file


That's all for the introduction. In our next discussion, we'll move ahead with different features offered by JDeveloper.