Wednesday, May 07, 2008

Make your JAVA application as executable jar file.

1. get the class file for the source code. create package structure for the class file.
In our example i have created a java file with a package structure as com.oracle.samples.HELLOWORLD.java.
Source Code for HELLOWORLD.java file.

package com.oracle.samples;

public class HELLOWORLD
{
public HELLOWORLD()
{
System.out.println("Iam printing from the HELLOWORLD constructor");
}

public static void main(String[] args) {
HELLOWORLD h = new HELLOWORLD();
}

}


D:\jdevstudio10133\jdk\bin\jar cvf HELLOWORLD.jar com\oracle\samples\HELLOWORLD.class

2. Create an empty folder and name it as META-INF.

3. Create a txt file and open that file in an editor. add the following line to it. Once added that line then hit the enter to get an empty line.
The empty line is very important, otherwise your manifest addition will not work.

main-class: com.oracle.samples.HELLOWORLD

D:\jdevstudio10133\jdk\bin\jar umf manifest.txt HELLOWORLD.jar

4. Once you done with the above steps you are ready to run the executable jar file.

D:\jdevstudio10133\jdk\bin\java -jar HELLOWORLD.jar

Note: If you want to add some jar files for your application you need to follow the steps below.
Create a folder called "lib" drop the your jar files under the folder example: log4j-1.2.13.jar or ojdbc14.jar
In the manifest.txt file you have to add one more line to it, add the below line.
Class-Path: lib\ojdbc14.jar lib\log4j-1.2.13.jar
After entering the above in the manifest.txt file you have hit the enter to have a empty line. This is very important otherwise you will get exception.

If you want to add properties file, you have to follow the below steps.
You can add the properties file inside the jar file or you can keep outside the jar file.

Monday, May 05, 2008

ORA-01000: maximum open cursors exceeded

Assum that you are looping through your result set.

If you get the "ORA-01000: maximum open cursors exceeded" error in java class, please check the following.

1. You should be having only one statemens object using connection(either statement, prepared statement or callable statement) and only one connection.

2. To make only single object for statements you can use the following check point before creating a new statements. It could be for any statements.
The below example is for prepared statement.
if(oPreparedStatement == null)
{
oPreparedStatement = oConn.getPreparedStatement(sPersonIdentifierQuery);
}

3. In your finally block don't forget to close the connection, statements and make them null. By following thies way you can get rid of the "ORA-01000: maximum open cursors exceeded exception".

4.The use of prepared statement is to compile the sql query and use it asmany time as you want, no need to prepare the statement again and again.

Thursday, April 24, 2008

How to title your pop-up window in javascript

I was recently asked by a colleague to help in a requirement with javascript.
She wants to have a popup window with a title on it. Normally it will have the url of the window as title.
The below is an example to get a title as we want.

function popitup2()
{
newwindow2=window.open('','name','height=200,width=150,resizable=1');
var tmp = newwindow2.document;
tmp.write('<--html-><--head-><--title->popup<--/--title->');
tmp.write('<--/head-><--body-><--p->this is once again a popup.<--/p->');
tmp.write('<--/body-><--/html->'); tmp.close();
}

This resolved her problem. Thanks to Kyle Varga

Friday, April 04, 2008

Simple way to implement Log4j in your applications

a. Download the log4j.jar file from the following web page.
http://logging.apache.org/log4j/docs/download.html
b. I have used apache-log4j-1.2.15.jar version in my example.
c. Add this jar file into your java project.
d. Import the log4j classes(Logger) into your java classes.
org.apache.log4j.Logger;
e. i have created a logger class in which i have a static method which return the logger object. In that static method,it has a Hashtable object which will hold the logger object.If second time called, the method will check in the Hashtable and if any logger object available, it will be retured. otherwise it will create a new object and stored in the Hashtable object and return the Logger object created.
public static Logger getLogger(String strLogName)

{
objHashTable = new Hashtable();
Logger log = (Logger)objHashTable.get(strLogName);
if(log == null)
{
log = Logger.getLogger(strLogName);
objHashTable.put(strLogName, log);
}
return log;
}
f. The configuration in the log4j.properties is as follows.
#log4j.rootLogger=DEBUG, A1, A2log4j.logger.A1=ALL,A1log4j.logger.A2=ALL,A2
# This is to print on the Console# log4j.appender.A1=org.apache.log4j.ConsoleAppender
# This is to write to a Log File

