SAX vs DOM Parser – Concept Revisited



Both SAX and DOM Parser’s are used to parse the XML document. Both has advantages and disadvantages and can be used in our programming depending on the situation.

SAX: Is a stream-based processor. You only have a tiny part in memory at any time and you “sniff” the XML stream as it passes. It uses almost no memory, but you can’t do “DOM” stuff, like use xpath or traverse trees.

DOM: You load the whole thing into memory – it’s a massive memory hog. You can blow memory with even medium sized documents. But you can use xpath and traverse the tree etc.



  • Parses node by node
  • Doesn’t store the XML in memory
  • We cant insert or delete a node
  • SAX is an event based parser
  • SAX is a Simple API for XML
  • doesn’t preserve comments
  • SAX generally runs a little faster than DOM


  • Stores the entire XML document into memory before processing
  • Occupies more memory
  • We can insert or delete nodes
  • Traverse in any direction.
  • DOM is a tree model parser
  • Document Object Model (DOM) API
  • Preserves comments
  • SAX generally runs a little faster than DOM

If we need to find a node and doesn’t need to insert or delete we can go with SAX itself otherwise DOM provided we have more memory.

Read More on SAX:

Categories: Uncategorized Tags: , , ,

Solutions Architect ~ An Overview

solution-architecting-expectationsThe Solutions Architect is a very experienced architect with cross-domain, cross-functional and cross-industry expertise. He/she outlines solution architecture descriptions, then monitors and governs their implementation.

The Solutions Architect is responsible for the development of the overall vision that underlies the projected solution and transforms that vision through execution into the solution.

To be effective the Solutions Architect must have experience on multiple Hardware and Software Environments and be comfortable with complex heterogeneous systems environments.




Involvement and Responsibility:

  1. Involved with a project at the time of inception.
  2. Involved in the Functional analysis (FA) of developing the initial requirements.
  3. Remain involved throughout the balance of the project.
  4. Should have hands-on experience in multiple industries and across several disciplines
  5. They can master a variety of hardware platforms including distributed platforms, desktops, and mobile devices.
  6. A broad and deep understanding of Databases is also required.
  7. Akin to that they should also possess skill and understanding of a variety of Operating Systems
  8. Solutions Architects decide which technologies to use.
  9. They work very closely with developers to ensure proper implementation.
  10. They are the link between the needs of the organization and the developers.
  11. A solutions architect must have a balanced mix of technical and business skills.

Solution Architecture in larger organization:

Solution Architects in large organizations often act as the bridge between Enterprise Architects and Application Architects.

  • An enterprise architect’s deliverable s are usually more abstract than a solution architect’s deliverable s. But that is not always the case, and the main distinction between enterprise architect and solution architect lies in their different motivations.
  • The enterprise architect is primarily employed in the design, planning and governance of strategic and cross-organizational rationalization or optimization of an enterprise’s services, processes or components.
  • The solution architect is primarily employed to help programmer and project managers in the design, planning and governance of implementation projects of any kind.

When the solution architect starts and stops depends on the funding model for the process of solution identification and delivery.
E.g. An enterprise may employ a solution architect on a feasibility study, or to prepare a solution vision or solution outline for an Invitation to Tender. A supplier may employ a solution architect at “bid time”, before any implementation project is costed or resourced. Both may employ a solution architect to govern an implementation project, or play a leading role within it.

Next I will be posting what exactly the role and responsibility of a Java Solution Architect and what are the skills he/she should.


Categories: Software Solutions


To install Java in Ubuntu/Linux  open Terminal (Press Ctrl+Alt+T) and copy the following commands in the Terminal:

  • sudo mkdir -p /usr/local/java

For 32-bit users:

  • wget -O jre-32bit.tar.gz
  • wget -O jdk-32bit.tar.gz
  • sudo -s cp -r jre-32bit.tar.gz /usr/local/java
  • sudo -s cp -r jdk-32bit.tar.gz /usr/local/java
  • cd /usr/local/java
  • sudo -s tar xvzf jre-32bit.tar.gz
  • sudo -s tar xvzf jdk-32bit.tar.gz

