About Me

My photo
I am kinda person who likes to challenge things .. and gets better everyday .. well.. I like to meet new ppl and new culture as well.

Thursday, December 20, 2007

Invoking Java from PL/SQL

After struggling for few days to enable Java PL/SQL integration... At last, I managed to make it work!

Ok, let's get down to business ..

I need to create a Java Stored procedure that will be called by PL/SQL. This Java method needs to return a collection of POJOs.

To create a Java method that returns basic Java data type to PL/SQL is very easy. Since Oracle already provides default data type mapping from basic Java data type to basic SQL type, such as java.lang.String to VARCHAR2.

But, what to do if you need to return a collection of complex POJOs?
Well .. we will go through it now ..

There are 2 difficulties to implement this approach
1 - How to map a Java POJO with SQL Data type?
2 - How to return a collection of POJOs to PL/SQL?

For this purpose, I have separated 2 sections to explain it, well .. 3 sections actually

Overview
Our company asked me to do POC on whether we can implement new application using Oracle Forms that calls Java module in the backend.
Theoretically, we can achieve this by utilizing Oracle JVM, whereby our PL/SQL calls the loaded Java libraries. The Oracle Forms will then call the respective PL/SQL.
But, this is still in theory, that is why we need to do POC to ensure it is working.

Requirements
  • Ensure your Oracle DB Server version is 9i or above.

  • Ensure your Oracle Client has "loadjava" and "dropjava" tools installed - they are part of Oracle Development Java utilities section during Oracle Client installation.

Develop and bind the Java Bean into Oracle DBMS
  • Creates the POJO bean (JAdviser.java) by implementing SQLData and Serializable interfaces.

  • Compile the bean and load it into Oracle JVM using "loadjava" utility.

  • Creates new Oracle TYPE (ADVISER) to bind this POJO bean in the database.

The source codes are like below

Java bean

package test;

import java.io.Serializable;
import java.sql.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;

public class JAdviser implements SQLData, Serializable {
    
    /**
    * Default UID given by Eclipse.
    */
    private static final long serialVersionUID = 1L;
    
    private String agentKey;
    
    // Ensure you have the value here, Capital, and not null.
    private String sql_type = "ADVISER";
    
    public JAdviser() {}
    
    public JAdviser(String key) {
        this.agentKey = key;
    }
    
    public String getKey() {
        return agentKey;
    }
    
    public void setKey(String agentKey) {
        this.agentKey = agentKey;
    }
    
    public String getSQLTypeName() throws SQLException {
        return sql_type;
    }
    
    public void readSQL(SQLInput stream, String typeName) throws SQLException {
        sql_type = typeName;
        agentKey = stream.readString();
    }
    
    public void writeSQL(SQLOutput stream) throws SQLException {
        stream.writeString(agentKey);
    }
}


PL/SQL to bind the Java bean

CREATE or REPLACE TYPE adviser AS OBJECT
EXTERNAL name 'test.JAdviser' LANGUAGE JAVA USING SQLData
(
agentKey varchar2(100)
external name 'java.lang.String',

constructor function adviser
return self as result,

member function getKey
return varchar2 as language java
name 'test.JAdviser.getKey() return java.lang.String',

member function getSQLTypeName
return varchar2 as language java
name 'test.JAdviser.getSQLTypeName() return java.lang.String'
);



Test the object has been properly registered inside Oracle

SELECT object_name, object_type, status
FROM user_objects
WHERE object_name LIKE '%JAdviser';



Develop the Java Stored Procedure and bind it
  • Creates the Java stored proc (TestFunction.java)
  • Compile and load it into Oracle JVM using "loadjava" utility.
  • Creates new Oracle TYPE (ADVISERLIST) to hold the returned Java collection.

Create Java stored Procedure
This is the actual Java stored procedure that constructs the Java bean, return
the collection of the Java bean to the PL/SQL.


package test;

import java.sql.SQLException;

import oracle.jdbc.OracleDriver;
import oracle.jdbc.driver.OracleConnection;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

