Maven Command Line Options

Posted: February 4, 2013 in Uncategorized

http://www.sonatype.com/books/mvnref-book/reference/running-sect-options.html

http://www.akadia.com/services/ora_interpreting_explain_plan.html

ISO 8601 Date and Time Format

Posted: October 12, 2012 in Uncategorized

ISO 8601 Date and Time Format – International standard for dates and times representation.

e.g

Year:

YYYY (eg 1997)

Year and month:

YYYY-MM (eg 1997-07)

Complete date:

YYYY-MM-DD (eg 1997-07-16)

Complete date plus hours and minutes:

YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)

Complete date plus hours, minutes and seconds:

YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)

Complete date plus hours, minutes, seconds and a decimal fraction of a

second

YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)

where:

YYYY = four-digit year

MM = two-digit month (01=January, etc.)

DD = two-digit day of month (01 through 31)

hh = two digits of hour (00 through 23) (am/pm NOT allowed)

mm = two digits of minute (00 through 59)

ss = two digits of second (00 through 59)

s = one or more digits representing a decimal fraction of a second

TZD = time zone designator (Z or +hh:mm or -hh:mm)

T = Denotes the start of time

1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time.

1994-11-05T13:15:30Z corresponds to the same instant.

SQL to create Oracle Sql Array. Input and output array.

CREATE TYPE array_input AS TABLE OF VARCHAR2 (100);CREATE TYPE array_output AS TABLE OF VARCHAR2 (100);

Stored procedure which receives array from java and returns sql array to java.

CREATE OR REPLACE PROCEDURE arraydescriptorproc (p_array_in IN array_input, p_arr_out OUT array_output)AS v_count NUMBER;BEGIN

p_arr_out := NEW array_output ();

FOR i IN 1 .. p_array_in.COUNT

LOOP

p_arr_out.EXTEND;

DBMS_OUTPUT.put_line (p_array_in (i));

p_arr_out (i) := p_array_in (i);

END LOOP;

END;

/

Java Program to pass java array to sql array which is used in oracle stored procedure. This program also fetches the value from oracle sql array to java array.

package pradeep;

import java.sql.CallableStatement;import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import oracle.jdbc.OracleCallableStatement;

import oracle.jdbc.internal.OracleTypes;

import oracle.sql.ARRAY;

import oracle.sql.ArrayDescriptor;

public class TestArrayDescriptor {

public static void main(String args[]) {

try {

Connection connection = getConnection();

String inputArray[] = { “APPLE”, “MANGO”, “WINE”, “BEER” };

CallableStatement st = executeStoredProcedure(connection, inputArray);

printOutputArrayFromStoreProcedure(st);

} catch (Exception e) {

e.printStackTrace();

}

}

private static Connection getConnection() throws ClassNotFoundException, SQLException {

Class.forName(“oracle.jdbc.OracleDriver”);

Connection connection = DriverManager.getConnection(“jdbc:oracle:thin:url “, “SCPP”, “Password11g”);

return connection;

}

private static void printOutputArrayFromStoreProcedure(CallableStatement st) throws SQLException {

ARRAY arr = ((OracleCallableStatement) st).getARRAY(2);

String[] outputArray = (String[]) (arr.getArray());

for (String str : outputArray) {

System.out.println(“Output: ” + str);

}

}

private static CallableStatement executeStoredProcedure(Connection connection, String[] inputArray) throws SQLException {

ArrayDescriptor des = ArrayDescriptor.createDescriptor(“ARRAY_INPUT”, connection);

ARRAY array_input = new ARRAY(des, connection, inputArray);

CallableStatement st = connection.prepareCall(“call arraydescriptorproc(?,?)”);

st.setArray(1, array_input);

st.registerOutParameter(2, OracleTypes.ARRAY, “ARRAY_OUTPUT”);

st.execute();

return st;

}

}

An ExecutorService that can schedule commands to run after a given delay, or to execute periodically.

Below is a Java program to schedule a service which periodically beeps every 10seconds for one hour.

import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;

class BeeperControl {
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

public static void main(String[] args){
beepForAnHour();
}

public static void beepForAnHour() {
final Runnable beeper = new Runnable() {
public void run() {
System.out.println(“beep”);
}
};
final ScheduledFuture beeperHandle = scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);

scheduler.schedule(new Runnable() {
public void run() {
beeperHandle.cancel(true);
}
}, 60 * 60, SECONDS);
}
}

Java Decompiler

Posted: February 13, 2012 in Uncategorized

http://java.decompiler.free.fr/?q=jdeclipse

Click the above link.

It’s a easy to use eclipse Plugin Java Decompiler.

Life Cycle of a Trade/End-to-End

Posted: January 11, 2012 in Financials

1. Client Onboarding:
- Sign ISDA Master agreement and CSA Credit support annex.
- Collect Clients data and store in reference data.
- KYC, SPN is created.
- Collateral agreements and margins are agreed.
- Credit Rating checks are performed.
2. Trade Execution: Occurs when traders buy or sell a financial product. This may/may not involve a exchange.
3. Trade Capture/Support: The trades are input into a relevant risk management system.
4. Profile & Loss/Risk Reporting: How much money we made or lost. Realized and Unrealized profit/loss are calculated.
5. Confirmation: The details of trade are sent to clients for confirmation. It may electronic email/phone confirmations.
6. Settlement: Involes pre/actual/post settlement activities.
7. Accounting: GLRS general ledger reconcilation process is the process of reconciliating the month end ledger balances to the sub-ledger and source transaction system.

Handlers for Uncaught Exceptions
The run method of a thread cannot throw any checked exceptions, but it can be terminated by an unchecked exception. In that case, the thread dies.
However, there is no catch clause to which the exception can be propagated. Instead, just before the thread dies, the exception is passed to a handler for uncaught exceptions.

The handler must belong to a class that implements the Thread.UncaughtExceptionHandler interface.
That interface has a single method, void uncaughtException(Thread t, Throwable e)

As of JDK 5.0, you can install a handler into any thread with the setUncaughtExceptionHandler method().
You can also install a default handler for all threads with the static method setDefaultUncaughtExceptionHandler()of the Thread class.
A replacement handler might use the logging API to send reports of uncaught exceptions into a log file.

If you don’t install a default handler, the default handler is null. However, if you don’t install a handler for an individual thread, the handler is the thread’s ThreadGroup object.
The ThreadGroup class implements the Thread.UncaughtExceptionHandler interface.

Its uncaughtException method takes the following action:
1. If the thread group has a parent, then the uncaughtException method of the parent group is
called.
2. Otherwise, if the Thread.getDefaultExceptionHandler method returns a non-null handler, it is
called.

Search “Pradeep” in all the files in all sub directories from the current directory.

find . | xargs grep -s ‘Pradeep’

Search “Pradeep” in all *.txt files in all sub directories from the current directory.

Find . –name “*.txt” | xargs grep ‘Pradeep’

What is Quartz Scheduler?

Posted: November 21, 2011 in Best Practices, Technicals

What is Quartz?

Enterprise Job Scheduler

Quartz is a full-featured, open source job scheduling service that can be integrated with, or used alongside virtually any Java EE or Java SE application – from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that may execute virtually anything you may program them to do. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.

Quartz is freely usable, licensed under the Apache 2.0 license.

http://www.quartz-scheduler.org/