Monday, December 19, 2016

Improve JDBC Oracle database transaction performance in Apache-Tomcat

Method 1 – Using Only Datasource


The standard way to configure JDBC connections in Tomcat is to define a datasource resource in the “context.xml” file as  follows

 url="jdbc:oracle:thin:@hostname:port:sid "


The above resource can then be accessed in the Java code to get a Oracle Connection as follows:

import java.sql.Connection;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import oracle.jdbc.OracleConnection;
/* Only connection related code snippet mentioned below */
// Initialize the variables
Connection conn = null;
OracleConnection oracleconn = null;
// Invoke the database
InitialContext jndiEnc = new InitialContext();
DataSource ds = (DataSource) jndiEnc.lookup("java:comp/env/jdbc/DBASE");
conn = ds.getConnection();
oracleconn = conn.unwrap(OracleConnection.class);


This is the way that you will find described in the Tomcat documentation and on most of the websites on internet.

The problem with the above approach is that it does not initialize the database connections when the server is started (or when the web application is deployed). The connection to the database is made only when the above code is executed. Due to this the performance is slow, which may still be okay for most of the cases. But if you need better performance then the next method is recommended.


Method 2 – Using Datasource with Factory


Using this method, the tomcat on startup creates database connections which are then readily available to be used in the program. This substantially improves the performance compared to the previous method. The resource configuration in “context.xml” is to be done as follows. The main difference compared to the earlier configuration is to add the “factory” parameter.


  username="apps" password="password" 


The above resource can then be accessed in the Java code to get a Oracle Connection as follows:

import java.sql.Connection;
import javax.sql.DataSource;
import javax.sql.PooledConnection;
import javax.naming.InitialContext;
import oracle.jdbc.OracleConnection; 
/* Only connection related code snippet mentioned below */
// Initialize the variables
Connection conn = null;
OracleConnection oracleconn = null;
/* Invoke the database */
InitialContext jndiEnc = new InitialContext();
DataSource ds = (DataSource) jndiEnc.lookup("java:comp/env/jdbc/DBASE");
conn = ds.getConnection();
/* The Connection object received is an instance of PooledConnection.
   Following line converts PooledConnection to OracleConnection. */
oracleconn = (OracleConnection) (Connection) ((PooledConnection) conn).getConnection();




Use the Method 2 to improve you application performance  while connecting to Oracle Database on Apache-Tomcat.


Saturday, October 1, 2016

Business Travel Checklist

This is a checklist for short term business travel to a foreign country. Onsite Travel Checklist

Onsite Travel Checklist

Sr. No. Item Quantity Tick Mark
1 Wheat Atta  1 Ziplock bag per 6 Days. One time cooking.  
2 Rice 1 Ziplock bag per 10 Days. Two time cooking.  
3 Split Dal for Khichdi 1/4 Quantity of rice  
4 Toor Dal 1/4 Quantity of rice  
5 Chole 1/4 Quantity of rice  
6 Black Eye Beans 1/4 Quantity of rice  
7 Moong 1/4 Quantity of rice  
8 Ghee Small Bottle for 14 Days  
9 Cooking Oil Small Bottle for 14 Days  
10 Spices and Salt As per the container, half is okay  
11 Jaggery 200 grams  
12 Corn Flakes & Meusli 1 Packet around 500 grams each for 14 Days.   
13 Khakhra 1 Dabba for 10 Days.  
13 Sweet (Jaggery Laddoo) 1 Per Day  
14 Dry Fruits & Nuts 200 gms each for 14 Days  
15 Dates 500 gms for 14 Days  
Sr. No. Item Quantity Tick Mark
1 Pressure Cooker with Flat Bottom 1 Qty (with Flat Bottom)  
2 Pressure Cooker Accessories 1 Qty (extra rubber, valve etc.)  
3 Steel Thali 1 Qty (to be used as Plate and Chakla)  
4 Rolling Pin (Belan) 1 Qty  
5 Office Tiffin Boxes & Bag 1 Qty  
Sr. No. Item Quantity Tick Mark
1 Office Wear 6 Pairs per week (includes 1 casual pair)  
2 Belts 1 Black + 1 Brown + 1 Casual  
3 Underwear 8 for a week  
4 Socks 7 Pairs (including 2 white cotton)  
5 Shoes 1 Office + 1 Casual  
6 Slipper 1 Pair  
7 Winter wear heavy jacket 1 Qty (Choose type depending on time of year)  
8 Wind Cheater / Rain jacket 1 Qty  
9 Umbrella 1 Qty  (Depending on region and rains)  
10 Thermals 2 Pair for winter season. 1 Pair for summer season  
11 Woollen Cap 1 Qty (Any time of year)  
12 Woollen Socks 1 Qty (Any time of year)  
13 Monkey Cap 1 Qty (Winter season only)  
14 Muffler 1 Qty (Winter season only)  
15 Woollen Hand Gloves 1 Qty (Winter season only)  
Cosmetics Etc.
Sr. No. Item Quantity Tick Mark
1 Body Lotion 1 Big Bottle per 3 weeks  
2 Face Lotion 1 Olay per 2 month  
3 Lip Guard 1 Qty  
4 Grooming kit (Scissor, Nail-Cutter) 1 Qty  
5 Shaving Kit 1 Qty (1 Blade per 30 Days)  
6 Bar of Soap 1 Qty for 30 Days  
7 Tooth Paste 1 Medium size for 30 Days  
8 Tooth Brush + Tongue Cleaner 1 Qty  
9 Cloth Washing Detergent 2 Small sachets per 1 week  
10 Cloth Washing Soap 1 Small Bar  
Electrical & Electronics
Sr. No. Item Quantity Tick Mark
1 Convertor Plug 1 Qty  
2 Kindle 1 Qty  
3 SIM  Card of the country 1 Qty  
4 Laptop, Charger, Mouse 1 Qty  
5 LAN Cable or Wireless modem 1 Qty (as per need)  
6 Mobile Charger (and Mobile) 1 Qty  
Sr. No. Item Quantity Tick Mark
1 Passport 1 Qty  
2 Wallet with Cash and Cards 1 Qty  
3 Ticket Printout 1 Qty  
4 LOA/Invitation Letter Prinout 1 Qty  
5 Hotel Booking Printout 1 Qty  

Friday, July 29, 2016

Difference between HTTP PUT and POST

Difference between PUT and POST

The key difference between PUT and POST is that PUT is idempotent while POST is not. No matter how many times you send a PUT request, the results will be same. POST is not an idempotent method. Making a POST multiple times may result in multiple resources getting created on the server.

Another difference is that, with PUT, you must always specify the complete URI of the resource. This implies that the client should be able to construct the URI of a resource even if it does not yet exist on the server. This is possible when it is the client's job to choose a unique name or ID for the resource, just like creating a user on the server requires the client to choose a user ID. If a client is not able to guess the complete URI of the resource, then you have no option but to use POST.

PUT http://MyService/Persons/
Won't work. PUT requires a complete URI
PUT http://MyService/Persons/1
Insert a new person with PersonID=1 if it does not already exist, or else update the existing resource
POST http://MyService/Persons/
Insert a new person every time this request is made and generate a new PersonID.
POST http://MyService/Persons/1
Update the existing person where PersonID=1

It is clear from the above table that a PUT request will not modify or create more than one resource no matter how many times it is fired (if the URI is same). There is no difference between PUT and POST if the resource already exists, both update the existing resource. The third request (POST http://MyService/Persons/) will create a resource each time it is fired.

HTTP Operations, Safe and Idempotent operations..

Operation performed on server
Read a resource.
Insert a new resource or update if the resource already exists.
Insert a new resource. Also can be used to update an existing resource.
Delete a resource .
List the allowed operations on a resource.
Return only the response headers and no response body.

A Safe operation is an operation that does not have any effect on the original value of the resource. For example, the mathematical operation "divide by 1" is a safe operation because no matter how many times you divide a number by 1, the original value will not change. 

An Idempotent operation is an operation that gives the same result no matter how many times you perform it. For example, the mathematical operation "multiply by zero" is idempotent because no matter how many times you multiply a number by zero, the result is always same. 

Similarly, a Safe HTTP method does not make any changes to the resource on the server. An Idempotent HTTP method has same effect no matter how many times it is performed. Classifying methods as Safe and Idempotent makes it easy to predict the results in the unreliable environment of the Web where the client may fire the same request again.

Wednesday, January 13, 2016

Configuration steps to start the Workflow Notification mailer in Test environments


At times, there is a need to receive the notification emails that are sent through the Oracle workflow mailer in Development and Test environments. However, these emails should not go to the mailboxes of the users of the system. Instead, they should be redirected to a common mailbox. This blog article is a step by step guide to configure the workflow mailer for the above objective.

Important Note: These steps should NEVER be performed in the production environment.


Part 1 - Configure the mail server and email sender

1)      Login using ‘SYSADMIN user and go to responsibility  ‘Workflow Administrator Web Application’ > Workflow Manager

2)     You will see Notification mailer is Down

3) Click on ‘Down’.You will find the below window.

4) To Configure Workflow Mailer, press on Edit button

5) You will find the below window

6) Set the Server Name to your Email /SMTP server. Set the ‘Reply-To-Address’ to ‘’.

7) Click on button 'Advanced'

8) Press 'Next'

9) Press 'Next'

10) Press 'Next'

11)   Update from field to ‘Workflow Mailer <Name of the Test Environment>’ for e.g. “Workflow Mailer DEV”

Part 2 - Configure the override address

Override address is the address where all the emails will redirected. This can be configured from front end also. However following are the steps to set it up from back end.

1)      Run the below sql statement

    select fscpv.parameter_value
      from fnd_svc_comp_params_tl fscpt
          ,fnd_svc_comp_param_vals fscpv
     where fscpt.display_name = 'Test Address' 
                     and fscpt.parameter_id = fscpv.parameter_id;

2) The result should be ‘NONE’

3) Now run the below sql update statement and commit

UPDATE fnd_svc_comp_param_vals fscpv 
  SET fscpv.PARAMETER_VALUE = '' --( put the email address to which all emails will be redirected)
WHERE fscpv.parameter_id 
(SELECT fscpt.parameter_id
  FROM fnd_svc_comp_params_tl fscpt
 WHERE fscpt.display_name = 'Test Address');

4) Now run the SQL in Step 1 to verify that the email address has been set as required.

5) Now start the workflow mailer by going to ‘Workflow Administrator Web Application’ > Workflow Manager.   You will see Notification mailer is Down. Click on 'Down'. On next page '1)      Select ‘Start’ from drop down list and Press on Go button.

6) After the above step the workflow notification mailer should start and the status should be 'Running'.

Part 3 - Test the setup

1) Click on 'Workflow Notification Mailer'.

2)  Click on ‘Test Mailer’

3) Select a valid user for which email address has been setup and click 'Accept' button.

Two test emails should be sent to the email address that you have setup in the Part 2 (step 3). The emails should not be sent to the actual email address that is set for the user that you have selected.

This completes the steps needed to redirect emails on your test or development environment. Enjoy!!

Thursday, July 30, 2015

Oracle Applications : Delete concurrent program & executable

The concurrent program and executable cannot be deleted from Oracle Applications front end,  instead you can only disable the concurrent program. This is because if deletion is allowed then the corresponding history of previous runs, audit records will be left with orphan records.

But sometimes during the development phase, you would want the option of deleting the concurrent program and executable. Following is the code snippet to delete a concurrent program and its executable from database.

------------------Program Short Name, Application Name 
if fnd_program.PROGRAM_EXISTS('XXWS01A',''My ABC Application') then
   fnd_program.DELETE_PROGRAM('XXWS01A',''My ABC Application');
end if;

------------------Executable Short Name, Application Name 
if fnd_program.EXECUTABLE_EXISTS('XXWS01A',''My ABC Application') then
   fnd_program.DELETE_EXECUTABLE('XXWS01A','My ABC Application');
end if;



Tuesday, June 16, 2015

Basic Accounting and Finance

Accounting is internally and operationally oriented. It mostly deals with transactions that have taken place and data that's been recorded.
It also includes preparing, presenting and interpreting financial statements.

Finance is more strategically oriented. It often involves factors external to the organisation, and its activities are aimed at aiding decision making.
Finance deals with planning related and futuristic information.
Finance areas include short-term and long-term financing, management and control of assets and investments, and determining and managing project risks.

Types of Accounting
1) Cash Based - In this type, business records cash inflow and outflow.
2) Accrual Based - In this type, business records sales revenue as soon as the sales is made, regardless of when the customer pays.

Cash based accounting is inadequate for most businesses, as they sell and buy on credit, carry inventories, invest in long term operating assets or make long term commitments such as employee pensions.

Cash based accounting is okay for personal accounts, businesses usually have accrual based accounting.

Types of record keeping documents
1) Journal - A book that records a businesses transaction in chronological order. Journalization is the daily recording of debits and credits.
Journals - also referred to as the 'books of original entry' - are where all the transactions are entered first. Businesses may maintain separate journals for different types of transactions for e.g. sales journal for recording sales transactions etc.

2) Ledger - The ledger - or General Ledger, as it is sometimes called - is distinct from a journal. The ledger is where the various accounting entries are sorted into their appropriate accounts. This is called 'Posting to the ledger'. The ledger is the 'book of final entry' and all financial statements are prepared from it.

Types of Risk
Default Risk - refers to the likelihood that you will fail to get your money back or receive the return you are due. Assessing this risk means deciding if the company in which investment is made is likely to default.

Inflation Risk - refers to the chances that predictable overall economic rise in prices for goods and services will cause the investments to loose some of its value. Investment in long term ventures presents greater inflation risk than short term ventures.

Maturity Risk - refers to the gamble taken when investors tie up their cash in investments that require a set period. When money in tied up in long term investments, it cannot be used for other, perhaps more profitable purposes.

Liquidity Risk - refers to the possibility that an investment may need to sold to free up cash. An investment's liquidity is how readily it can be converted back to cash prior to maturation, or if that's even possible. The easier it is to sell off asset when needed, the lower the liquidity risk.

Accounting Principles
Business Entity Principle - As per this principle the purpose of accounting is to keep records of the transaction only for the organization, not for the people involved.

Money Management Principle - Considers only the financial aspects of the business (such as gross profit, net profit etc.), allowing simple evaluation and comparison.

Going Concern Principle - Maintains businesses will operate over an extended period, so valuation of assets can be simplified.

Cost Based - Use the price originally paid for an item for accounting purposes, as it's a convenient and objective value.

Realization Principle - Holds that revenue should be recorded at the time goods or services are delivered (i.e Accrual based accounting).

Basic Accounting  Equation
Assets = Liabilities + Owner's Equity

Three Financial Statements - Characteristics

Earnings Statement, P&L Statement
   => Statement for a given period of time.
   => It is is the statement of Profit.
   => Shows net profit (or losses) as the difference between revenues and expenses
   => Shows the profitability and the operations of a company over a specific period of time
Cash Flow Statement
   => Statement for a given period of time.
   => It is the statement of Liquidity.
   => Shows the actual cash inflows and outflows from operating, investing, and financing activities.
   => Shows the change in cash balances for a specific period of time.

Balance Sheet
   => Statement at a point in time.
   => It sums up the financial condition.
   => Shows the financial position of a company at a certain point in time
   => Balances assets owned by a company with its liabilities plus owners' (or shareholders') equity

Relationship between the statements
Net Income from Earnings Statement is used to calculate the Cash Flow Statement. It is the first line in the Cash Flow Statement.
Net Cash at the end of Cash Flow statement is used as a Current Cash in the Balance Sheet statement.
Net Income from Earnings Statement is used as Retained Earnings in Balance sheet (assuming no dividends are paid).

Some other points
Revenue => Something which is recognized when the transaction takes place (i.e. the Customer receives the value). This principle of recognizing revenue when a transaction takes place is called 'Accrual Based Accounting', this is the method that is generally accepted by all major Accounting standards.
The other principle of recognizing revenue when the actual cash is received is called 'Cash Based Accounting', this is not preferred method of accounting.
Mainly because so many business work on credit nowadays.

Receipts => Actual receipt of the cash. May be at a different date than the revenue recognition date, generally later.

Income Statement (Profit & Loss Statement
Gross profit  = Net revenue - cost of goods sold
Operating income =  Gross profit - operating expenses
Net income  = Operating Income - Expenses - Taxes

Balance Sheet
Balance sheet should represent the equation
Assets = Liabilities + Equity
Assets = Current Assets + Fixed Assets
Liabilities = Current Liabilities + Long Term Liabilities
Equity = Shareholder's Equity Investment + Retained Earnings
Retained Earnings = Previous Retained Earnings + Net Income - Dividends Paid.

Cash Flow Statement
Cash flow statement is required because normally the 'Accrual Based' accounting is followed, which doesn't give true picture of the Cash.
If 'Cash Based' accounting is followed then there would be no need to generate a Cash flow statement.

1) Operating Activities - show cash transactions that create revenues and expenses. Often these related to current assets and liabilities.
( Current Asset is one that can be easily converted to cash. Example of current assets are Cash, Bonds, Accounts Receivable
  Current Liability are obligations that need to be settled within within one year or less (or to be settled in same fiscal year).
  Example of current liabilities are Short term bank loans, Account Payable, Wages Payable, Tax Payable, Interest Payable)
Cash flows in from the sale of goods and services, from interest on loans, and from dividends received.
Cash flows out to suppliers for inventory, to employees for wages, to the government for taxes, to lenders for interest on loans, and to others for various expenses.

2) Investing Activities - show cash transactions that affect fixed assets.
(Fixed assets, also referred to as long term assets, are assets used by organization that won't be converted to cash immediately.
 Fixed assets are those that an organization needs to produce goods and services. For example property, plant and equipment are fixed assets).
Cash flows in from the sale of property, plant, and equipment; from the sale of debt or equity securities of other businesses; and from the collection of principal on loans to other businesses.
Cash flows out to purchase property plant, and equipment; to purchase debt or equity securities of other businesses; and to make loans to other companies.

3) Financing Activities - show cash transaction related to long-term liabilities and equity financing.
( Long term liabilities are obligations that won't be fulfilled within the next 1 year (or fiscal year).
  Example of Long term liabilities are mortgages that persist over a number of years, bonds payable, pensions
  Equity financing encompasses cash provided by Owner/Shareholder and Dividends paid)
Cash flows in from the sale of the company's own stock and from issuing bonds and notes.
Cash flows out to stockholders as dividends, to repay long-term debt, and to repurchase the company's own stock.