public class TestFunction {
    
    public static oracle.sql.ARRAY getAdvisers(String tableName)
    throws SQLException {
        String agentKeys[] = new String[] {"101", "202", "303"};
        JAdviser[] adviserList = new JAdviser[agentKeys.length];
        
        for (int iCnt = 0; iCnt < agentKeys.length; iCnt++) {
            JAdviser adviser = new JAdviser();
            adviser.setKey(agentKeys[iCnt]);
            adviserList[iCnt] = adviser;
        }
        
        // Built-in connection when running in the database.
        OracleConnection conn = (OracleConnection) new OracleDriver()
        .defaultConnection();
        
        // Bind the Java array to the database UDT.
        ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
        "ADVISERLIST", conn);
        
        System.out
        .println("Descriptor type: " + arrayDescriptor.getArrayType());
        
        // Create the return array.
        return new ARRAY(arrayDescriptor, conn, adviserList);
    }
    
}


Creates the "container" to hold the returned Java Collection
As you know, we need to create a SQL TYPE to hold the collection

CREATE or REPLACE TYPE ADVISERLIST is TABLE OF adviser;



PL/SQL to bind the Java stored procedure in DBMS

CREATE OR REPLACE FUNCTION
testFunction (tableName varchar2) RETURN ADVISERLIST
AS LANGUAGE JAVA
NAME 'test.TestFunction.getAdvisers (java.lang.String) return oracle.sql.ARRAY';





Next, just test this new function by calling it directly:

SELECT testFunction ('dummy') FROM DUAL;

That's all, it is as simple as that.
However, please note these hints below to make it work

Hints
  • All Java methods must be public static except if the Java Class implements SQLData interface

  • It is strongly suggested, to develop Java stored procedure or any Java objects that shall be called by PL/SQL, to implement java.sql.SQLData interface or Oracle Datum interfaces, to keep the nature of its Object Oriented approach

  • Implementing SQLData interface requires you to properly implement readSQL(...) and writeSQL(...) methods, plus getSQLTypeName() which returns the SQL TYPE name of this object in Capitals and not null!

  • To return 2 objects or more from Java stored procedure to PL/SQL, the Java return type must be in Array, either oracle.sql.ARRAY or java.sql.Array

  • SQL Type inside the PL/SQL that receives that array shall be Nested Table for easier development, syntax: TYPE ... is TABLE OF ...





Sunday, December 16, 2007

Benefits of working abroad (Singapore)

Related with my previous post on How to get IT job in Spore

Getting an IT Job outside Indonesia is a challenging process, but worth to try, for sure!

Take an example, to work in our neighbor country, such as Singapore.
Singapore has been developed rapidly since recent 15 years with clear vision and goals.

This extensive and rapid development in many sectors, including IT sector, will surely requires lots of man-power, highly skilled ones.

However, talented skills are still considered as scarce resources in Singapore, including IT professionals.

To boost the availability of these scarce resources, Singapore Government, which was initially very strict on importing foreign workers, are now opening the door wider by encouraging talented professionals from whole over the world to come and work in Singapore.

One of its new Policy is to introduce new type of Self-sponsor Work Permit, called Personal Employment Pass (PEP) - http://pubweb.fdbl.com/ihp8/global/media85.nsf/public-country-briefs/singapore?opendocument

Because of this new Policy and other benefits that employers in Singapore offer, Singapore is now becoming to be one of the most targeted Country to work and live.

Benefits that we can get if working in Singapore:
  1. Standard 13th month salary, this is a mandatory from the Government of Singapore.
  2. Lots of types of Leaves, from annual leaves, child care leaves, family leaves, etc. The annual leaves itself can be up to 21 days per annum.
  3. CPF contribution from Employer, outside our Basic Salary, which is considered high, about 15% per month.
  4. More money we can have for saving.
  5. Relatively higher annual bonus (depends on our KPI and Company's KPI)
  6. Regular salary increase every year
  7. Medical coverage for in-patient and out-patient (GP and Specialist)
  8. Extremely efficient environment, from Public transports up to Government services.
  9. Singapore is considered as one of the most safe and secure place to work and invest money to do business. This will surely contribute to excellent economic growth.
  10. and many more....

The main thing is, if considered as when I was working in Indonesia and now here, at least I can concentrate more on my job and pursue clearer Career Path.

Saturday, December 15, 2007

Getting an IT job in Spore


I have been dreaming of working abroad since long time ago, but did not know how to get one.

My main reason to get a job outside Indonesia is simply because I really want to improve my quality of life which was quite terrible when I was still working in Indonesia.

Just imagine with only about Rp. 8 million (about US$888) per month and we need to cover our whole family needs from housing, meals, insurance, education, etc. This was surely not enough to get a decent life.

Then comes this opportunity to go abroad by using Agency service.
I was using their service because I did not know anything about working abroad and how to apply a job.

In return, I have to pay for $4,500 SGD for their service, which is, to me, is really expensive. They will try their best to get me some interviews, but can't guarantee if I can secure the job or not!

Well.. this is understandable, but with that amount of money, is just too much!
However, I really made up my mind to move on, so I just signed the contract and pay them in advance - which might be considered as risky decision!

They did their job to find me some interviews, but was not that easy get a job. I have to stay in Singapore with my own pocket money while waiting for the interviews.

Anyway, fast forward .. finally I got the Job to work as Contract Team Leader in Prudential Singapore - which was my first job here in Singapore.

To those who wants to get a job in Singapore, you have 2 options, either by:
(1) hire Agency Service and pay a lump sum of money, in advance, or
(2) get the job by yourself

First option surely will require you to prepare lots of money, at least about $5,000 to $6,000 - this is including the agency fees and your cost of living in spore while waiting for the interviews.

Second option does not mandate you to have that much of money, but the uncertainties are higher than going through agency.

Why?

Ok, let's see the facts about Singapore and its culture.

  • Singapore holds East culture strongly, whereby people rely on family, relatives or friends opinions on making decisions, including decision to hire someone as Employee!
  • Agencies (Agents) usually already made some connections with the Employers, hence they can convince the Client better, then we as foreign, strangers to them can do.
  • Even if you say you have 8 years experience in your CV with lots of experience letters from your previous employers in Indonesia.
  • Indonesians are well known in Singapore as poor, below standards Human resources. This is sad, but true. Thus, your 8 years (for example) experience in Indonesia is considered nothing to them. If you go through 3rd party, such as Agency, it means they are your representatives to the Client.
  • And as Singapore-based companies, these agencies can at least remove the bad images about Indonesian people, since the Clients see the Agency image not us.
  • Singaporeans are speaking English very fluently, compared to their foreign peers, well .. except Caucasians, surely they are better. On the other hand, Indonesians are usually not that good on using English - this Blog is an example of it :). Usually, our Resume is written in English but not really convincing, since it might not well understandable by employers in terms of expectations, career objective, etc. Creating a professional resume that can speaks loudly itself is not that easy to do, especially using English. These agencies can help you to achieve that, for sure.
  • There are lots of foreign workers from many countries who would love to work in Singapore, even if they have to sell their lands! This creates fierce competition to Indonesians who wants to work in Singapore. They are mostly go through agencies, and ready to lose their money, if worst things happen - such as he/she can't secure any job. These foreign workers, mostly from India and China, are tough hardworking people and have the guts to risk their money. In addition, they are also very good and professional on their works.

If we see from this angle, we as Indonesian people, is not really at the good position, and does not have strong bargaining position to get a job.

But, one thing that I always said to myself is
"believe yourself, and show them what you are made of!"

If you have read the my blog till this point, it means you are really have the strong will to go abroad especially to Singapore.

Well .. then let me share my tips on how to secure a job, especially IT job in Singapore. Assuming you don't wanna go through Relocation agencies like me.

I hope with these Tips and your strong unstoppable efforts, you can get it:

First things first
Go to Singapore, just for sight seeing, 1-2 days. Look around and see if you still wanna work and stay in Singapore for long. Get a flight from Jakarta to Batam, and from Batam gets a Ferry to Singapore. This way will costs you much lesser than getting direct flight from Jakarta to Singapore. If you have friends or relatives working in Singapore, visit them. Ask him/her if you can borrow his Address and mailbox for mailing purpose. And while there, buy a Prepaid Card, such as M1 or Singtel cards. If possible, top it up with some money and bring it back to Indonesia, do not throw it!! Why? I will explain later.

Once you have made up your mind, nothing can stop you to work in Singapore, then you can proceed to the next tips, otherwise no need to continue on reading this.

  1. Practice your English and advance it to the next level without any hesitate. Skill on communication using English is your first image and gives the most impact on finding the job. Without it, your IT skills are nothing. Please note, soft skills such as Communication skill is really important in Singapore. Employers much more prefer people who has right attitude than IT experts with harsh words!

  2. Get a Skill certificate. For God's sake, this is really a very powerful key to mesmerize the Employers. Even if you have to burn some of your money to attend a class for Certificate preparation, just go for it! But be very selective on the Certificates you want to acquire. Go for Vendor-related certs, such as those from Sun, IBM, CISCO, etc. However, Project Management certs will surely bites more than technical ones, like PMP (Project Management Professional) from PMI.

  3. Practice yourself to have these 2 principles "No Pain No Gain" and "There is always a way". This works for me, and I am sure they can work for anyone as well!

  4. Creates your Professional Resume. Sell yourself like an Artistic, Unique masterpiece. Because you are! Do not just use plain boring English, pour your strong will and determination inside the resume so that they can feel you are really interested to get a job. Your resume must have these 3 points, and you must emphasize them properly. They are Availability Date, Current SalaryExpected Salary. For those who are first time applying a job in Singapore, DO NOT, I repeat, DO NOT put the amount of Expected Salary there. Use more diplomatic approach such as "Expected Salary: Negotiable". This way, employers will have more questions to ask to you later (at Interview). If you do put the amount, then the chance to secure a job will be smaller.

  5. Since you have visited Singapore, already written down your friends Address in Singapore and already have Singapore's mobile number at hand. Use these information (Singapore Address and Mobile Number) as your contact point on the Resume. Please never, ever, ever put local Indonesia address and your local Indonesia mobile number on the resume, I can guarantee you, they will never contact you!!

  6. Search for a Job that really matches your Resume on the websites, such as Jobstreet.com and Monster.com.sg. Also go for Jobs on the company website directly. Do not apply for a job that doesn't match your criteria, in terms of skills and experience. If you have long experience, look for similar requirements. If you are a seasoned developer, do not apply for a Java Programmer with 1-2 yrs experience. You are gonna kill yourself there! Also, the other way around, do not apply if your experience does not meet the requirements, they might blacklist you. Apply as many as you can, but DO NOT send your resume to the same company more than once, that is if you want to keep your Good image. If you do that, you will just degrade your bargaining position.

  7. Once you have tired of applying jobs, activate your Singapore cellphones. And wait for the calls. Also check your email more frequently. You can also make some arrangements with your friend there if he/she is willing to be the contact point between you and the companies. That means, he/she is the one who is gonna receive their calls and let you know that you have an interview.

  8. Pack the interview schedules as much as you can. Which means, arrange them as close as possible. So that you can go to Spore, attend the interviews and fully completes them in just few days. Please note that Singapore is a very efficient country, usually Contract positions will just require 2-3 days from interview date to the outcome. If no news after 2-3 days, then you can go back to Indonesia, otherwise stay.

  9. Try to get jobs with Contract positions first, afaik, this is the fastest way to get a job in Singapore. Permanent position is usually for Singaporeans or Singapore PR.

  10. Last but not least, do pray to God. In my experience on applying for the jobs, I was always only believe myself without considering God. That was why almost all of my applications were rejected, until the very last moment, I give everything to God and ready to accept for the worst scenario to happen - then suddenly I got the Job from the best employers that had interviewed me so far that time. So, please do pray to God, otherwise all of these tips will not work.
