Sunday, 4 January 2015

Install Oracle 11g on Windows 64bit server


This tutorial explains how to install Oracle 11g database server in a windows 64 bit server. You can download the software for free only for personal use from this link Oracle Download  Microsoft Windows (x64). This link has two files where both the files are mandatory for Oracle installation.

Note: In downloads.oracle.com you can either download Enterprise edition or Express studio. Where Express studio has many limitations of the Oracle features and also size limit of 11GB of the total database.

Once download please extract both the files and click on the setup.exe, the installation with start after the basic checks.

1)      Skip the first step which asks to enter your email id as we won’t require as we are going to use the software only for learning purpose.
2)      In Installation Option select “Create and configure a database”


3)      In System Class option select “Server Class”


4)      In the next step select Single Instance database Installation, click Next
5)      In the next step select Advanced install, click Next
6)      Click Next, In the Database Edition selection screen Enterprise Edition will be selected keep it as it is and click Next



7)      In the next step select the path where you need the software and the database to reside and click Next


8)      In the next step select General Purpose / Transaction Processing, click Next


9)      Enter the name of the database, click next


10)   In the next step in Configuration Options go to the tab Sample Schemas and select “Create database with sample schemas”


11)   Click next, next and next. Then in the Schema password section select use same password for these accounts and enter the password.
12)   Once you click on next Oracle Installer will automatically check for space and prerequisite and if it passed will go to the summary page with the list of items that will be installed. Click Finish to start the installation.


Once the installation is completed it will show the result screen as above. We have now successfully installed Oracle in our machine.


Let us know your reviews about the post to improve the blog, also let us know if you face any issues in accomplishing the above. 

Please provide your comments below the blog.

Thursday, 1 January 2015

How does Oracle Works

In this tutorial we are going to see how does Oracle actually works, I read this post in one of the Oracle document and found this should be helpful for others so I have reproduced the same. (To checkout the original link Click Here )
The following example describes the most basic level of operations that Oracle performs. This illustrates an Oracle configuration where the user and associated server process are on separate computers (connected through a network).
  1. An instance has started on the computer running Oracle (often called the host or database server).
  2. A computer running an application (a local computer or client workstation) runs the application in a user process. The client application attempts to establish a connection to the server using the proper Oracle Net Services driver.
  3. The server is running the proper Oracle Net Services driver. The server detects the connection request from the application and creates a dedicated server process on behalf of the user process.
  4. The user runs a SQL statement and commits the transaction. For example, the user changes a name in a row of a table.
  5. The server process receives the statement and checks the shared pool for any shared SQL area that contains a similar SQL statement. If a shared SQL area is found, then the server process checks the user's access privileges to the requested data, and the previously existing shared SQL area is used to process the statement. If not, then a new shared SQL area is allocated for the statement, so it can be parsed and processed.
  6. The server process retrieves any necessary data values from the actual datafile (table) or those stored in the SGA.
  7. The server process modifies data in the system global area. The DBWn process writes modified blocks permanently to disk when doing so is efficient. Because the transaction is committed, the LGWR process immediately records the transaction in the redo log file.
  8. If the transaction is successful, then the server process sends a message across the network to the application. If it is not successful, then an error message is transmitted.
  9. Throughout this entire procedure, the other background processes run, watching for conditions that require intervention. In addition, the database server manages other users' transactions and prevents contention between transactions that request the same data.
Please provide your comments below the blog.


Wednesday, 31 December 2014

Oracle Database Architecture

In this tutorial we are going to see about Oracle Database and basic details of its various types of files and few background processes in brief.
Oracle is an Object Relational Database Management System (ORDBMS).  An Oracle database server consists of a database and at least one database instance. An Oracle database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. A database server is the key to solving the problems of information management. The database has logical structures and physical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting the access to logical storage structures.

Database: It’s a set of files, located on disk which is used to store the data.

Instance: It’s a combination of System Global Area (SGA) and a set of background process which is used to manage database files.

The below diagram shows these details.




Physical Structures

Data file: It contains the actual data stored in the database objects like tables, indexes etc.

Control file: It contains the details of physical structure of the database like name of database, location of data file etc.

Redo log file: It contains details of the changes made to the database, which will be used in case of db failure. It’s a set of files always.

Parameter file: Contains the configuration details of instance and database, one machine readable (SPFILE) and human readable (PFILE).

Alert & Trace file: All background process write to these files when some abnormal activates happens in the database and for additional information when some operations is being performed.

Logical Structures

Data Blocks: It’s the lowest level where an Oracle exactly stores a data. One data block represent specific number of bytes.

Extends: It’s the next level of database space, which represent contiguous data blocks.

Segments: Its above extends, collects of extends stored for specific user object.

Tablespaces:  It’s the logical container for various segments, and each tablespace contains at least one data file.