log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.MaxBackupIndex=10
log4j.appender.A1.MaxFileSize=10MB
log4j.appender.A1.File=D:/OHIOLog.log
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d - %m%n# --Print the date in ISO 8601 format# log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
#---- Below for A2 configuration# This is to write to a Log File

log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A2.MaxBackupIndex=10
log4j.appender.A2.MaxFileSize=10MB
log4j.appender.A2.File=D:/BadDatas.log
log4j.appender.A2.layout=org.apache.log4j.PatternLayout

log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d - %m%n# --Print the date in ISO 8601 format# log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
In this example iam using 2 different log files, one for logging the error and debug messages and the other for collecting the bad datas which cannot be inserted into the table with any of thefollowing failures.
1. Primary Key constraints2. FK constrains3. Null values
Iam capturing the entire sql statement if any error occured during insert. In this example iam using 2 files A1 and A2.A1 will capture the debug and error messages.
In my java classes i will be using like the folloing statement.
try{

String sPersonInsert = "Insert into persons(person_id, name)values(iPersonId,sName)";
// Example of debug message logging into log file.

UnivLogger.getLogger("A1").debug("Database connection established ");
}catch(SQLException eSQLException)

{
// Example of error message logging into log file.
UnivLogger.getLogger("A2").error("The failed insert SQL statement is ==>"+sPersonInsert);
}
If you have any question, please update this post with your comments, i will get back to you with answers. Happy Coding.

If you want to print only the log message, with out any time stamp in it, in use the following conversion pattern
log4j.appender.A2.layout.ConversionPattern=%m%n

Tuesday, March 25, 2008

How to insert data into mulitple tables in a single statement

In one of my projects, i had a requirement to insert data into more than one table, as i dint get a chance to get more experience in pl/sql, so i asked some of my colleagues "can we insert data into more than one table" everybody said we cannot.
I just don't want to write a procedure for this and i want to insert data into more than one tables. so i cannot use the below example as well because, with this you can insert into a single table only
insert into table_name values (select * from table_name)
I just thought googling to get some answer, i luckily found some forums which was explaining the "INSERT ALL " concept, with this concept you can insert into more than one table.
The below example will give you clear idea about the "INSERT ALL" concept.
Example:
1. Create a table A and B
2. Insert data into A and B in a single statement
create table tablea (sno number, name varchar2(20));
create table tableb (sno number, name varchar2(20));
3. insert all
into tablea(name) values ('THIS IS TABLE A')
into tableb(sno, name) values ('1','THIS IS TABLE B')
select 1 from dual;
4. select * from tablea;
Name
----------
THIS IS TABLE A
5. select * from tableb;
sno Name
----------------
1 THIS IS TABLE B
This is a new concept comes up with the 10g (10.1.2) feature. Make use and Enjoy.
I got the above information from a forum answered by Nicolas.Gasparotto.
Thanks Nicolas.

Monday, March 24, 2008

Self Appraisal

I got the below story from my friend last week, thanks Sakthi
A little boy went into a drug store, reached for a soda carton and pulled it over to the telephone. He climbed onto the carton so that he could reach the buttons on the phone and proceeded to punch in eight digits (phone numbers).
The store-owner observed and listened to the conversation:
Boy: 'Lady, Can you give me the job of cutting your lawn?
Woman: (at the other end of the phone line): 'I already have someone to cut my lawn.'
Boy: 'Lady, I will cut your lawn for half the price of the person who cuts your lawn now.'
Woman: I'm very satisfied with the person who is presently cutting my lawn.
Boy: (with more perseverance): Lady, I'll even sweep our curb and your sidewalk, so on Sunday you will have the prettiest lawn in all of Palm beach, Florida.'
Woman: No, thank you.With a smile on his face, the little boy replaced the receiver.

The store-owner, who was listening to all this, walked over to the boy.
Store Owner: 'Son... I like your attitude; I like that positive spirit and would like to offer you a job.'
Boy: 'No thanks,
Store Owner: But you were really pleading for one.
Boy: No Sir, I was just checking my performance at the job I already have.
I am the one who is working for that lady, I was talking to, and I was doing my 'Self Appraisal'

How to setup SVN in your Desktop / Laptop

How to setup SVN in your Desktop / Laptop