Pheww.. I guess that's all I know. I am open for discussion on this. On my next post, I will elaborate benefits of working in Singapore.

Saturday, October 13, 2007

GWT, doing AJAX easier and faster

I heard about this new technology few months ago.
But, just get the chance to try it with simple coding.

First impression: its just fun using this framework.
Doing the presentation layer with AJAX built-in seems like playing toys.

I remember my old times when I was started doing Java programming with AWT API.
Create a button, assign event listener to it, handle the event, then display the Text "Hello World" !

Using GWT is like migrating the GUI-based, standalone application to a Web based, distributed application!

However, GWT is much more than that. It enables us to interact with the Server-backend for complex business rules processing, and then displays the information in a nicely interactive manner which really enhances the User experience.

It is also Web Server friendly, since most of the load which was occur in the Server is now transferred to Client's PC (AJAX concept). This means reducing network traffic, thus proving high scalability for this type of Application.

And to AJAX developers, it relieves their pains to enable AJAX in their applications.

GWT was initially talking to backends (Servlet-based objects) via RPC on HTTP protocol. But now it supports POJO based objects. Which means supports Spring-based objects!

This is the new feature offered by GWT 1.4 with GWT-SL 0.1.4. libraries.

I am now trying to test this new feature, GWT Spring Integration, using GWTHandler.

Will keep you guys posted once I am done with it.

Thursday, October 11, 2007

J2EE Certificate .. is it worth?

Sun Certified Enterprise Architect .. hmm .. sounds cool..

I was anxious about this certificate, thus invested some money to prepare for it.
However, when doing my research to know more about this certificate, especially its advantages for career advancement,
I soon figured out that it seems not really important.

Some of information that I found were like this:

"... Certification does not really matter .. It is experience does matter"
Quoted from one of J2EE evangelist out there.
He said companies will prefer more to people with longer experience then younger ones but with Certificate.

J2EE, actually EJB 1.x / 2.x, was losing its popularity due to the nature of its specification .. heavyweight, high learning curve, difficult performance tuning ..etc.
And unfortunately, EJB 2.x is part of SCEA curriculum.
Well .. I don't know if it is still .. or perhaps upgraded to EJB 3.0?

Gaining certificate for J2EE requires lots of costs - time and money. However, your current employer would be hesitant to increase your package significantly. At least, this is what I heard from others.
Thus, in terms of ROI, I think this will not be a good investment though!

Other certifications in Management, such as PMP (Project Management Professional) attracts employers more
.. which means more money for the achiever!

Now I feel so confuse on how to accelerate my career, just working smarter seems not enough nowadays.
I think there must be a way to advance my career to the next level without certification (?)

Anybody, what do you think about this?

Monday, October 8, 2007

Living a life in spore

Today, I feel so lazy to go to work ..
It seems that I feel saturated aldy .. however..this is the life that I have to live with

I have a family which really relies on me ..and I feel very responsible for them ..
It sounds cliche' .. but in reality it is not .. its just the way we have to go for it..

When I was young .. if I don't like something I will leave it .. and just go .. thats it!

But it is not the way anymore .. especially in Spore ..
and especially living with my family ..

Yep .. I am now working in Spore ..
but now everything seems very difficult here ..
govt increase GST another 2% (from 5% to 7%) ..
property market getting worst last year ..

My rent fee was only $900 .. now it is $1,350 ..
highly increased right!?

But no point to complain .. as I always said to myself ..

"There is always a way .. "

I do believe this .. I always do ... and will always be ..

Besides, everytime I come home ..
my wife and my little sweet daughter will smile at me ..
and says "Waalaikum salam warahmatullah.."

Although difficult, I will stick with my plan to stay here ..
have enough saving and go back to Indonesia .. my lovely country!

Living in Singapore is not so bad ..
in Bahasa we just say "Ada suka dukanya deh .. " :)