Memory Structure

System Global Area (SGA): It’s a shared memory structure, which contain data (i.e. data block, shared SQL area) and information for a single oracle database instance. It’s shared by all server and background process.

Programmable Global Area (PGA): It’s shared memory stricter, which contain data and control information for a server or a background process. Each server process has its own PGA

User Global Area: Memory that is associated with a specific user session.

Client Process: These process are created and maintained to run the software code of an application program on an Oracle Tool.

Oracle Background Processes

PMON-Process Monitor: Manages all the process, performs recovery when a user process fails, cleaning cache, freeing resources.

SMON-System Monitor: Processes recovery after instance failure and monitors and cleans temporary segments and extends that are not used.

DBWn-Database Writer: It takes care of writing the modified blocks from the database buffer (RAM) to the data files.  

LGWR-Log writer: It writes the redo log entries to the disk.

CKPT-Checkpoint: It writes information to control files and data file headers.

MMON: Process to collect statistics for Automatic Workload Repository (AWR) report.

RECO-Recovered process: Used to resolve distributed transaction that are pending due to network or system failure in distributed database.

SGA Components

Database Buffer Cache: Contains the most recently used blocks of data. Contains both modified and unmodified blocks.  

Redo log buffer: Circular buffer in the SGA that stored the redo entries describing the changes made to the database. These contain information necessary to reconstruct, or redo, changes made to the db by DML or DDL operations.

Shared Pool: It’s the place where SGA has the library cache (SQL, PL/SQL code), dictionary cache (Oracle accessed data dictionary item used for SQL parsing) and result cache (results of SQL queries, PL/SQL that are cached).


Please provide your comments below the blog.

Wednesday, 24 December 2014

Oracle ADF architecture


Oracle ADF is based on the Model-View-Controller (MVC) design pattern. An MVC application is separated into:

1) A MODEL layer that handles interaction with data-sources and runs the business logic,
2) A VIEW layer that handles the application user interface, and
3) A CONTROLLER that manages the application flow and acts as the interface between the Model and the View layers.

Separating applications into these three layers simplifies maintenance and reuse of components across applications. The independence of each layer from the others results in a loosely coupled, Service Oriented Architecture (SOA)




Oracle ADF implements MVC and further separates the model layer from the business services to enable service-oriented development of applications.
The Oracle ADF architecture is based on four layers:
• The Business Services layer – provides access to data from various sources and handles business logic. (EJB, Web Services, ADF BC, .xml Bean definition file) 
• The Model layer – provides an abstraction layer on top of the Business Services layer, enabling the View and Controller layers to work with different implementations of Business Services in a consistent way. (.cpx, .dcx, .xml) 
• The Controller layer – provides a mechanism to control the flow of the Web application. 
• The View layer – provides the user interface of the application. (VO files (__vo.xml), .java, .jsp, .jspx, .uix)

Oracle ADF lets developers choose the technology they prefer to use when implementing each of the layers. The diagram above shows the various options available for developers when building Oracle ADF applications. The glue that integrates the various components of Java EE applications and makes development so flexible is the Oracle ADF model layer. EJB, Web Services, JavaBeans, JPA/EclipseLink/TopLink objects and many others can all be used as Business Services for the Oracle ADF Model. View layers can include Web based interfaces implemented with JSF, Desktop Swing applications and MS Office front ends, as well as interfaces for mobile devices.

The Business Services Layer
The Business Services layer manages interaction with a data persistence layer. It provides such services as data persistence, object/relational mapping, transaction management, and business logic execution.
The Business Services layer in Oracle ADF can be implemented in any of the following options: As simple Java classes, EJB, Web services, JPA objects, and Oracle ADF Business Components (VO, EO & AM). In addition, data can be consumed directly from files (XML or CSV) as well as REST.

The Controller Layer
The controller layer manages the applications flow and handles user input. For example, when you click a Search button on a page, the controller determines what action to perform (do a search) and where to navigate to (the results page).
There are two controller options for web-based applications in JDeveloper: the standard JSF controller or the ADF Controller which extends the JSF controller functionality. Whichever controller you use, you will typically design your application flow by laying out pages and navigation rules on a diagram.
With the ADF controller you can break your application’s flow into smaller, reusable task flows; include non-visual components such as method calls and decision points in your flow; and create “page fragment” flows that run inside a region of a single containing page. This approach encourages maximum reusability for user interface fragments and simplified integration into portals and smashup applications.

The View Layer
The View layer represents the user interface of the application.
Oracle ADF support multi-channel access to your business services allowing you to reuse your business services and access them from a Web client, a client-server swing desktop based application, Microsoft Excel spreadsheets, or a mobile devices such as a smart-phone.
For Web based interface Oracle ADF offers a rich set of over a 150 Ajax enabled JSF components that simplified the creation of dynamic and appealing user interfaces.