How to configure the SVN set up to your laptop / Desktop
1. Download and install the TortoiseCVS-1.8.1.exe, wincvs - setup.exe
2. Download and install TortoiseSVN-1.4.4.9706-win32-svn-1.4.4.msi
3. After installation, create a folder in your local directory and right click and click on the network link
4. Configure the proxy setting
Host Name: oracle proxy Port Number: 80
No need of username and password.
5. After configuration right click on the folder and select checkout module, enter the url where you want to check out. It will prompt you with, username and password for SVN access. https://hostname/svn/foldername/
6. Once you enter the username/password then you can get the entire folder and all the required documents.
If you have any doubts, update this post with your error messages, wll resolve it

Friday, March 21, 2008

How to get the port numbers after installing SOA 10g Suite and How to make connection using JDeveloper to the SOA Suite 10g

To know the port numbers after installation, refer to the following file in the below locations.
1. Home\bpel\utilities\ant-orabpel.properties file
2. Make note of the ports being used by the following properties.
· http.port
· opmn.requestport
These port values are required, while making connection to the application server and integration servers.

3. Run the below command in the /opmn/bin folder
opmnctl status -port
To get the other port numbers

opmnctl status -l output
by running the above commands you can get the opmn ports.
How to make connection to the SOA Suite using JDeveloper
While creating connection to the application server, you will be asked to check the deploy password check box. Please check the deploy password check box, otherwise whenever you deploy the process, you will be asked to enter the password again and again.
While creating connection to the application server, these are the parameters used for the connection.

In the Jdev click on the Connection Navigator tab, click on the Application Server connection and create new connection.
1. Provide a new name for the connection, ex: SOASuiteAppConn
2. Enter the following information.
a.UserName: oc4jadmin
b. Password: password
c. HostName: hostname or ipaddress
d. Single instance / Group : select accroding to your requirement
e. Oc4jInstanceName : Key-in the oc4j container name.
f. opmn port : opmn port number
3. Click next and check your connection using the test button.

Integration Connection:
Click on the integration connection in the same connection navigator window.
1. Provide a name for the integration server connection, ex: SOASuiteIntegConn.
2. In the connection tab, use the application server connection here (SOASuiteAppConn)
Provide the HostName or ip address.
Enter the port number.
3. Click next, here test your connection. You should be able to see the following connection with out fail.
Application Server: OK
BPEL Process Manager Server: OK
ESB Server: OK
If you still not able to make connection, please update this post with your comments.

Monday, March 17, 2008

Oracle ESB - Enterprise Service Bus

What is Inbound and Outbound in ESB : Oracle Enterprise Service Bus Server enables you to define inbound and outbound adapter services. An inbound adapter service receives data from an external data source and transforms it into an XML message. An outbound adapter service sends data to a target application by transforming an XML message into the native format of the target application.

Oracle AIA

I have attended Oracle AIA Deep Dive from 10-14 March 2008. Oracle AIA stands for Oracle Application Integration Architecture, a new integration architecture from Oracle, using Oracle SOA components.

CAVS in AIA
CAVS expanded as Composite Application Validation System. This is used to test your integration points of the applications. If you want to test your integration scenaios you can test individual end points with your really integrate. TEST is used to test your live endpoints. To TEST you end points you have send the request soap messages, the webservice will send you the response. To

BPEL Tips

1. Whenever you use a custom xsd file, drop the file under the bpel folder inside the project folder. So that you can avoid some compilation errors. After copying the xsd and you have defined the request and response according to that, and if you are not able to see those values in structure window under the variables. Even after you did couple of time refresh, restart the JDeveloper. I hope this issue is fixed in Jdev 11g, i havent tried. If you have tried this, please update me with your comments.

2. Whenever you are using the EMAIL functionality of the BPEL process, dont forget to mention the from account, if you are using the from account as "Default" make sure the first letter in CAPS, otherwise the the bpel process will not throw any error message, but the mail will not be sent.

Difference between BPEL and ESB

What is the difference between BPEL and ESB
Adv BPEL
Bpel is used for orchestration of processes.
Bpel is deployed to the server.
Bpel maintains the version control for the process deployed.

Adv ESB
ESB is mainly used for virtualization of endpoints, routing and transformation.
ESB is a light weight component.
ESB is registered to the server.
ESB doesn't maintain the version control. whenever you register it will delete the old version and register with new code.

How many ways you can call a BPEL Process

A BPEL Process deployed on the Process Manager can be invoked in 3 different ways as mentioned below.

a. Using the BPEL Console's Initiate tab, this is where you will mention about the xml data to be passed into the bpel process. You can define the input in 2 ways either in XML format or HTML format.
b. Using the Java API published by Oracle BPEL Process Manager
c. Using the Web service/Soap Interface using endpoint of the process.
d. Creating the web service client using the WSDL file of the process.