Saturday, December 31, 2005

Eclipse Startup Issue: java.lang.ClassNotFoundException: javax.xml.parsers.SAXParserFactory

Today when I started my Eclipse, it simply refused to!!! It simply flashed an alert asking to look into log file. And log file simply said:

!SESSION Dec 31, 2005 10:50:19.810 ---------------------------------------------
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US

!ENTRY org.eclipse.osgi Dec 31, 2005 10:50:19.810
!MESSAGE Error registering XML parser services.
java.lang.ClassNotFoundException: javax.xml.parsers.SAXParserFactory
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.core.runtime.adaptor.EclipseAdaptor.registerEndorsedXMLParser(
at org.eclipse.core.runtime.adaptor.EclipseAdaptor.frameworkStart(
at org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start(
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$
at Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(
at org.eclipse.osgi.framework.internal.core.StartLevelManager.launch(
at org.eclipse.osgi.framework.internal.core.SystemBundle.resume(
at org.eclipse.osgi.framework.internal.core.Framework.launch(
at org.eclipse.osgi.framework.internal.core.OSGi.launch(
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(
at java.lang.reflect.Method.invoke(Native Method)
at org.eclipse.core.launcher.Main.basicRun(
at org.eclipse.core.launcher.Main.main(

!ENTRY org.eclipse.osgi Dec 31, 2005 10:50:19.852
!MESSAGE Startup error
java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.eclipse.core.runtime.adaptor.PluginConverterImpl.parsePluginInfo(
at org.eclipse.core.runtime.adaptor.PluginConverterImpl.fillPluginInfo(
at org.eclipse.core.runtime.adaptor.PluginConverterImpl.convertManifest(
at org.eclipse.core.runtime.adaptor.EclipseBundleData.generateManifest(
at org.eclipse.core.runtime.adaptor.EclipseBundleData.loadManifest(
at org.eclipse.core.runtime.adaptor.EclipseBundleData.getManifest(
at org.eclipse.core.runtime.adaptor.EclipseBundleData.loadFromManifest(
at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultBundleData.initializeNewBundle(
at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultAdaptor$1.begin(
at org.eclipse.osgi.framework.internal.core.Framework.installWorkerPrivileged(
at org.eclipse.osgi.framework.internal.core.Framework$
at Method)
at org.eclipse.osgi.framework.internal.core.Framework.installWorker(
at org.eclipse.osgi.framework.internal.core.Framework.installBundle(
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(
at org.eclipse.core.runtime.adaptor.EclipseStarter.installBundles(
at org.eclipse.core.runtime.adaptor.EclipseStarter.loadBasicBundles(
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(
at java.lang.reflect.Method.invoke(Native Method)
at org.eclipse.core.launcher.Main.basicRun(
at org.eclipse.core.launcher.Main.main(

!ENTRY org.eclipse.osgi Dec 31, 2005 10:50:19.863
!MESSAGE Bundle initial@reference:file:c:/eclipse0/plugins/org.eclipse.core.runtime_3.0.0/ [192] was not resolved.

I checked the classpath. Everything seemed same as before. So, what to do? I simply picked up the Eclipse from a collegue's machine and started it. and What?!!! It bombed again, saying the same old story. Then I checked that Eclipse was not working on his machine as well. So what to do now?
Then it occured to me that something else is interrupting Eclipse to start; something that is a new installed entity for both the machines. Both of us had installed Oracle 9i client a day before, it was the first time that the Eclipse was being restarted. So, I simply modified the 'path' entry - remove
C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;
from the path, and restart Eclipse. It works again!

Wednesday, December 28, 2005

Useless Facts

  1. It is impossible to lick your elbow.
  2. A crocodile can’t stick it’s tongue out.
  3. A shrimp’s heart is in their head.
  4. A pregnant goldfish is called a twit.
  5. On average, a human being will have sex more than 3,000 times and spend two weeks kissing in their lifetime.
  6. Rats and horses can’t vomit.
  7. If you sneeze too hard, you can fracture a rib. If you try to suppress a sneeze, you can rupture a blood vessel in your head or neck and die. If you keep your eyes open by force, they can pop out.
  8. Rats multiply so quickly that in 18 months, two rats could have over million descendants.
  9. Wearing headphones for just an hour will increase the bacteria in your ear by 700 times.
  10. If the government has no knowledge of aliens, then why does Title 14, Section 1211 of the Code of Federal Regulations of US, implemented on July 16, 1969, make it illegal for U.S. citizens to have any contact with extraterrestrials or their vehicles?
  11. The cigarette lighter was invented before the match.
  12. Thirty-five percent of the people who use personal ads for dating are already married.
  13. A duck’s quack doesn’t echo, and no one knows why.
  14. Most lipstick contains fish scales.
  15. Cat’s urine glows under a black-light.
  16. Like fingerprints, everyone’s tongue print is different.

[Received in an email]

Saturday, December 24, 2005


No Need to Click Here - I'm just claiming my feed at Feedster

Wednesday, December 7, 2005

Remote Debugging with Eclipse

Levent Gurses has published an article on Remote Debugging with Eclipse. He has touched Weblogic, JBoss and Tomcat server.

toString() Generator plugin for Eclipse

While working in my latest project, I came across a situation where I needed a toString method for my TO (Transfer Object) classes. Instead of using reflection, I simply downloaded Eclipse Plugin for toString generation. Restart the Eclipse and it is ready to be used. For any class that require a toString(), switch to Package Explorer, and right click on the class name. Select 'Generate toString' from the context menu, select the fields, and the method is there in the class!

I had this plugin for quite some time, and had actually forgotton that its not the part of Eclipse. So, in my current project, when I failed to see 'toString generator', I realized it a plugin :)

Besides toString, if you like to see equals() and hashCode() methods as well, use Commonclipse plugin.

Saturday, November 26, 2005

[Humor] Excerpts from HER & HIS Diaries


I asked him what was wrong - he said, "Nothing." I asked him if it was my fault that he was upset. He said it had nothing to do with me and not to worry.
On the way home, I told him that I loved him, but he simply smiled and kept driving.
I can't explain his behavior; I don't know why he didn't say, "I love you too."

When we got home, I felt as if I had lost him, as if he wanted nothing to do with me anymore. He just sat there and watched TV; he seemed distant and absent.

Finally, I decided to go to bed. About 10 minutes later he came to bed.

I decided that I could not take it anymore, so I decided to confront him with the situation but he had fallen asleep. I started crying and cried until I fell asleep.
I do not know what to do. I'm almost sure that his thoughts are with someone else.

My life is a disaster.


Today India lost the cricket match again. DAMM IT.

Wednesday, November 16, 2005

Google Analytics

Added Google Analytics (formerly known as urchin), the new Web Analysis Software Tool acquired by Google, and unlike Urchin, it is free to be used. Results are pretty cool and quite graphical in nature.

Friday, November 11, 2005

[Humor] Call Centre Jobs

Call Centre Jobs: People often wonder why they are paid so much...for just being on the phone. Take a look...

  1. Tech Support: "I need you to right-click on the Open Desktop."
    Customer "Ok."
    Tech Support: "Did you get a pop-up menu?"
    Customer: "No."
    Tech Support: "Ok. Right click again. Do you see a pop-up menu?"
    Customer "No."
    Tech Support:: "Ok, si r. Can you tell me what you have done up until
    this point?"
    Customer: "Sure, you told me to write 'click' and I wrote 'click'."
  2. Customer: "I received the software update you sent, but I am still getting the same error message."
    Tech Support:: "Did you install the update?"
    Customer: "No. Oh, am I supposed to install it to get it to work?"
  3. Customer:: "I'm having trouble installing Microsoft Word."
    Tech Support:: "Tell me what you've done."
    Customer: "I typed 'A:SETUP'."!
    Tech Support:: "Ma'am, remove the disk and tell me what it says."
    Customer:: "It says '[PC manufacturer] Restore and Recovery disk'."
    Tech Support:: "Insert the MS Word setup disk."
    Customer:: "What?"
    Tech Support: "Did you buy MS word?"
    Customer: "No..."
  4. Customer:: "Do I need a computer to use your software?"
    Tech Support:: ?!%#$
  5. Tech Support:: "Ok, in the b ottom left hand side of the screen, canyou see the 'OK' button displayed?"
    Customer: "Wow. How can you see my screen from there?"
  6. Tech Support:: "What type of computer do you have?"
    Customer:: "A white one."
  7. Tech Support:: "Type 'A:' at the prompt."
    Customer:: "How do you spell that?"
  8. Tech Support: "What's on your screen right now?"
    Customer: "A stuffed animal that my boyfriend got me at the grocery store."
  9. Tech Support:: "What operating system are you running?"
    Customer: "Pentium."
  10. Customer: "My computer's telling me I performed an illegal abortion."
  11. Customer: "I have Microsoft Exploder."
  12. Customer: "How do I print my voicemail?"
  13. Customer: "You've got to fix my computer. I urgently need to print document, but the computer won't boot properly."
    Tech Support: "What does it say?"
    Customer: "Something about an error and non-system disk."
    Tech Support: "Look at your machine. Is there a floppy inside?"
    Customer: "No, but there's a sticker saying there's an Intel inside."
  14. Tech Support: "Just call us back if there's a problem. We're open 24 hours."
    Customer: "Is that Eastern time?"
  15. Tech Support:: "What does the screen say now?"
    Customer: "It says, 'Hit ENTER when ready'."
    Tech Support:: "Well?"
    Customer: "How do I know when it's ready?"
  16. A plain computer illeterate guy rings tech support to report that his computer is faulty.
    Tech: What's the problem?
    User: There is smoke coming out of the power supply.
    Tech: You'll need a new power supply.
    User: No, I don't! I just need to change the startup files.
    Tech: Sir, the power supply is faulty. You'll need to re place it.
    User: No way! Someone told me that I just needed to change the startup and it will fix the problem! All I need is for you to tell me the command.

    10 minutes later, the User is still adamant that he is right. The tech is frustrated and fed up.
    Tech: Sorry, Sir. We don't normally tell our customers this, but there is an undocumented DOS command that will fix the problem.
    User: I knew it!
    Tech: Just add the line LOAD NOSMOKE.COM at the end of the CONFIG.SYS. Letme know how it goes.

    10 minutes later.
    User: It didn't work. The power supply is still smoking.
    Tech: Well, what version of DOS are you using?
    User: MS-DOS 6.22.
    Tech: That's your problem there. That version of DOS didn't come with NOSMOKE. Contact Microsoft and ask them for a patch that will give you ! the file. Let me know how it goes.

    1 hour later.
    User: I need a new power supply.
    Tech: How did you come to that conclusion?
    User: Well, I rang Microsoft and told him about what you said, and he started asking questions about the make of power supply.
    Tech: Then what did he say?
    User: He told me that my power supply isn't compatible with NOSMOKE

Which one is the best u like :)

Friday, October 28, 2005

JDBC Performance Pointers

Here are a few of the JDBC Performance pointers. Hopefully, there are a lot more, which you may be aware of, but not mentioned here. Care to share them as well?

  • Get database connection from connection pool rather than getting it directly
    Use batch transactions.
  • Choose right isolation level as per your requirement.
  • TRANSACTION_READ_UNCOMMITED gives best performance for concurrent transaction based applications. TRANSACTION_NONE gives best performance for non-concurrent transaction based applications.
  • Your database server may not support all isolation levels, be aware of your database server features.
  • Use PreparedStatement when you execute the same statement more than once.
  • Use CallableStatement when you want result from multiple and complex statements for a single request.
  • Use batch update facility available in Statements.
  • Use batch retrieval facility available in Statements or ResultSet.
  • Set up proper direction for processing rows.
  • Use proper getXXX() methods.
  • Close ResultSet, Statement and Connection whenever you finish your work with them.
  • Write precise SQL queries.
  • Cache read-only and read-mostly tables data.
  • Fetch small amount of data iteratively rather than whole data at once when retrieving large amount of data like searching database etc.
  • Use Type one driver if you don't have a driver for your database. This is a rare situation because all major databases support drivers or you will get a driver from third party vendors.
  • Use Type two driver for two tiered applications to communicate from java client to database that gives better performance than Type1 driver.
  • Use Type three driver to communicate between client and proxy server ( weblogic, websphere etc) for three tiered applications that gives better performance when compared to Type 1 &2 drivers.
  • Use Type four driver for applet to database communication that is two tiered applications and three tiered applications when compared to other drivers.
  • Pass database specific properties like defaultPrefetch if your database supports any of them.

Tuesday, October 25, 2005

Friday, October 21, 2005

Flock is here (Developer Review Release)

Have just installed Flock, the new Firefox based browser. Too early for any review, it is still deep in the 'developer review'. Download and check it out yourself. Actually, I got the invitation to check it from Flock guys. They even sent me a userid/password, but I didnt require it to download it :))

Thursday, October 20, 2005

Friday, October 14, 2005

Google Home page in 2084

Srinivas has published an image of the 'purposed' Google Home Page in 2084. Check it out :: A Java Geek's Diary : Weblog

Monday, October 10, 2005

Spam Comments

In the past few days, some of my posts have been receiving 'spam comments'. Therefore, I have enabled the word-verification option to discourage the spammers. Hope, it wont discourage the people who really want to share the experiences.

Monday, September 26, 2005

Smile Test

I got a link to Smile Test all thanx to Srinivas's JRoller Blog.
Take this smile test to test your ability in identifying the genuine, fake smiles. Smile will appear only once and you have to decide in the mean time.

I could get only 10 out of 20 :(

Seralizing a Singleton - More on readResolve method

This refers to my earlier post on Sep 21 regarding Serializing a Singleton. Here are a few more pointers for readResolve method:
  • Use a readResolve method to protect the 'instance-control invariants' of singletons and other instance-controlled classes. Consider the following Singelton class

public class Elvis {
private Elvis() {
... // Remainder omitted

  • This class would no longer be a singleton if the words “implements Serializable” were added to its declaration.
  • If the Elvis class is made to implement Serializable, the following readResolve method suffices to guarantee the singleton property:

private Object readResolve() throws ObjectStreamException {
// Return the one true Elvis and let the garbage collector
// take care of the Elvis impersonator.
return INSTANCE;

  • A readResolve method is necessary not only for singletons, but for all other instance controlled classes.
  • A second use for the readResolve method is as a conservative alternative to the defensive readObject method.
  • Following readResolve method can be used in lieu of the defensive readObject method:

// The defensive readResolve idiom
private Object readResolve() throws ObjectStreamException {
return new Period(start, end);

  • The accessibility of the readResolve method is significant.
    • A readResolve method on a final class, such as a singleton, it should be private.
    • For a readResolve method on a non final class, consider its accessibility. If it is private, it will not apply to any subclasses. If it is package-private, it will apply only to subclasses in the same package. If it is protected or public, it will apply to all subclasses that do not override it.

Friday, September 23, 2005

The Evolution of a Programmer

I am just checking my pst. It still brings a few smiles.

High School/Jr.High

20 END

First year in College
program Hello(input, output)
writeln('Hello World')

Senior year in College
(defun hello
(cons 'Hello (list 'World))))

New professional
void main(void)
char *message[] = {"Hello ", "World"};
int i;

for(i = 0; i < 2; ++i)
printf("%s", message[i]);

Seasoned professional

class string
int size;
char *ptr;

string() : size(0), ptr(new char('\0')) {}

string(const string &s) : size(s.size)
ptr = new char[size + 1];
strcpy(ptr, s.ptr);

delete [] ptr;

friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);

ostream &operator<<(ostream &stream, const string &s)
return(stream << s.ptr);

string &string::operator=(const char *chrs)
if (this != &chrs)
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);

int main()
string str;

str = "Hello World";
cout << str << endl;


Master Programmer
library LHello
// bring in the master library

// bring in my interfaces
#include "pshlo.idl"

cotype THello
interface IHello;
interface IPersistFile;

module CHelloLib

// some code related header files

// needed typelibs

coclass CHello
cotype THello;

#include "ipfix.hxx"

extern HANDLE hEvent;

class CHello : public CHelloBase

CHello(IUnknown *pUnk);

HRESULT __stdcall PrintSz(LPWSTR pwszString);

static int cObjRef;

#include "thlo.h"
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)

HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
printf("%ws\n", pwszString);


// when the object count goes to zero, stop the server
if( cObjRef == 0 )


#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

HANDLE hEvent;

int _cdecl main(
int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries

CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
ulRef = pCF->Release();

// Tell OLE we are going away.


extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }

#include "pshlo.h"
#include "shlo.hxx"
#include "clsid.h"

int _cdecl main(
int argc,
char * argv[]
) {
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = '\0';
wcsT[0] = '\0';
if( argc > 1) {
mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
else {
fprintf(stderr, "Object path must be specified\n");

// get print string
if(argc > 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
wcscpy(wcsT, L"Hello World");

printf("Linking to object %ws\n", wcsPath);
printf("Text String %ws\n", wcsT);

// Initialize the OLE libraries

if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath, &pmk);
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

if(SUCCEEDED(hRslt)) {

// print a string out

ulCnt = pHello->Release();
printf("Failure to connect, status: %lx", hRslt);

// Tell OLE we are going away.


Apprentice Hacker
$msg="Hello, world.\n";
if ($#ARGV >= 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n";
print (FILE $msg);
close(FILE) || die "Can't close $arg: $!\n";
} else {
print ($msg);

Experienced Hacker
#define S "Hello, World\n"
main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Seasoned Hacker
% cc -o a.out ~/src/misc/hw/hw.c
% a.out

Guru Hacker
% cat
Hello, world.

New Manager
20 END

Middle Manager
mail -s "Hello, world." bob@b12
Bob, could you please write me a program that prints "Hello, world."?
I need it by tomorrow.

Senior Manager
% zmail jim
I need a "Hello, world." program by this afternoon.

Chief Executive
% letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout


[Humor] What is inheritance?

Interviewer: Mr. Singh, Can u tell me, what is inheritance.

Sardaar : (Embarrassed by this simple que.) When U make love to ur wife and she bears a child, that is Inheritance.

Interviewer was a thorough professional and was not disturbed by Sardaar's reply. But he wanted to have some fun.

Interviewer: Then what is Multiple Inheritance?
Sardaar : When U and ur neighbour make love with ur wife and ur wife bears a single child, that is multiple inheritance.

Interviewer: What is Virtual Function?
Sardaar: When ur neighbour makes love with ur wife and u assume that, the child is urs.

Interviewer: What is Pure Virtual Function?
Sardaar: When u r impotent and still ur wife bears a child.

This was too much for the interviewer; so he got angry and got up. but the sardarjee was very cool. He said immediately, "no problem, just assume that ur wife is an abstract base class and allow her to be derived as many times as possible.

A few Nice Quotes

  • Regular naps prevent old age... especially if you take them while driving.
  • Having one child makes you a parent; having two makes you a referee...
  • "Marriage is a relationship in which one person is always right and the other is the Wife!"
  • I believe we should all pay our tax with a smile. I tried but they Wanted cash...
  • A child's greatest period of growth is the month after you've purchased New school uniforms.
  • Don't marry the person you want to live with, marry the one you cannot live without... but whatever you do, you'll regret it later.
  • You can't buy love, but you pay heavily for it...
  • True friends stab you in the front
  • Laziness is nothing more than the habit of resting before you get tired.
  • My wife and I always compromise. I admit I'm wrong and she agrees with me.
  • Those who can't laugh at themselves leave the job to others.
  • They call our language the mother tongue because the father seldom gets to speak.

[Humor] Born Programmer

Received the pic in an email :)

Thursday, September 22, 2005

Programmers to Testers

Top 20 replies by Programmers to Testers when their programs don't work:

20. "That's weird..."
19. "It's never done that before."
18. "It worked yesterday."
17. "How is that possible?"
16. "It must be a hardware problem."
15. "What did you type in wrong to get it to crash?"
14. "There is something funky in your data."
13. "I haven't touched that module in weeks!"
12. "You must have the wrong version."
11. "It's just some unlucky coincidence."
10. "I can't test everything!"
9. "THIS can't be the source of THAT."
8. "It works, but it hasn't been tested."
7. "Somebody must have changed my code."
6. "Did you check for a virus on your system?"
5. "Even though it doesn't work, how does it feel?
4. "You can't use that version on your system."
3. "Why do you want to do it that way?"
2. "Where were you when the program blew up?"
And the Number One Reply by Programmers when their programs don't




"It works on my machine" :)

Wednesday, September 21, 2005

Serializing a Singleton

I have been forwarded some study material on Core Java related stuff from The Training Group in my Organization to prepare for a forthcoming training program. While going thro it, I came across an interesting point of which I was unaware earlier. It relates to Singleton classes. While dicussing Singleton classes, it says that
To make a singleton class serializable provide a readResolve method. Otherwise, each deserialization of a serialized instance will result in the creation of a new instance.

public class CacheMgr {
public static final CacheMgr INSTANCE = new CacheMgr();

private CacheMgr() {
// ...

// ... // Remainder omitted

// readResolve method to preserve singleton property
private Object readResolve() throws ObjectStreamException {
* Return the one true CacheMgr and let the garbage collector
* take care of the CacheMgr impersonator.
return INSTANCE;

public static void main(String[] args) {

I have not thought of this aspect so far. So, obviously, I have no experience of it either. However, I am interesting to know if you know an idea on the subject. Any first hand experience?

Thursday, September 15, 2005

Installing Bugzilla on Windows

Bugzilla is the Bugs/Issues Tracking Tool from The Mozilla Organization. Version 2.18 is the latest stable release. There are couple of resources which guide a User installing Bugzilla on a Unix/linux machine. However, this entry describes a way to install Bugzilla on a Windows machine (W2K to be precise). This document guides you step by step through the installation process.
First, get Administrative access to the machine on which you want to install Bugzilla. It should be a simple step. Usually, Users are given Administrative rights on Windows machine. However, if you dont have, contact your Administrator.

Get Bugzilla

Then download the Bugzilla from There are two ways of gettng it - through CVS or direct downloading the tar file. Remember there are no Zip files. However, any zip utility should be able to untar the Bugzilla. I download the tar file and untarred it using WinZip. I placed the untarred 'bugzilla' directory in my c: drive. So, the location of bugzilla is c:\bugzilla.


Get MySQL database. The latest production release is 4.1. Though MySQL 5.x is available under Beta, it is not recommended. Along with MySQL db, download one of the graphical client to connect to the DB Server. There are a couple of options - MySQL Control Center, My SQL Query Browser, Toad for MySQL...

Install and Configure MySQL

Complete the default installation (i.e. Typical) of MySQL db.
Create a User for database. Lets name the created user as bugs_user with password 'bugs_pass'.
Create a database. Lets name the created DB as 'bugsdb'.
Grant all access rights to user 'bugs_user' for the database 'bugsdb'.

If you are running MySQL 4.1, you may encounter the Client does not support authentication protocol requested by server error message. To fix this, once the user has been created you will have to reset the password using OLD_PASSWORD. See this blog entry.

Get Perl

Next, you need to install Perl on the machine. I installed Perl 5.8.7 from ActiveState.

Install Perl

Install Perl in the root directory. Mine is in C:\perl Plz take care that Perl is not installed in Program Files directory as it may break Perl's Template-Toolkit installer.
Create a temp directory in root.(c:\temp). If you find issues in running Bugzilla, plz see that temp is located in c:\ only.

Install Perl Modules

Next we need to install perl modules. Following are the mandatory modules:

Following are the optional modules:

Though these are not required, you may install them for creating report charts.

There are two ways to install these modules.
Go to and download file and unzip it to a location of your choice. Open a console window, go to the unzipped directory, and run the following commands sequencely
X:\>ppm install AppConfig.ppd
X:\>ppm install TimeDate.ppd
X:\>ppm install DBI.ppd
X:\>ppm install DBD-mysql.ppd
X:\>ppm install Template-Toolkit.ppd
X:\>ppm install GD.ppd
X:\>ppm install Chart.ppd
X:\>ppm install GDGraph.ppd
X:\>ppm install PatchReader.ppd

If you need to uninstall any module, use the following command:
X:\>ppm uninstall PatchReader.ppd

Get a Web Server

We need a Web Server to serve bugzilla pages. I have used Apache Web Server. You may use any other web server also, including IIS. Following steps are required to install Apache and configure it to serve bugzilla.

Get Apache

Download the latest stable Apache release from

Install Apache

Installing Apache on Windows is again a smooth process. Just follow the instructions. Make sure you Install it for All Users. Apache always install itself in Apache2 directory. On my machine, apache is in C:\Program Files\Apache Group\Apache2.

Configure Apache

Edit C:\Program Files\Apache Group\Apache2\conf\httpd.conf with your favourite text editor.

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (
Listen 80

Change the DocumentRoot setting to point to C:\Bugzilla. Note there are two locations in httpd.conf that need to be updated.

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:/Bugzilla"

# This should be changed to whatever you set DocumentRoot to.

Enable CGI support in Apache by uncommenting the AddHandler cgi-script .cgi line.

# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
AddHandler cgi-script .cgi

And allow .cgi scripts in the Bugzilla directory by adding the ExecCGI option. We also need to allow Bugzilla's .htaccess file to restrict access to sensitive documents by allowing it to override the defaults. This involves changing AllowOverride None to AllowOverride All.

Apache also needs to know to use Perl to execute .cgi files, via the ScriptInterpreterSource directive.

# This should be changed to whatever you set DocumentRoot to.

# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
# The Options directive is both complicated and important. Please see
# for more information.
Options Indexes FollowSymLinks ExecCGI

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride All

# Controls who can get stuff from this server.
Order allow,deny
Allow from all

# Tell Apache to use Perl to execute .cgi
ScriptInterpreterSource Registry-Strict

You also should add index.cgi to the DirectoryIndex list.

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
DirectoryIndex index.html index.html.var index.cgi

In order for ScriptInterpreterSource Registry-Strict to work, you also need to add an entry to the Registry so Apache will use Perl to execute .cgi files.

Create a key HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command with the default value of the full path of perl.exe with a -T parameter. For example C:\Perl\bin\perl.exe -T

Restart Apache

C:\>net stop apache2
The Apache2 service is stopping..
The Apache2 service was stopped successfully.

C:\>net start apache2
The Apache2 service is starting.
The Apache2 service was started successfully.

Bugzilla Configuration

Once all of the above steps are executed successfully, we are ready to test bugzilla installation.
On the console window, go to c:\bugzilla, and execute the following command:

If it runs without error message,then congratulations,otherwise figure out what mighty be wrong according to the error message,it is very obvious.

Now, we are ready to configure bugzilla. Open a file called localconfig in your favourite text editor.

First, update the DB info:

$db_host = "localhost"; # where is the database?
$db_port = 3306; # which port to use
$db_name = "bugsdb"; # name of the MySQL database
$db_user = "bugs_user"; # user to attach to the MySQL database
$db_pass = 'bugs_pass';

Customize following variables according to your needs to initialize mysql database

@severities,the secerity level of the bug to be specified when creating a new bug
@priorities,the priority you can assign to the bug
@opsys,possible operating system of your test environment
@platforms,hardware platform your system is running on.

You can also update these variables any time after the installation and configuration is over.

Then run the above command again,this will initialize database and create required tables.

If things go wrong during database setup,try to make sure you have edited database connect parameters correctly .
If you encounter the following error Client does not support authentication protocol ,that is because the newer version mysql use some new password encryption algorithm.

Now all we require is to configure email service. For this install a SendMail-compliant Mail Transfer Agent.

After all these steps,the bugzilla can be installed and accessed now if nothing goes wrong.

Open your favourite browser and go to http://localhost/ If all steps have had been successful, you would be at bugzilla home.

Monday, September 12, 2005

Bugzilla Installation Issue :: Help Required

I am trying to install on a Linux machine (Fedora). Facing a couple of issues(I, being a Windows guy, was to face those issues :(...

  • Anyway, I was able to install Apache successfully on this machine...tested.

  • MySQL 4.1 installation failed for some dependency issues. Got it resolved by pointing to MySQL DB on a W2K machine :)

  • All required Perl packages installed successfully...tested

  • Trying to access Bugzilla home page...failing repeatedly.

My Apache 2.0.5x is in /usr/local/apache2.
My Bugzilla 2.18.3 is in /var/www/html/bugzilla.

I have carried out the installation and configuration as per the Bugzilla manual (I hope I did it correct), but I cant access Bugzilla still. When I try to access bugzill home, it shows Internal Server Error in the browser and in the Apache log file, following message is recorded:

[Mon Sep 12 12:54:05 2005] [debug] prefork.c(956): AcceptMutex: sysvsem (default: sysvsem)
[Mon Sep 12 12:54:13 2005] [error] [client] Can't locate Bugzilla/ in @INC (@INC contains: . /usr/lib/perl5/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl) at /var/www/html/bugzilla/index.cgi line 40.
[Mon Sep 12 12:54:13 2005] [error] [client] BEGIN failed--compilation aborted at /var/www/html/bugzilla/index.cgi line 40.
[Mon Sep 12 12:54:13 2005] [error] [client] Premature end of script headers: index.cgi

I am unable to see its root cause of failure. The error seems to indicate that it cant locate Bugzilla/ file (This file location is /var/www/html/bugzilla/Bugzilla/ and it is present).

Can u plz help me?

Wednesday, September 7, 2005

Client does not support authentication protocol requested by server; consider upgrading MySQL client

Recently I installed MySQL 4.1 on my W2K machine and tried to connect to it. But could not. It threw the error
Client does not support authentication protocol requested by server; consider upgrading MySQL client

Well, I was least expecting such an error to occur. Actually, this error has revisited me. Long back, when I installed MySQL 4.1 on my previous workstation, I had encountered this error. So, the solution was easy. Just change MySQL's password hashing algorithm for your password. So, how how u do that?

mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd') WHERE Host = 'some_host' AND User = 'some_user';

Thats it :-)

Actually, MySQL offers a reason for the same

MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients.

To solve this problem, you should use one of the following approaches:
  • Upgrade all client programs to use a 4.1.1 or newer client library.
  • When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password.
  • Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program.
  • Tell the server to use the older password hashing algorithm
    Start mysqld with the --old-passwords option
    Assign an old-format password to each account that has had its password updated to the 4.1 format.

Friday, September 2, 2005


I have been assigned to prepare a checklist for my project. So, while compiling a checklist for SQLs, I suggested to use
[COLUMN_NAME is NOTNULL column] instead of
My impression was that while for COUNT(*), DB has to do a complete scan of the table, for COUNT(COLUMN_NAME), it require to scan the COLUMN only. But then, I dont know why, I just decided to google it. And I came across this AskTom Entry where it says it is just a myth that COUNT(COLUMN_NAME) is faster than COUNT(*).

I dont know how different DBs behave in this matter?

What u guys think of it? What are ur experiences?

Tuesday, August 30, 2005

Make others find your blog by location

Today I found an interesting website - GeoURL, all thanx to this blog. It is a location-to-URL reverse directory and allows you to find URLs by their proximity to a given location.

It is very easy to get a "GeoURL".

  1. Find the longitude and latitude of the blogs location

  2. Insert some metatags in the head of your webpage, my metatags is as following

  3. <meta name="ICBM" content="28.662, 77.106"/>
    <meta name="DC.title" content="Raj Blogs"/>
    <meta name="geo.position" content="28.662, 77.106"/>

  4. Register with GeoURL by using its ping form or a GET query something like this:

  5. Finally insert the HTML code generated by GeoURL into your webpage.

Find your neighbor's blog :-)

Wednesday, August 24, 2005

Google Desktop 2 and Talk

I have just installed Google Desktop 2 on my office workstation and hope to install it on my home machine later in the evening.
After installation, it is indexing the files. The 'sidebar' feature seems quite good, but Weather and Share Market info is meant only for those in US :( A big disappointment for us non-US people.
What u say of it? Any reviews?

Also, I plan to install Talk on my home machine. How it it. Has anybody used it so far? Any reviews?


XMLHTTP is Extensible Markup Language Hypertext Transfer Protocol. It is a set ofAPIs that enables XML, HTML or binary data to be transmitted to and fromWeb servers over the Internet using HTTP.
An advantage of XMLHTTP is that when files that are User Interface programs (e.g. JSPs, ASPs or CGI programs) are queried from the server, theXMLHTTP object continuously queries the server transparently to retrievethe latest information without the user having to repeatedly refresh thebrowser. XMLHTTP enables streamed content through DHMTL rather than ActiveXcontrols or Java applets.

Userful Links: Define XMLHTTP Google XMLHTTP

Blog Subscription by Email

I have introduced email based subscription for the Blog, all thanx to Bloglet. The subscription option is available in the left sidebar :-)

Monday, August 22, 2005

JSP Model 1, Model 2 Architectures and MVC Pattern

JSP Model 1, Model 2 Architectures and MVC Pattern
The early JSP specifications presented two approaches for building web applications using JSP technology. These two approaches were the JSP Model 1 and Model 2 architectures. The two JSP architectures differ in several key areas.
The major difference is in how and by which component the processing of a request is handled. With the Model 1 architecture, the JSP page handles all of the processing of the request and is responsible for displaying the output to the client. There is no extra servlet involved in the process. The client request is sent directly to a JSP page, which may communicate with JavaBeans or other services, but ultimately the JSP page selects the next page for the client. The next view is determined based on either the JSP selected or parameters within the client's request. In contrast, in the Model 2 architecture, the client request is first intercepted by a servlet, referred to as a controller servlet. This servlet handles the initial processing of the request and determines which JSP page to display next.A client never sends a request directly to a JSP page in the Model 2 architecture. This allows the servlet to perform front-end processing, including authentication and authorization, centralized logging, and help with internationalization. Once request processing has completed, the servlet directs the request to the appropriate JSP page. How the next page is determined varies widely across different applications. The main difference between the two approaches is that the Model 2 architecture introduces a controller servlet that provides a single point of entry and encourages more reuse and extensibility than the Model 1 approach. With the Model 2 architecture, there is a clear separation of the business logic, presentation output, and request processing. This separation often is referred to as a Model-View-Controller (MVC) pattern.

While the Model 2 architecture might seem overly complicated, it actually can simplify an application greatly. Web applications built using the Model 2 approach generally are easier to maintain and can be more extensible than comparable applicationsbuilt around the Model 1 architecture.

Importance of Model-View-Controller

The MVC architectural pattern is not directly related to web applications. In fact, it's quite common in Smalltalk applications, which generally have nothing to do with the Web.
The Model 2 approach is concerned with separating responsibilities in web applications. Allowing a JSP page to handle the responsibilities of receiving the request, executing some business logic, and then determining the next view to display can make for an unattractive JSP page, not to mention the maintenance and extensibility problems this entanglement causes. Application development and maintenance are much easier if the different components of a web application have clear and distinct responsibilities.

The MVC Model
Depending on the type of architecture your application uses, the model portion of the MVC pattern can take many different forms. In a two-tier application, where the web tier interacts directly with a data store such as a database, the model classes may be a set of regular Java objects. These objects may be populated manually from a ResultSet returned by a database query, or they may be instantiated and populated automatically by an object-to-relational mapping (ORM) framework such as TopLink or CocoBase.

The MVC View
The views within the web tier MVC pattern typically consist of HTML and JSP pages. HTML pages are used to serve static content, while JSP pages can be used to serve both static and dynamic content.
Most dynamic content is generated in the web tier. However, some applications may require clientside JavaScript. This does not interfere with or infringe upon the MVC concept.
HTML and JSP are not the only choice for the view. You easily can support WML, for example,
instead of HTML. Because the view is decoupled from the model, you can support multiple views, each for a different client type, using the same model components.

The MVC Controller
The controller portion of the web tier MVC design generally is a Java servlet. The controller in a web tier application performs the following duties:

  • Intercepts HTTP requests from a client
  • Translates each request into a specific business operation to perform
  • Either invokes the business operation itself or delegates it to a handler
  • Helps to select the next view to display to the client
  • Returns the view to the client

    The Front Controller pattern describes how a web tier controller should be implemented. Because all client requests and responses go through the controller, there is a centralized point of control for the web application. This helps when adding new functionality. Code that would normally need to be put in every JSP page can be put in the controller servlet, which processes all the requests. The controller also helps to decouple the presentation components (views) from the business operations, further aiding development.

    Useful Links : Sun's Patterns Catalog Front Controller Pattern

  • Here is a graphical repersentation of a typical struts based application.

    Click to view larger image

    Sunday, August 21, 2005

    JSP Performance Tips

    Here are a few tips to improve JSP performance that I have been using. If you have your own listing of the tips, plz share.

  • Disable JSP auto reloading feature.
  • Use thread pool for your JSP engine and define the size of thread pool as per application requirement.
  • Use jspInit() method to cache static data
  • Initialize the 'out' object (implicit object) with proper size in the page directive.
  • Set the content length
  • Give 'false' value to the session in the page directive to avoid session object creation.
  • Flush the data partly
  • Use StringBuffer rather than using + operator when you concatenate multiple strings
  • Use include directive instead of include action when you want to include the child page content in the translation phase.
  • Avoid giving unnecessary scope in the 'useBean' action.
  • Use print() method rather than println() method
  • Use ServletOutputStream instead of JSPWriter to send binary data
  • Minimize code in the synchronized block
  • Do not use custom tags if you do not have reusability.
  • Use 'session' and 'application' as cache.
  • Remove 'session' objects explicitly in your program whenever you finish the task
  • Use caching tags provided by different organizations like
  • Reduce session time out value as much as possible
  • Release resources in jspDestroy() method.
        • Thursday, August 18, 2005

          [Updated] JDBC Drivers

          I have updated my earlier post on JDBC Drivers. Updated version can be viewed here.

          [Humor] Being an IT Consultant

          Once upon a time there was a shepherd sitting on the side of a deserted road. Suddenly a brand new Porsche screeches to a halt. The driver, a man dressed in an Armani suit, Cerutti shoes, Ray-Ban sunglasses, TAG-Heuer wrist-watch, and a Pierre Cardin tie, gets out and asks the Shepherd: "If I can tell you how many sheep you have, will you give me one of them?"

          The shepherd looks at the young man, and then looks at the large flock of grazing sheep and replies: "Okay."

          The young man parks the car, connects his laptop to the mobile-fax, enters a NASA Webster, scans the ground using his GPS, opens a database and 60 Excel tables filled with logarithms and pivot tables, then prints out a 150 page report on his high-tech mini-printer. He turns to the shepherd and says, "You have exactly 1,586 sheep here."

          The shepherd cheers," That's correct, you can have your sheep."

          The young man makes his pick and puts it in the back of his Porsche.

          The shepherd looks at him and asks:"If I guess your profession, will you return my animal to me?"

          The young man answers, "Yes, why not". The shepherd says, "You are an IT consultant ".

          How did you know?" asks the young man.

          "Very simple," answers the shepherd. "First, you came here without being called. Second, you charged me a fee to tell me something I already knew,and third, you don't understand anything about my business... Now can I have my DOG back?"

          Servlets Vs Applets

          There are some things to note to note about Servlets as opposed to Applets.

          Firstly, the servlet and its environment is completely under the control of those deploying it. That is, you have control of which JVM is used and that this is independent of the browser used by the user. This is important as it removes concerns associated with the so-called “browser” wars.
          Secondly, a servlet is not constrained by the applet sandbox. This means that a servlet can reside behind a firewall and can communicate with any and all systems that it needs to. For example, JavaIDL can be used to connected to a CORBA compliant Object Request Broker (ORB) or sockets to connect to legacy systems (for example implemented in C).
          Thirdly, the client Web browser does not communicate directly with the servlet. Rather the browser communicates with the Web server, which in turn communicates with the servlet. Thus if the web server is secure behind a firewall, then the servlet is also secure.
          Fourthly a single Servlet can process multiple user requests. That is one instance (by default) of a Servlet is loaded into the web server and this instance services all user requests. This does not mean that each request is queued. Rather it means that each request is handled by a separate thread (of execution) that uses the same servlet instance.
          Fifthly, as each Servlet is shared amongst multiple users, care must be taken with user specific data. For example, this means that sensitive user information should not be stored in an instance variable as the instance is shared amongst many users. This can be overcome by using a HttpSession object that can be obtained from the initial request. Each session object is linked to a single user.

          How Servlets work

          Step 1: A user using a web browser requests some information from the web server via an http request.

          Step 2: The web server receives the request. If the request is for a straightforward HTML page then the appropriate HTML file will be loaded. If the request is to a servlet, then the web container will load and initiate the servlet (unless it was already running). This is done by running the servlet on a Java virtual machine (JVM).

          Step 3: The servlets’ init() method is then executed. This method is the equivalent of the init() method defined for applets. That is, it is executed only once, when the servlet is first created. It should be used in the same way as the init() method for applets. That is, as the servlets initialisation method (rather than defining a constructor). The init() method must complete before any requests are handled.

          Step 4: The servlet will receive the HTTP request and perform some ty pe of process. Each request is handled by its own thread (lightweight Java process). Depending upon the request one of the following methods will be called to handle the request:

          • doGet – handles GET, conditional GET and HEAD requests.
          • doPost – handles POST requests.
          • doPut – handles PUT requests.
          • doDelete – handles DELETE requests.

          Step 5: The servlet will return a response back to the Web server from one of the above methods.

          Step 6: The Web server will forward the response to the client.

          Step 7: When requested, the web server will terminate the servlet. This may be done by the web server administrator. At this time the destroy() method is called. This method runs only once and is used to “tidy” up any system resources used by the servlet etc. For the servlet to be run again, it must be reloaded by the web server.

          Wednesday, August 17, 2005

          A slightly bigger 'Hello World'

          The code is shown below is simplest that you can imagine and does very unusual thing!
          It is slightly bigger than "Hello World!" program but does much more. Can you make a guess what the program outputs?

          public class test{
          public static void main(String args[]){
          for (int i = 0;i < args.length; i++) {
          System.out.println("File " + i + ":" + args[i]);
          if (args.length<=0) {
          System.out.println("No files!");

          After compilation, if you run it like this:
          java test *
          it lists all files in the current directory on Windows or in any shell in UNIX.

          If you do: java test .*
          on UNIX it also shows all hidden files.

          You can ask how can we get this list without any file handling functionality in the code?
          Indeed looks mysterious...
          But in reality everything is very simple.
          When you type "*" (wildcard) OS (DOS, Windows, UNIX), not Java (!!!) sends the list of files in the current directory to your program as a list of parameters.
          And you see this list...

          Two-phase commits

          The two-phase commit protocol ensures that all the resource managers either commit a transaction or abort it. In the first phase, the JTS asks each resource manager if it is prepared to commit. If all the participants affirm, then in the second phase the JTS(Java Transaction Service) broadcasts a commit message to all of them. If any part of the transaction fails - for instance, if a resource manager fails to respond to the prepare request, or if a resource manager responds negatively, then the JTS notifies all of the resource managers that the transaction is aborted. This is the essence of the two-phase commit protocol.

          Tuesday, August 9, 2005


          Originally uploaded by rgarg.
          This is Aryan, my son. He is 2 1/2 yrs old now, and have just started attending a playschool.

          No Need to Click Here - I'm just claiming my feed at Feedster

          [JSE 5.0] Performance Testing Example

          Bruce Eckel had an interesting post on performance testing the collection classes. Basically, he is comparing the different classes, running a myriad of insertion and delete tests and then timing the operation. He uses System.nanoTime() and to quote him, “typically nanoTime() produces values with a granularity that is greater than one (and this granularity will vary with machines and operating systems)”.

          A List of JDBC Drivers

          Continuing from What are the different type of JDBC drivers?, here is a listing of some of the popular JDBC Drivers available.
          I have so far used Oracle Thin driver, IDS Server, Hypersonic SQL, Sprinta Driver (for MS-SQL Server) and MM.MySQL Drivers beside JDBC ODBC Bridge, and I think your own list would also be somewhat similar. Or is it different?

          Yawn of theTiger

          A white tiger yawns as he lays in a pond at the New Delhi Zoological Park in New Delhi.

          I just adore the pic...

          Saturday, July 30, 2005

          What is a Transaction?

          To illustrate the concept, let us assume that you want to transfer money from a savings account into a current account. In this scenario, it is critical that both the accounts are changed from a successful transaction and neither is affected from an unsuccessful one. You just cannot afford to have your money vaporize if crediting your current account fails for any reason after the debit on your savings account! Therefore, the most important concept that one has to be aware of when dealing with enterprise applications is the concept of a transaction. To a user, a transaction is a single change event that either happens or doesn't happen. Although this may sound like a fairly straightforward and simple requirement, it is hard to make this work in a distributed system without deploying some form of transaction control - computers can fail and messages can be easily lost.
          Transactions provide a way to bundle a set of operations into an atomic execution unit. This atomic "all-or-nothing" property is not new; in short, within any transaction, several independent entities must agree before the deal is done. If any party disagrees, the deal is off and the independent entities are reverted back to their original state by invoking a rollover operation.Transactions are essential for distributed applications. Further, transactions provide modular execution, which complements a component technology’s modular programming.

          The ACID properties

          All transactions subscribe to the following "ACID" properties:
          Atomicity - A transaction either commits or rollbacks. If a transaction commits, all of its effects remain. If it rollbacks, then all of its effects are undone. For example, in money transfer example above, the money is deducted from Saving account, and the same amount is added to current account (commit) or nothing changes (rollback).
          Consistency - A transaction always leads to a correct transformation of the system state by preserving the state invariance. For example, a transaction adding an element to a doubly linked list, all forward and backward pointers are updated.
          Isolation - Concurrent transactions are isolated from the updates of other incomplete transactions. This property is also often called serializability. For example, a second transaction traversing a doubly linked list already undergoing modification by a first transaction will see only completed changes, and be isolated from any non-committed changes of the first transaction.
          Durability - If a transaction commits, its effects will be permanent after the transaction commits. In fact, the effects remain even in the face of system failures. It is up to the application to decide what consistency is and to bracket its computation to delimit these consistent transformations. It is the job of the transactional resource managers to provide consistent, isolated and durable transformations of the objects they manage. If the transactions are distributed among multiple computers, the two-phase commit protocol is used to make these transactions atomic and durable.

          Friday, July 29, 2005

          Do you have BRAIN?

          Who Said English is easy?

          Fill in the following blank with Yes or No -

          ______ I don't have a BRAIN.


          GNU utilities for Win32

          I have been using a W2K machine for the devlopment activities. However, sometime back I came acroos this set of tools that port some of the GNU Utilities to Win32 platform. Since then, I have been using them for various activities. Just check it out at

          Wednesday, July 27, 2005

          What is P3P?

          P3P is the Platform for Privacy Preferences Project. It was developed by the W3C, (World Wide Web Consortium) as a protocol for providing automated privacy information to the end user, giving them more control over their own personal information at the web sites they visit.

          P3P websites offer privacy information in a machine-readable format and P3P enabled browsers can read this and compare it to their own privacy standards. This protocol provides a standardization of privacy statements and presents it in a format that allows surfers to act on the information they are provided with.

          The two main goals of implemented P3P policies are:

          * To enable Web sites to present their data-collection practices in a standardized, computer-readable, easy-to-locate manner
          * To enable Web users to understand what data will be collected by sites, how that data will be used, and what data and uses they may "opt-out" of or "opt-in" to.

          How is it useful?

          Web Applications usually uses cookies to track any kind of user information. Internet Explorer (IE) 6.0's default privacy setting "interprets" framed sites as third party cookies. IE 6.0 does not accept third party cookies. Users setting their privacy settings on high on IE 6.0 disable access to such sites. Users have to customize the privacy setting to gain access to these sites. This really can annoy the users to change their privacy settings.

          To avoid such kind of issues sites having cookies can implement P3P Policies and publish them on site. The policy will provide information of the site accepting the kind of cookies and the data collected by the user. After the implementation when user access the site user's privacy is matched with the policy deployed on the site. A handshake is done and if the users privacy settings matches the policy hosted on the site user is allowed to login to the site. Else the site is shown as blocked. P3P is being usually employed by Ad Servers to serve Ads.

          How do I implement P3P on my site?

          First, you need a privacy statement for your site that surfers can read, or you can use the HTML privacy statement that is generated with the IBM P3P editor. Policies can also be created from P3PDeveloper

          The P3P Editor will create four files, a policy file, written in XML, a reference file, written in XML, a compact policy and an HTML version of the privacy statement that you can use on your site as your privacy statement if you don't wish to reference your site's current privacy statement, or if your site doesn't have one. Further compact policies setting can be set on IIS on custom header tab.

          Along with the policy file a legal document page will also be created with the information about the legal implications of a site. The generated policy file can then be deployed along with the legal document on the web site. User can view the policy by viewing the privacy report on IE for the page with the posted policy information.

          I, myself, have used P3P in one of my recent Projects where we built a 3rd Party Ad Server (I would be willing to discuss 3rd party AdServer in one of my later posts). Have you used P3P in your web applications? Your comments are welcome.

          Tuesday, July 26, 2005

          Common UNIX Commands

          I just decied to look for a few commonly used UNIX command. A quick Google produces a lot more, but here are a list of more useful commands.

          1. cd - Change Directory. (Just like in dos)
          2. mkdir - Make Directory.
          3. rmdir - Removes a Directory that is empty!
          4. ls - List directory. (Like dir in Windows)
          5. cat – Short for concatenate. It was used to concatenate two filestogether via cat file1 file2 >file3 Didn‘t know that did you. Theechoing out to standard out gave cat a whole new meaning to the users.
          6. more - Just like less. It pages output to the screen.
          7. mv - Move. For moving files and directories around
          8. rm Remove a file. Also rm rf for removing a folder and it‘scontent.
          9. grep - Used to search for text within a stream or files. (man regex)
          10. vi – A text based editor. You‘ll find that it‘s really a symboliclink to vim now a days.
          11. rlogin - Remote login. I hope your admins disabled this!
          12. passwd - Used to change your password.
          13. ps - Used to processes.
          14. nice - Run a program with lower priority so you don't hog CPU.
          15. kill – Terminates a program. You can select what signal you want tokill a program with also. -9
          16. gzip - Compresses files.
          17. gunzip - Uncompresses files.
          18. tee – Pipe your output to standard out and to a file. Nice forwatching a process and logging.
          19. sort - A sort program
          20. sed – Stream Editor. Excellent program to modify files or streams!(man regex)
          21. uniq - Unique program.
          22. awk – An excellent program to parse up streams or files into tokens.It supports a hellva lot of cool things and you can complete writeprograms with it. (man nawk also)
          23. chgrp - Change Group
          24. chown - Change owner
          25. pwd - Current working directory.
          26. find – Used to find programs and you can also execute commands oneach match found.
          27. wc - Word, line, letter count program. For you line counting whores.
          28. which - Finds a location of a program that's in your path.
          29. last - See who last logged in.
          30. du - Disk usage.
          31. df - Disk Free
          32. top – Running processes with CPU and other information thatrefreshes.
          33. watch – Repeats a command and updates the screen with only thechanges
          34. login - Logging in
          35. telnet - Connect to another machine
          36. logout - Logging out
          37. emacs - Using the emacs text editor
          38. cp - Making a copy of a file
          39. chmod - Controlling access to your files
          40. cmp - Comparing two files
          41. compress - Compress a file
          42. pine Using Pine to send and receive email
          43. mush - The mush electronic mail system
          44. talk - Talk to another user
          45. write - Write messages to another user
          46. ftp - Transferring files with ftp
          47. man - Manual pages
          48. quota v Finding out your available disk space quota
          49. ical - Using the Ical personal organizer
          50. finger - Getting information about a user
          51. who - Finding out who's logged on
          52. lpr - Printing
          53. lprm - Removing a print job
          54. lpq - Checking the print queues
          55. ps - Finding your processes
          56. kill - Killing a process
          57. nohup - Continuing a job after logout
          58. nice - Changing the priority of a job
          59. & - What is a background process?
          60. Cntrl-z - Suspending a process
          61. fg - Resuming a suspended process

          Monday, July 25, 2005

          What are the different type of JDBC drivers?

          There are four types of JDBC database driver:

          The JDBC/ODBC bridge driver (Type 1) A piece of native C-code that translates a JDBC call to an ODBC call. Use this driver for development, not for industrial-strength application environments. Note that you have to have an ODBC database driver manager + an ODBC database driver installed on the server in addition to the JDBC/ODBC bridge. Though useful for learning JDBC and quick testing, bridging solutions are rarely appropriate for production environments.

          Native API partly java driver (Type 2) A piece of native C-code that translates a java JDBC call to a native database call level API. Use this driver for development and deployment. Due to its native code, this driver can only be used by Java Applications with full computer access (i.e. not Applets). Type 2 drivers generally provide the best performance, but they require the installation of native libraries on clients that need to access the database. Applications using Type 2 drivers have a limited degree of portability.

          JDBC-Net pure Java driver (Type 3) A piece of pure java code that translates an incoming JDBC call to an outgoing database Net protocol call (such as SQL*Net). Use this driverfor development and deployment. Flexible and powerful, this driver can be used by any Java component and requires only connect access to work. The Type 3 architecture is actually more of a benefit to driver vendors than application architects since it enables the vendor to write a single implementation and claim support for any database that has a JDBC driver. Though this driver type is quite powerful but, unfortunately, it has weak performance and unpredictable stability.

          Native protocol pure Java driver (Type 4) A piece of pure java code that translates an incoming JDBC call to an outgoing database native protocol call (such as Oracle CLI). Use this driver for development and deployment. This driver type is the recommended one for server-side java development unless a type 2 driver has considerable performance advantages.

          Practically speaking, Type 2 and Type 4 drivers are the only viable choices for a production application. At an abstract level, the choice between Type 2 and Type 4 comes down to a single issue: is platform independence critical? By platform independence, I mean that the application can be bundled up into a single jar and run on any platform. Type 2 drivers have a hard time with platform independence since you need to package platform-specific libraries with the application. If the database access API has not been ported to a client platform, your application will not run on the platform. On the other hand, Type 2 drivers tend to perform better than Type 4 drivers.

          Always remember, knowing the driver type provides only a starting point for making a decision about which JDBC driver to use in your application. The decision really comes down to knowing the drivers that exist for your database of choice and how they compare to each other.

          Useful Links : List of JDBC Drivers

          Saturday, July 23, 2005

          What’s the difference between Primary Key and Unique Key?

          Both Primary & Unique keys are Indexes.

          Index - An index is a structure in a table that orders the data. It allows the database to access data quickly (In MySQL its implemented using B-tree algorithms).

          Primary Key - This is an index that cannot be NULL, Primary Keys are used in building relationships between tables in a database. (an index is automatically created on the primary key). The difference between primary and ordinary keys is that there can be multiple keys, but only one primary key.

          Unique Key - Unique and Index are same, the difference is, in Unique, duplicate are not allowed in any circumstances and that is enforced by database server. Primary key(s) qualify to be Unique on basis of their uniqueness.
          In case, your table has 2 primary keys means that the 2 fields together form one unique key. Each field by itself may have repeating values, but both primary keys combined together must be unique.

          Wednesday, July 20, 2005

          EMail Validation using Regular Expressions

          Using Regular Expressions in Java, we can validate where the given email-id string is of the valid format. Here is a sample.

          import java.util.regex.Matcher;
          import java.util.regex.Pattern;

          public static boolean validateEmailId(String astrEmailId) {
          //Set the email pattern string
          Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
          //Match the given string with the pattern
          Matcher m = p.matcher(astrEmailId);
          //check whether match is found
          return m.matches();

          RegExp can also be used in JavaScriptto validate EMail ID

          function isEmail(str) {
          // are regular expressions supported?
          var supported = 0;
          if (window.RegExp) {
          var tempStr = "a";
          var tempReg = new RegExp(tempStr);
          if (tempReg.test(tempStr)) {
          supported = 1;
          if (!supported) {
          return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
          var r1 = new RegExp("(@.*@)(\\.\\.)(@\\.)(^\\.)");
          var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.
          return (!r1.test(str) && r2.test(str));

          Monday, July 18, 2005

          Sunday, July 17, 2005

          How old are the daughters?

          Two MIT math graduates bump into each other at Fairway on the upper west side. They hadn't seen each other in over 20 years.
          The first grad says to the second: "how have you been?"
          Second: "Great! I got married and I have three daughters now"
          First: "Really? how old are they?"
          Second: "Well, the product of their ages is 72, and the sum of their ages is the same as the number on that building over there.."
          First: "Right, ok.. oh wait.. hmmmm.., I still don't know"
          second: "Oh sorry, the oldest one just started to play the piano"
          First: "Wonderful! my oldest is the same age!"

          Problem: How old are the daughters?

          Monday, July 11, 2005

          Improve the quality of your JMeter scripts

 has published an article on improving the quality of a JMeter Test Script.
          Just in case you are unaware, JMeter is an Open Source Load-Testing Tool from Apache. It has an excellent UI and various parameters and elements can be drag-and-dropped. []

          Wednesday, July 6, 2005

          Patterns: Inversion of Control

          I consider the following links to be a good introduction into IoC (Inversion of Control) pattern and would like to share them:

          How do I make Tomcat startup faster?

          These are a few of the options u can try to make your Tomcat Server startup faster:
          • Get a faster computer (:D)
          • Make sure your code is not doing slow things. (Use a profiler like JProbe)
          • Remove any jar files you don't need. When searching for classes every JAR file needs to be examined to find the needed class. Also during webapp startup, jar files are searched for TLD files. If the jar file is not there - there is nothing to search.
          • Remove any webapps you don't need. (So remove the all the webapps installed with tomcat)
          • Tweak memory parameters - Google is your friend.
          • Trim the config files as much as possible. XML parsing is not cheap. The less there is to parse - the faster things will go.

          Monday, July 4, 2005

          How can I prevent my public JSP page from appearing within the search engine

          There are two ways of achieving it:
          • You can add a meta tag to the generated HTML content indicating that the page must not be indexed by the search engine's spider.
          <meta name="robots" content="noindex">
          • put a file robots.txt at the root of your site, that is /robots.txt. In that file you can configure certain sections of your site to be skipped by crawling bots:
          # All robots will spider the domain
          User-agent: *
          Disallow: /path/of/files/or/documents/to/deny


          Popular Posts (Last 30 days)

          This is a personal blog and I do not speak for my employer.