For 64-bit users:

  • wget -O jdk-64bit.tar.gz
  • wget -O jre-64bit.tar.gz
  • sudo -s cp -r jre-64bit.tar.gz /usr/local/java
  • sudo -s cp -r jdk-64bit.tar.gz /usr/local/java
  • cd /usr/local/java
  • sudo -s chmod a+x jre-64bit.tar.gz
  • sudo -s chmod a+x jdk-64bit.tar.gz
  • sudo -s tar xvzf jre-64bit.tar.gz
  • sudo -s tar xvzf jdk-64bit.tar.gz

Now you need to enter these command (both 32-bit and 64-bit users):

  • sudo nano /etc/profile

Add the following lines at the end of file:

export JAVA_HOME
export JRE_HOME
export PATH

Copy above lines and to paste in terminal (Press Ctrl+Shift+V) and to save file using nano (Press Ctrl+O) then (Press Ctrl+X) to exit from file.

Now enter following commands one by one in terminal:

  • sudo update-alternatives –install “/usr/bin/java” “java” “/usr/local/java/jre1.7.0_12/bin/java” 1
  • sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/local/java/jdk1.7.0_12/bin/javac” 1
  • sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/local/java/jre1.7.0_12/bin/javaws” 1
  • sudo update-alternatives –set java /usr/local/java/jre1.7.0_12/bin/java
  • sudo update-alternatives –set javac /usr/local/java/jdk1.7.0_12/bin/javac
  • sudo update-alternatives –set javaws /usr/local/java/jre1.7.0_12/bin/javaws
  • . /etc/profile

Check installed java version:

  • java -version


That’s it, Enjoy!!!



Categories: Java, JDK7, LINUX, UBUNTU

30 SQL PL/SQL Questions for Java/J2EE Professionals

Here are a mix of SQL and PL/SQL questions. You can treat these be as SQL and PL/SQL interview questions or a Database FAQ.
Many of them may be specific to Oracle database. Please  drop comment if you are unable to get an answer to any of them.Also please note that it is better to know the answers to them even if you are a Java developer as database interaction is very much required in most of the applications.

  1. What are the various types of indexes?Is there any advantage of using views?
  2. On what kind of tables and columns, a view be created?
  3. What are the various kinds of constraints which can be applied on a column?
  4. What is the disadvantage of using indexes?
  5. What are the various techniques you have used for optimizing your tables? What about De-normalization?
  6. What is the purpose of DUAL table?
  7. How will you convert a date to String in SQL?
  8. How will you copy only the table structure from one table to another compatible table?
  9. How will you copy the table structure and data from one table to another compatible table?
  10. Which is the faster method of retrieving data using a SQL query? WHERE, ROWID, CURSOR
  11. What is better to use? A subquery or a Join?
  12. What is the purpose of NOCACHE and NOLOGGING keywords?
  13. What does DELETE CASCADE do in a constraint?
  14. When should one use Auto Increment of a column than using a sequence?
  15. How will you take the backup of the data present in your tables?
  16. What is the difference between a Data Warehouse and Data Mining?
  17. What is the disadvantage of having constraints and integrity checks in triggers or procedures than to have them in the application using the database?
  18. How will you delete duplicate rows from a table based on a particular column?
  19. Can a view be created on another view?
  20. Can a SQL query have an alias and be used as a column name for the enclosing parent SQL query? Give example?
  1. Is AVG a function or procedure?
  2. What is the advantage of using packages for storing PL/SQL objects?
  3. How will you raise an exception and an error in PL/SQL procedure?
  4. How will you call a PL/SQL procedure from a SQL statement?
  5. What is the default value being assigned to variables in a PL/SQL variables?
  6. What is the difference between NVL and NVL2 functions?
  7. What is the difference between Count and Count(*)?
  8. What is the difference between Procedure and Function?
  9. What is overloading of procedures?
  10. What is a ROW and STATEMENT triggers?
Most of the above questions are 100% applicable for DBA professionals but same time I would like to suggest as java professional we have have know all the above concept….  Java interviewer are expecting many things from java developers/professionals now a day.
Categories: DBA, PL/SQL, SQL

Clustering vs. Load Balancing – What is the difference?

These 2 terms – clustering and load balancing – are used in the same sense by a majority of IT people with relative impunity.

Clustering has a formal meaning. A cluster is a group of resources that are trying to achieve a common objective, and are aware of one another. Clustering usually involves setting up the resources (servers usually) to exchange details on a particular channel (port) and keep exchanging their states, so a resource’s state is replicated at other places as well. It usually also includes load balancing, wherein, the request is routed to one of the resources in the cluster as per the load balancing policy.