The Model Layer
The model layer connects the business services to the objects that use them in the other layers. Oracle ADF provides a model layer implementation that sits on top of business services, providing a single interface that can be used to access any type of business service. The model layer consists of two components, data controls and data bindings, which utilize metadata files to define the interface. Data controls abstract the business service implementation details from clients. Data bindings expose data control methods and attributes to UI components, providing a clean separation of the view and model. Due to the metadata architecture of the model layer, developers get the same development experience when binding any type of Business Service layer implementation to the View and Controller layers.


Please provide your comments below the blog.

Message box on Button Click in Android (TOAST)

This tutorial explains how to show a message box on button click of an Android application.

Create a new Android project:

Create a new project as in the Hello World Android tutorial.

Application Name:  Message Alert
Project Name: MessageAlert
Package Name: com.skk.messagealert

Minimum SDK:  API 8
Target SDK: API 20
Compile With: API 20
Theme: Holo Light with Dark Action Bar

Activity Name: Message_Alert

1)      Remove the existing TextView “HelloWorld”

2)      Drag and drop a button from the Forms Widget Pallet to Android Screen and rename the Text properties to “Show Alert”





3)      Response for the button click in Android can be done via any of the two following ways,

a.       By setting onClick event:
In the properties of the button change the onClick event value to sendMessage. This will update the XML as below

android:onClick="sendMessage"

 Complete XML File:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.skk.messagealert.MessageAlert" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="98dp"
        android:layout_marginTop="46dp"
        android:onClick="sendMessage"
        android:text="Show Alert" />

</RelativeLayout>

Now we need to write the code for showing the Message on button click i.e the event, go to the java file MessageAlert.java under src\com.skk.messageAlert\ add the following method in MessageAlert class

public void sendMessage(View view) {
              Toast.makeText(getApplicationContext(), "You have clicked me!", Toast.LENGTH_LONG).show();
       }

Typically in this method we set the text that needs to be displayed when button is clicked, and how long it should be shown and show the message to the user.

a.       Using onClickListener event:
In this method we set the Listener event for the button. The below is the code for the same.

       @Override
       protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_message_alert);
             
              Button bt1 = (Button) findViewById(R.id.button1);
              bt1.setOnClickListener(new View.OnClickListener() {
                    
                     @Override
                     public void onClick(View v) {
                           Toast.makeText(getApplicationContext(), "You have clicked me!", Toast.LENGTH_LONG).show();
                     }
              });
       }


Here we create a local variable to refer the button and add the EventHandler for that and on click of that we show the message using Toast.

4)      1)      After creating the code as in any one of the methods above, save and run the code as Android Application Project. This will launch the android application. Once you click the button you should be able to see the message being show.



Successfully we have created and deployed the sample message box in Android.

Additional Details:

Toast: Toast is used to show a small popup upon a specific action in Android, while the current activity remains visible and interactable.
makeText(): This is used to create the text message that needs to be displayed , duration and the application context.
show(): This method is called to displayed the created text message.
R.java:  This is an auto generated file for all the Android project, it creates a unique ID for all the elements in the Android application i.e Button, title, logo etc. Sample value below.

public static final int button1=0x7f05003c;


Note: The value of the button might differ for you.

Please provide your comments below the blog.

Hello World in Android more details


This tutorial explains provides you some basic explanation about the Android application project.

Following are the list of items which needs to be known when creating a simple application.

1)      Activity:
Activity is the one which provides screen to the user where he can interact with the application. There should be at least one activity in your Android application to run. Whenever an application icon is clicked any one Activity will be started.

2)      Layout:
Layout is one which defines how your application screen should look like. The layout that we use in the HelloWorld application is RelativeLayout. Which sets the items in a sequence based on other items. In every Android project there will be a folder called LAYOUT in which all the layout design files are stored in XML format.

3)      AndroidManifest.XML:
This file contains the configuration details of our Android application, the minSDK and targetSDK. List of permission that the application need access i.e internet, camera etc.., the first activity that needs to be run when the application launches. What’s the display name of the application, the theme that needs to be used etc.

Below is the file sample file of an Android application.

xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.skk.helloWorld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


4)      Values folder:
This section in the Android project contains the strings, styles, format of the UI elements etc. Below is the sample strings.xml which contains the strings and its values.

xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Hello Kumar</string>
    <string name="hello_world">Hello Kumar!</string>
    <string name="action_settings">Settings</string>

</resources>


5)      Drawable folders:
This section contains all the images that are used in the Android application. The images with various resolutions are kept in separate folders.

The above are the basic details that needs to be known for a sample application. Details in depth will be explained in separate posts.

Please provide your comments below the blog.