Load balancing can also happen without clustering when we have multiple independent servers that have same setup, but other than that, are unaware of each other. Then, we can use a load balancer to forward requests to either one server or other, but one server does not use the other server’s resources. Also, one resource does not share its state with other resources.

Each load balancer basically does following tasks:

  1. Continuously check which servers are up.
  2. When a new request is received, send it to one of the servers as per the load balancing policy.
  3. When a request is received for a user who already has a session, send the user to the *same* server (This part is important, as otherwise user would keep going between different servers, but not able to really do any work). This part is not required for serving static pages, in that case, there are no user sessions.

What does it mean from a user’s perspective? Which one is better?
Every time some one asks a generic question – which one is better, the answer is invariably “It depends”. This isn’t political equivocation, but simply restating the fact that if one was better than the other in all circumstances, then the other wouldn’t exist.

Clustering saves the user’s state, and is more transparent to the user, but is harder to setup, and is very resource specific. Different application servers have different clustering protocols, and don’t necessarily work out of the box (don’t you believe any of that marketing fluff). Load balancing is comparatively more painless, and relatively more independent of application servers.

From a user’s perspective, it means that if the user is doing something on the application, and that server goes down, then depending upon whether the system is doing clustering or load balancing, the user observes different behavior. If the system is clustered, the user may be able to continue doing the transaction, and may not even realize that the server has gone down. If the system is load balanced without clustering, that means that the user’s state will likely be lost, and the user will be simply sent to the other server(s) to restart transaction. The user has lost some work.

Categories: Cluster, Load Balancing

Character array is better than String for Storing password in Java!

Why character array is better than String for storing password in Java?

You might be knowing String is immutable and how Substring can cause memory leak in Java.

1) Since Strings are immutable in Java if you store password as plain text it will be available in memory until Garbage collector clears it and since String are used in String pool for reusability there is pretty high chance that it will be remain in memory for long duration, which pose a security threat. Since any one who has access to memory dump can find the password in clear text and that’s another reason you should always used an encrypted password than plain text. Since Strings are immutable there is no way contents of Strings can be changed because any change will produce new String, while if you char[] you can still set all his element as blank or zero. So Storing password in character array clearly mitigates security risk of stealing password.

2) Java itself recommends using getPassword() method of JPasswordField which returns a char[] and deprecated getText() method which returns password in clear text stating security reason. Its good to follow advice from Java team and adhering to standard rather than going against it.

3) With String there is always a risk of printing plain text in log file or console but if use Array you won’t print contents of array instead its memory location get printed. though not a real reason but still make sense.


String strPassword=”Unknown”;
char[] charPassword= new char[]{‘U’,’n’,’k’,’w’,’o’,’n’};
System.out.println(“String password: ” + strPassword);
System.out.println(“Character password: ” + charPassword);


String password: Unknown
Character password: [C@110b053

That’s all on why character array is better choice than String for storing passwords in Java.  Though using char[] is not just enough you need to erase content to be more secure. I also suggest working with hash’d or encrypted password instead of plaintext and clearing it from memory as soon as authentication is completed.

Categories: Java, Java Profiling

JConsole, My first step towards Java profiler

November 12, 2012 1 comment

JConsole is very simple, yet powerful Java performance monitor tool and one of the major upgrades to Java 5 is its comprehensive monitoring and management support, which is very much needed in any Java based enterprise application.

There are various profiling tools available for Java in the market and every one of them has its significance & different from the other. JConsole is very useful for basic profiling needs. t’s not very elaborate like other profilers, so, you don’t loose focus from the problem you are chasing. Since, it is part of JDK, you can always trust this more than any other third party profiling tools.

In a nutshell, JConsole is used for monitoring the vital JVM statuses like memory pools (heap & permGen space), threads and classes getting loaded. It is also used for managing MBeans which are part of JDK or the one’s provided by the application that JVM is running. Servers like JBoss and Tomcat ship their own set of MBeans along with their products, using which you can manage their application containers. You can also write your own application specific management tasks like “OutOfMemory” warning system, cache management or any back door administrative tasks as management beans.

For more details please read out here:


you can also get plenty other free Java profiling Tools from the below link as follows:


Happy Java Profiling 🙂


%d bloggers like this: