<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5334619773603269475</id><updated>2011-11-27T16:18:55.499-08:00</updated><category term='linux'/><category term='coding problem resources java'/><category term='create user'/><category term='tools'/><category term='format date java'/><category term='learn java online'/><category term='mysql'/><category term='java'/><category term='rm'/><category term='create table'/><category term='hibernate tutorial examples'/><category term='java j2ee struts hibernate spring examples'/><category term='jsp'/><category term='cd'/><category term='privileges'/><category term='create database'/><category term='java introduction. web server'/><category term='compile'/><category term='la'/><category term='mkdir'/><category term='pwd'/><category term='application server'/><category term='permissions'/><category term='rmdir'/><category term='commands'/><category term='cp'/><category term='show usrers'/><category term='editplus'/><category term='wc'/><category term='SCJP 1.5 Mocks'/><category term='servlet'/><category term='hit counter'/><category term='cat'/><category term='j2ee'/><category term='run'/><category term='best java sites websites learn java'/><category term='ls'/><title type='text'>Learn Java</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-1846149764134207676</id><published>2009-08-11T05:09:00.000-07:00</published><updated>2009-08-11T05:18:31.691-07:00</updated><title type='text'>Useful and interesting links for new Java programmers</title><content type='html'>http://www.refactoring.com/catalog/index.html&lt;br /&gt;http://www.dcs.qmul.ac.uk/~mmh/jlinks.html&lt;br /&gt;http://www.xtremevbtalk.com/showthread.php?t=122263&lt;br /&gt;http://javaquestion.tripod.com/javalinks.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-1846149764134207676?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/1846149764134207676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=1846149764134207676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/1846149764134207676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/1846149764134207676'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/08/useful-and-interesting-links-for-new.html' title='Useful and interesting links for new Java programmers'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-3062543141679066108</id><published>2009-07-29T01:54:00.000-07:00</published><updated>2009-07-29T01:55:01.812-07:00</updated><title type='text'>String Util</title><content type='html'>Utilities for reading and writing CSV (comma separated value) text files.&lt;br /&gt;http://ostermiller.org/utils/CSV.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-3062543141679066108?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/3062543141679066108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=3062543141679066108' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3062543141679066108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3062543141679066108'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/07/string-util_29.html' title='String Util'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-4721446863252018539</id><published>2009-07-27T22:38:00.000-07:00</published><updated>2009-07-27T22:42:02.142-07:00</updated><title type='text'>How To Ask Questions The Smart Way</title><content type='html'>How to get help from people who actually know about the software or hardware you're dealing with.&lt;br /&gt;This guide will teach you how to ask questions in a way more likely to get you a satisfactory answer.&lt;br /&gt;http://www.catb.org/~esr/faqs/smart-questions.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-4721446863252018539?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/4721446863252018539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=4721446863252018539' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4721446863252018539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4721446863252018539'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/07/how-to-ask-questions-smart-way.html' title='How To Ask Questions The Smart Way'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-1889083855144517262</id><published>2009-07-26T22:37:00.000-07:00</published><updated>2009-07-26T22:39:57.303-07:00</updated><title type='text'>String Util</title><content type='html'>package com.ananth.util;&lt;br /&gt;&lt;br /&gt;import java.text.CharacterIterator;&lt;br /&gt;import java.text.StringCharacterIterator;&lt;br /&gt;import java.util.regex.Matcher;&lt;br /&gt;import java.util.regex.Pattern;&lt;br /&gt;&lt;br /&gt;public final class StringUtil {&lt;br /&gt;&lt;br /&gt;   private StringUtil() {&lt;br /&gt;        // Utility class, hide the constructor.&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Validators ---------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Check if given string is a number. It should contain digits only.&lt;br /&gt;     * @param string The string to check on.&lt;br /&gt;     * @return True if string is a number.&lt;br /&gt;     */&lt;br /&gt;    public static boolean isNumber(String string) {&lt;br /&gt;        return string.matches("^\\d+$");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Check if given string is numeric. Positive and negative prefix and dot separators are&lt;br /&gt;     * allowed.&lt;br /&gt;     * @param string The string to check on.&lt;br /&gt;     * @return True if string is numeric.&lt;br /&gt;     */&lt;br /&gt;    public static boolean isNumeric(String string) {&lt;br /&gt;        return string.matches("^[-+]?\\d+(\\.\\d+)?$");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Check if given string is a value. The dot separator and two decimals are required.&lt;br /&gt;     * @param string The string to check on.&lt;br /&gt;     * @return True if string is value.&lt;br /&gt;     */&lt;br /&gt;    public static boolean isValue(String string) {&lt;br /&gt;        return string.matches("^\\d+\\.\\d{2}$");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Check if given string contains numbers.&lt;br /&gt;     * @param string The string to check on.&lt;br /&gt;     * @return True if string contains numbers.&lt;br /&gt;     */&lt;br /&gt;    public static boolean hasNumbers(String string) {&lt;br /&gt;        return string.matches("^.*\\d.*$");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Check if given string is a valid email address.&lt;br /&gt;     * @param string The string to check on.&lt;br /&gt;     * @return True if string is an valid email address.&lt;br /&gt;     */&lt;br /&gt;    public static boolean isEmailAddress(String string) {&lt;br /&gt;        return string.matches("^[\\w-~#&amp;]+(\\.[\\w-~#&amp;]+)*@([\\w-]+\\.)+[a-z]{2,5}$");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Converters ---------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Convert the given string to a string with unicode escape sequence for every character.&lt;br /&gt;     * @param string The string to be converted.&lt;br /&gt;     * @return The string with unicode escape sequence for every character.&lt;br /&gt;     */&lt;br /&gt;    public static String toUnicode(String string) {&lt;br /&gt;        StringBuilder builder = new StringBuilder();&lt;br /&gt;        for (char c : string.toCharArray()) {&lt;br /&gt;            builder.append(String.format("\\u%04x", (int) c));&lt;br /&gt;        }&lt;br /&gt;        return builder.toString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Unescape any unicode escape sequence in the given string.&lt;br /&gt;     * @param string The string to be unescaped.&lt;br /&gt;     * @return The string with unescaped unicode escape sequences.&lt;br /&gt;     */&lt;br /&gt;    public static String unescapeUnicode(String string) {&lt;br /&gt;        Matcher matcher = Pattern.compile("\\\\u((?i)[0-9a-f]{4})").matcher(string);&lt;br /&gt;        while (matcher.find()) {&lt;br /&gt;            int codepoint = Integer.valueOf(matcher.group(1), 16);&lt;br /&gt;            string = string.replaceAll("\\" + matcher.group(0), String.valueOf((char) codepoint));&lt;br /&gt;        }&lt;br /&gt;        return string;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Escape characters for text appearing as XML data, between tags.     &lt;br /&gt;     */&lt;br /&gt;     public static String forXML(String aText){&lt;br /&gt;       final StringBuilder result = new StringBuilder();&lt;br /&gt;       final StringCharacterIterator iterator = new StringCharacterIterator(aText);&lt;br /&gt;       char character =  iterator.current();&lt;br /&gt;       while (character != CharacterIterator.DONE ){&lt;br /&gt;         if (character == '&lt;') {&lt;br /&gt;           result.append("&amp;lt;");&lt;br /&gt;         }&lt;br /&gt;         else if (character == '&gt;') {&lt;br /&gt;           result.append("&amp;gt;");&lt;br /&gt;         }&lt;br /&gt;         else if (character == '\"') {&lt;br /&gt;           result.append("&amp;quot;");&lt;br /&gt;         }&lt;br /&gt;         else if (character == '\'') {&lt;br /&gt;           result.append("&amp;#039;");&lt;br /&gt;         }&lt;br /&gt;         else if (character == '&amp;') {&lt;br /&gt;            result.append("&amp;amp;");&lt;br /&gt;         }&lt;br /&gt;         else {&lt;br /&gt;           //the char is not a special one&lt;br /&gt;           //add it to the result as is&lt;br /&gt;           result.append(character);&lt;br /&gt;         }&lt;br /&gt;         character = iterator.next();&lt;br /&gt;       }&lt;br /&gt;       return result.toString();&lt;br /&gt;     }&lt;br /&gt;    /**&lt;br /&gt;     * Remove any XSS (Cross Site Scripting) vulnerabilities from the given string.&lt;br /&gt;     * @param string The string to remove XSS from.&lt;br /&gt;     * @return The string with removed XSS, if any.&lt;br /&gt;     */&lt;br /&gt;    public static String removeXss(String string) {&lt;br /&gt;        return string&lt;br /&gt;            .replaceAll("(?i)&lt;script.*?&gt;.*?&lt;/script.*?&gt;", "") // Remove all &lt;script&gt; tags.&lt;br /&gt;            .replaceAll("(?i)&lt;.*?javascript:.*?&gt;.*?&lt;/.*?&gt;", "") // Remove tags with javascript: call.&lt;br /&gt;            .replaceAll("(?i)&lt;.*?\\s+on.*?&gt;.*?&lt;/.*?&gt;", ""); // Remove tags with on* attributes.&lt;br /&gt;    }    &lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-1889083855144517262?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/1889083855144517262/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=1889083855144517262' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/1889083855144517262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/1889083855144517262'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/07/string-util.html' title='String Util'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-4947986318895136840</id><published>2009-06-24T18:38:00.000-07:00</published><updated>2009-06-24T18:48:01.446-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coding problem resources java'/><title type='text'>Resources to use when presented with a coding problem?</title><content type='html'>1. I usually just google my question and usually get a hit on my question.&lt;br /&gt;3. Hit some forums - &lt;span style="font-weight:bold;"&gt;tek-tips.com&lt;/span&gt;, &lt;span style="font-weight:bold;"&gt;codeguru.com&lt;/span&gt;, &lt;span style="font-weight:bold;"&gt;codeproject.com&lt;/span&gt; &lt;br /&gt;4. Browse code sharing sites - &lt;span style="font-weight:bold;"&gt;planet-source-code.com&lt;/span&gt;, &lt;span style="font-weight:bold;"&gt;codeproject.com&lt;/span&gt; &lt;br /&gt;5.I try to search for it in Books 24X7&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-4947986318895136840?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/4947986318895136840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=4947986318895136840' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4947986318895136840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4947986318895136840'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/06/resources-to-use-when-presented-with.html' title='Resources to use when presented with a coding problem?'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-3832613067929669796</id><published>2009-06-14T10:55:00.000-07:00</published><updated>2009-06-14T10:56:03.881-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hit counter'/><title type='text'>Hit counter</title><content type='html'>&lt;table width="133" border="0" cellspacing="0" cellpadding="3"&gt;&lt;tr&gt;&lt;td align="center"&gt;&lt;a href="http://www.elogicwebsolutions.com/stat-counters.html" target="_blank"&gt;&lt;img src="http://www.elogicwebsolutions.com/cgi-bin/cntimg.pl?c=7072-2046" alt="stat counter login" border="0" &gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;&lt;font style="font-family:Geneva,Arial,Helvetica,sans-serif;font-size:9px;color:#000000"&gt;Supported by the &lt;a href="http://www.elogicwebsolutions.com" target="_blank" style="font-family: Geneva,Arial,Helvetica,sans-serif;font-size:9px;color:#000000" title="website optimization"&gt;website optimization&lt;/a&gt; experts.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-3832613067929669796?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/3832613067929669796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=3832613067929669796' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3832613067929669796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3832613067929669796'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/06/hit-counter.html' title='Hit counter'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-6532680394455291645</id><published>2009-06-08T23:04:00.000-07:00</published><updated>2009-06-08T23:11:21.637-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java j2ee struts hibernate spring examples'/><title type='text'>Java Examples</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Java examples organized by topic.&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.java2s.com/" target="_blank"&gt;http://www.java2s.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-6532680394455291645?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/6532680394455291645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=6532680394455291645' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6532680394455291645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6532680394455291645'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/06/java-examples.html' title='Java Examples'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-2862024713113848531</id><published>2009-06-08T19:39:00.000-07:00</published><updated>2009-06-08T19:43:05.750-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jsp'/><category scheme='http://www.blogger.com/atom/ns#' term='j2ee'/><category scheme='http://www.blogger.com/atom/ns#' term='servlet'/><category scheme='http://www.blogger.com/atom/ns#' term='java introduction. web server'/><category scheme='http://www.blogger.com/atom/ns#' term='application server'/><title type='text'>J2EE Introduction</title><content type='html'>Web clients, Application Clients.&lt;br /&gt;&lt;br /&gt;Web clients - browser&lt;br /&gt;&lt;br /&gt;Application Clients&lt;br /&gt;standalone client application for handling tasks such as system or application &lt;br /&gt;administration. &lt;br /&gt;For example, a web-based banking application might use an application client to &lt;br /&gt;manually administer customers and accounts. &lt;br /&gt;This capability is useful in the event the site becomes inaccessible for any &lt;br /&gt;reason or a customer prefers to communicate things like changes to account &lt;br /&gt;information by phone.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Hypertext Transfer Protocol&lt;/span&gt; (HTTP) is an application-level protocol for distributed systems&lt;br /&gt;&lt;br /&gt;HTTP is a request/response standard of a client and a server. A client is the end-user, the server is the web site. The client making a HTTP request—using a web browser, spider, or other end-user tool—is referred to as the user agent. The responding server—which stores or creates resources such as HTML files and images—is called the origin server.&lt;br /&gt;&lt;br /&gt;GET&lt;br /&gt;If a request is made from a html form the GET method can be specified with the method attribute.&lt;br /&gt;POST&lt;br /&gt;If a request is made from a html form the POST method can be specified with the method attribute.&lt;br /&gt;HEAD&lt;br /&gt;HEAD is similar to GET, but returns only the header.&lt;br /&gt;PUT&lt;br /&gt;DELETE&lt;br /&gt;TRACE&lt;br /&gt;OPTIONS&lt;br /&gt;&lt;br /&gt;Web Application:&lt;br /&gt;web application generates interactive web pages containing various types of markup language (HTML, XML, and so on) and dynamic content in response to requests&lt;br /&gt;&lt;br /&gt;programming model&lt;br /&gt;server-side runtime support&lt;br /&gt;deployement support&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;J2EE specification:&lt;/span&gt;&lt;br /&gt;Java Servlets &amp; JSP&lt;br /&gt;Web Container - is essentially a Java runtime&lt;br /&gt;packaging structure&lt;br /&gt;&lt;br /&gt;The Java 2 Platform, Enterprise Edition (J2EE) specification is the standard for developing, deploying, and running enterprise applications. &lt;br /&gt;&lt;br /&gt;(Application clients provide a framework on which application code runs, so that your client applications can access information on the application server.&lt;br /&gt;&lt;br /&gt;For example, an insurance company can use application clients to help offload work on the server and to perform specific tasks. Suppose an insurance agent wants to access and compile daily reports. The reports are based on insurance rates that are located on the server. The agent can use application clients to access the application server where the insurance rates are located.)&lt;br /&gt;&lt;br /&gt;Java Servlet technology was created as a portable way to provide dynamic, user-oriented content.&lt;br /&gt;JavaServer Pages (JSP) technology provides a simplified, fast way to create dynamic web content. JSP technology enables rapid development of web-based applications that are server- and platform-independent. &lt;br /&gt;Deployment descriptor describes how a web application or enterprise application should be deployed. They help to manage web applications once they are deployed.&lt;br /&gt;&lt;br /&gt;J2EE Application server&lt;br /&gt; the term application server sometimes refers to a J2EE or Java EE 5 application server. Among the better known Java Enterprise Edition application servers are WebSphere Application Server and WebSphere Application Server Community Edition (IBM), Sybase Enterprise Application Server (Sybase Inc), WebLogic Server (Oracle), JBoss (Red Hat), JRun (Adobe Systems), Apache Geronimo (Apache Software Foundation), Oracle OC4J (Oracle), Sun Java System Application Server (based on GlassFish Application Server)(Sun Microsystems), SAP Netweaver AS (ABAP/Java) (SAP), and Glassfish Application Server.&lt;br /&gt;&lt;br /&gt; Web container built into web servers&lt;br /&gt;Ex: Jakarta Tomcat - pure web server&lt;br /&gt;- it includes a webserver along with a web container&lt;br /&gt;&lt;br /&gt; [[ The term web server can mean one of two things:&lt;br /&gt;A computer program that is responsible for accepting HTTP requests from clients (user agents such as web browsers), and serving them HTTP responses along with optional data contents, which usually are web pages such as HTML documents and linked objects (images, etc.).&lt;br /&gt;A computer that runs a computer program as described above. ]]&lt;br /&gt;&lt;br /&gt;Web container in a separate runtime&lt;br /&gt; Apache, Microsoft IIS (Internet Information Services)- requires Java runtime to run servlets, and a web server plug-in to integrate the Java runtime with the web server.&lt;br /&gt;&lt;br /&gt; commercially availabe servlet/JPS engine - JRun , ServletExec&lt;br /&gt;&lt;br /&gt;The Structure of Web Application&lt;br /&gt;The contents of the WEB-INF directory are:&lt;br /&gt;&lt;br /&gt;The /WEB-INF/web.xml deployment descriptor.&lt;br /&gt;&lt;br /&gt;The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader.&lt;br /&gt;&lt;br /&gt;The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets, beans, and other utility classes useful to the Web application. The Web application class loader must be able to load classes from any of these archive files.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-2862024713113848531?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/2862024713113848531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=2862024713113848531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2862024713113848531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2862024713113848531'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/06/j2ee-introduction.html' title='J2EE Introduction'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-4865166194498838287</id><published>2009-04-14T23:09:00.000-07:00</published><updated>2009-06-13T05:42:37.475-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hibernate tutorial examples'/><title type='text'>Hibernate Tutorial</title><content type='html'>http://www.hibernate.org/hib_docs/v3/reference/en/html/index.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-4865166194498838287?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/4865166194498838287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=4865166194498838287' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4865166194498838287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4865166194498838287'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/04/hibernate-tutorial.html' title='Hibernate Tutorial'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-336368332785706398</id><published>2009-03-20T00:51:00.001-07:00</published><updated>2009-06-13T05:43:23.291-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='format date java'/><title type='text'>Java Date and Time</title><content type='html'>Get the current Date and Time&lt;br /&gt;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;import java.text.SimpleDateFormat;&lt;br /&gt;&lt;br /&gt;public class DateUtils {&lt;br /&gt;  public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";&lt;br /&gt;&lt;br /&gt;  public static String now() {&lt;br /&gt;    Calendar cal = Calendar.getInstance();&lt;br /&gt;    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);&lt;br /&gt;    return sdf.format(cal.getTime());&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public static void  main(String arg[]) {&lt;br /&gt;    System.out.println("Now : " + DateUtils.now());&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here some formatting possibilities available through the SimpleDateFormat class.&lt;br /&gt;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;import java.text.SimpleDateFormat;&lt;br /&gt;&lt;br /&gt;public class DateUtils {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  public static String now(String dateFormat) {&lt;br /&gt;    Calendar cal = Calendar.getInstance();&lt;br /&gt;    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);&lt;br /&gt;    return sdf.format(cal.getTime());&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public static void  main(String arg[]) {&lt;br /&gt;     System.out.println(DateUtils.now("dd MMMMM yyyy"));&lt;br /&gt;     System.out.println(DateUtils.now("yyyyMMdd"));&lt;br /&gt;     System.out.println(DateUtils.now("dd.MM.yy"));&lt;br /&gt;     System.out.println(DateUtils.now("MM/dd/yy"));&lt;br /&gt;     System.out.println(DateUtils.now("yyyy.MM.dd G 'at' hh:mm:ss z"));&lt;br /&gt;     System.out.println(DateUtils.now("EEE, MMM d, ''yy"));&lt;br /&gt;     System.out.println(DateUtils.now("h:mm a"));&lt;br /&gt;     System.out.println(DateUtils.now("H:mm:ss:SSS"));&lt;br /&gt;     System.out.println(DateUtils.now("K:mm a,z"));&lt;br /&gt;     System.out.println(DateUtils.now("yyyy.MMMMM.dd GGG hh:mm aaa"));&lt;br /&gt;  }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-336368332785706398?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/336368332785706398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=336368332785706398' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/336368332785706398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/336368332785706398'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/03/java-date-and-time.html' title='Java Date and Time'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-342659377265478776</id><published>2009-01-07T01:44:00.000-08:00</published><updated>2009-01-07T01:46:27.509-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='best java sites websites learn java'/><title type='text'>Best Java sites</title><content type='html'>http://www.javaalmanac.com - The online counterpart of the Java Developer's Almanac - highly recommended for quick code snippets, and if you like the site, buy the book. &lt;br /&gt;&lt;br /&gt;http://www.onjava.com - O'Reilly's Java website. New articles weekly. &lt;br /&gt;&lt;br /&gt;http://java.sun.com - The official Java developer website - new articles posted weekly. &lt;br /&gt;&lt;br /&gt;http://www.developer.com/java - Java articles hosted by Gamelan.com &lt;br /&gt;&lt;br /&gt;http://www.java.net - The Java community website hosted by Sun Microsystems. &lt;br /&gt;&lt;br /&gt;http://www.builder.com - Cnet's Builder.com website - All tech articles, some Java-centric. &lt;br /&gt;&lt;br /&gt;http://www.ibm.com/developerworks/java - IBM's Developerworks; the Java section. &lt;br /&gt;&lt;br /&gt;http://www.javaworld.com - One of the originals. Weekly updates of Java articles. &lt;br /&gt;&lt;br /&gt;http://www.devx.com/java - Java articles hosted at DevX. &lt;br /&gt;&lt;br /&gt;http://www.fawcette.com/javapro - The JavaPro online magazine website. &lt;br /&gt;&lt;br /&gt;http://www.sys-con.com/java - The Java Developers Journal online magazine website. &lt;br /&gt;&lt;br /&gt;http://www.javadesktop.org - The desktop Java community hosted at Java.net. &lt;br /&gt;&lt;br /&gt;http://www.theserverside.com - Often considered the resource for all discussion server-side Java specific. &lt;br /&gt;&lt;br /&gt;http://www.jars.com - The Java review service. Covers frameworks and applications. &lt;br /&gt;&lt;br /&gt;http://www.jguru.com - A great source for Q&amp;A style interaction in the community. &lt;br /&gt;&lt;br /&gt;http://www.javaranch.com &lt;br /&gt;&lt;br /&gt;http://www.ibiblio.org/javafaq/javafaq.html - The comp.lang.java FAQ - questions asked, answered, and categorized from the comp.lang.java newsgroup. &lt;br /&gt;&lt;br /&gt;http://java.sun.com/docs/books/tutorial/ - The Official Java tutorial from Sun - very useful for almost any feature set. &lt;br /&gt;&lt;br /&gt;http://www.javablogs.com - Blog aggregator for the most active Java-based blogs throughout the internet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-342659377265478776?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/342659377265478776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=342659377265478776' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/342659377265478776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/342659377265478776'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2009/01/best-java-sites.html' title='Best Java sites'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-5793778775165153287</id><published>2008-11-06T22:00:00.000-08:00</published><updated>2008-11-06T23:03:18.433-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='create user'/><category scheme='http://www.blogger.com/atom/ns#' term='show usrers'/><category scheme='http://www.blogger.com/atom/ns#' term='permissions'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='create table'/><category scheme='http://www.blogger.com/atom/ns#' term='privileges'/><category scheme='http://www.blogger.com/atom/ns#' term='create database'/><title type='text'>Running MySQL in Windows</title><content type='html'>Step 1: Open Command Prompt&lt;br /&gt;        C:\Program Files\MySQL\MySQL Server 5.0\bin&gt;mysql -uroot -p&lt;br /&gt;&lt;br /&gt;Step 2:&lt;br /&gt;mysql&gt; show databases;&lt;br /&gt;+--------------------+&lt;br /&gt;| Database           |&lt;br /&gt;+--------------------+&lt;br /&gt;| information_schema |&lt;br /&gt; | hibernatetutorial  |&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;The above command shows all the existing databases.&lt;br /&gt;&lt;br /&gt;Step 3:&lt;br /&gt;       Create new MySQL user&lt;br /&gt;       CREATE USER 'sark'@'localhost' IDENTIFIED BY 'sark';&lt;br /&gt;&lt;br /&gt;Step 4:&lt;br /&gt;       Grant Permissions.&lt;br /&gt;      GRANT ALL PRIVILEGES ON *.* TO 'sark'@'localhost' IDENTIFIED BY 'sark' WITH GRANT OPTION;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step 5:&lt;br /&gt;      To check the existing users.&lt;br /&gt;      mysql&gt; select User,Host from mysql.user;&lt;br /&gt;+-----------+--------------+&lt;br /&gt;| User      | Host         |&lt;br /&gt;+-----------+--------------+&lt;br /&gt;| root      | %            |&lt;br /&gt;| sark      | localhost    |&lt;br /&gt;+-----------+--------------+&lt;br /&gt;&lt;br /&gt;Step 6: To check the Permissions/privileges.&lt;br /&gt;&lt;br /&gt;mysql&gt; show grants for sark@localhost;&lt;br /&gt;+-------------------------------------------------------------------------------&lt;br /&gt;-------------------------------------------------------+&lt;br /&gt;| Grants for sark@localhost&lt;br /&gt;                                                       |&lt;br /&gt;+-------------------------------------------------------------------------------&lt;br /&gt;-------------------------------------------------------+&lt;br /&gt;| GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'sark'@'localhost' IDENTIFIED B&lt;br /&gt;Y PASSWORD '*A231ED0CF53E6EF33A1A79930EB2A82DB89812F2' |&lt;br /&gt;+-------------------------------------------------------------------------------&lt;br /&gt;-------------------------------------------------------+&lt;br /&gt;&lt;br /&gt;Step 6:&lt;br /&gt;       Exit from root user and login as 'sark' user;&lt;br /&gt;&lt;br /&gt;     mysql&gt; exit;&lt;br /&gt;     Bye&lt;br /&gt;&lt;br /&gt;   C:\Program Files\MySQL\MySQL Server 5.0\bin&gt;mysql -usark -psark&lt;br /&gt;   Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;br /&gt;   Your MySQL connection id is 43 to server version: 5.0.24-community-nt&lt;br /&gt;&lt;br /&gt;   Type 'help;' or '\h' for help. Type '\c' to clear the buffer.&lt;br /&gt;&lt;br /&gt;   mysql&gt;&lt;br /&gt;&lt;br /&gt;Step 7:&lt;br /&gt;     Create database 'sarkDB'&lt;br /&gt;     mysql&gt; CREATE DATABASE sarkDB;&lt;br /&gt;&lt;br /&gt;Step 8:&lt;br /&gt;      Use Database&lt;br /&gt;     mysql&gt; use sarkDB;&lt;br /&gt;     Database changed&lt;br /&gt;&lt;br /&gt;Step 9:&lt;br /&gt;      Create table demo_people.&lt;br /&gt;     mysql&gt;  CREATE TABLE `demo_people` (&lt;br /&gt;       `pid` int(11) NOT NULL,&lt;br /&gt;      `name` varchar(20) default NULL,&lt;br /&gt;       `phone` int(11) default NULL,&lt;br /&gt;      PRIMARY KEY  (`pid`)&lt;br /&gt;     );&lt;br /&gt;Query OK, 0 rows affected (0.23 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-5793778775165153287?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/5793778775165153287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=5793778775165153287' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/5793778775165153287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/5793778775165153287'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/11/running-mysql-in-windows.html' title='Running MySQL in Windows'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-7252238837728534684</id><published>2008-10-31T10:24:00.000-07:00</published><updated>2008-10-31T10:25:02.233-07:00</updated><title type='text'>Apache Versus Tomcat</title><content type='html'>This is a pretty popular question judging from the results on google,so I just wanted to consolidate whatever information I found on the web,which helped me decide.&lt;br /&gt;&lt;br /&gt;Apache Http Server comes with other features like Modules configuration, SSL, SSO capabilities etc .&lt;br /&gt;If you use Apache Tomcat,you are restricted to serving jsp's and servlet's.&lt;br /&gt;Clustering: By using Apache as a front end you can let Apache act as a front door to your content to multiple Tomcat instances.so handling the failure of one Tomcat is easier.But you could always use Tomcats Clustering capabilities and a hardware load balancer.Apart from loadbalancing.&lt;br /&gt;Clustering/Security: You can also use Apache as a front door to different Tomcats for different URL namespaces (/app1/, /app2/, /app3/, or virtual hosts). The Tomcats can then be each in a protected area and from a security point of view, you only need to worry about the Apache server. Essentially, Apache becomes a smart proxy server. 2/ (i.e. the capability of reverse proxying, allowing you to 'plug in' one or more web applications running on one or more Tomcat instances in one URL space.)&lt;br /&gt;Security. This topic can sway one either way. Java has the security manager while Apache has a larger mindshare and more tricks with respect to security. But also keep in mind, if you run Apache with Tomcat - you have two systems to defend, not one.&lt;br /&gt;Add-ons. Adding on CGI, perl, PHP is very natural to Apache. Its slower and more of a kludge for Tomcat. Apache also has hundreds of modules that can be plugged in at will. &lt;br /&gt;With Apache in front of Tomcat, you can perform any number of decorators that Tomcat doesn't support or doesn't have the immediate code support. &lt;br /&gt;Speed. Apache is faster at serving static content than Tomcat. But unless you have a high traffic site, this point is useless. But in some scenarios, tomcat can be faster than apache. So benchmark YOUR site. Socket handling/system stability. Apache has better socket handling with respect to error conditions than Tomcat. The main reason is Tomcat must perform all its socket handling via the JVM which needs to be cross platform. The problem is socket optimization is a platform specific ordeal. Most of the time the java code is fine, but when you are also bombarded with dropped connections, invalid packets, invalid requests from invalid IP's, Apache does a better job at dropping these error conditions than JVM based program&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-7252238837728534684?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/7252238837728534684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=7252238837728534684' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7252238837728534684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7252238837728534684'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/10/apache-versus-tomcat.html' title='Apache Versus Tomcat'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-5449515283082389987</id><published>2008-10-31T10:22:00.000-07:00</published><updated>2008-10-31T10:23:15.059-07:00</updated><title type='text'>WebServers And Containers Basics</title><content type='html'>Apache Webserver versus Apache Tomcat is a popular question,and being on the brink of choosing between the two,I started googling,but before I blog what i found,I just wanted to go over the bare basics of webservers,containers and HTTP.For the experienced ones,skip this and go directly to the differences :Apache Versus Tomcat&lt;br /&gt;HTTP&lt;br /&gt;Hypertext Transfer Protocol (HTTP) is a communications protocol used to transfer information on the web. HTTP is a request/response protocol between a client and a server. The client i.e. a web browser or some other end-user tool makes an HTTP request(called the User Agent)(http://www.google.com/ .The responding server which stores or creates resources such as HTML files and images—is called the origin server understands this request and returns the html content specified by the URL. There can be proxies, gateways and tunnels in between the client and the server, but ultimately the server receives and understands the request and sends the requested resources to the client.The server can return pure HTML content/HTML content with scripts embedded within which are understood by the client's web browser and executed on the client appropriately/files.&lt;br /&gt;Typically, an HTTP client initiates a request by establishing a Transmission Control Protocol (TCP) connection to a particular port .An HTTP server listening on that port waits for the client to send a request message.&lt;br /&gt;Upon receiving the request, the server sends back a status line, such as "HTTP/1.1 200 OK", and a message of its own, the body of which is perhaps the requested file, an error message, or some other information.&lt;br /&gt;Resources to be accessed by HTTP are identified using Uniform Resource Identifiers (URIs) or Uniform Resource Locators (URL).&lt;br /&gt;Web Server&lt;br /&gt;A webserver is a piece of software that understands these HTTP requests,and is able to locate the resource that was requested,or atleast some component that will handle the request and return the resource.This is the basic functionality provided by any webserver.But on top of this,the webserver can also provide some services like: Authentication,handling static content and dynamic content(CGI,JSP,PHP,ASP e.t.c),HTTPS support(SSL or TLS) to allow secure encrypted connections to the server on the port 443 instead of 80,Content Compression,Virtual Hosting(Serve many websites using one IP address),Large File Support,Bandwidth throttling.&lt;br /&gt;&lt;br /&gt;A basic HTTP webserver only understands HTTP,If we are programming in JSP's and servlets,we need something that understands Servlets and JSP's,the job of a Servlet Container is just that.Consider Apache HTTP Server and Apache Tomcat.The Apache HTTP Server like the name suggests acts as a webserver,Apache Tomcat acts as a webserver and can also understands servlets(A servlet container).So in order to use the Apache Webserver and let it serve jsp's and servlet's we can plug the Apache Tomcat Container into the Apache HTTP Server.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-5449515283082389987?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/5449515283082389987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=5449515283082389987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/5449515283082389987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/5449515283082389987'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/10/webservers-and-containers-basics.html' title='WebServers And Containers Basics'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-9051939611368222351</id><published>2008-09-22T00:11:00.000-07:00</published><updated>2008-09-22T00:35:29.209-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tools'/><category scheme='http://www.blogger.com/atom/ns#' term='run'/><category scheme='http://www.blogger.com/atom/ns#' term='compile'/><category scheme='http://www.blogger.com/atom/ns#' term='editplus'/><title type='text'>Compiling and Running Java Source Files Using EditPlus Tools</title><content type='html'>There is a way to compile and run your Java source code files without using the command prompt! You can set up some menu options in EditPlus that allow you to quickly compile and run your Java programs. You might want to print these instructions so you can follow these steps. Later we will add a tool or two to this group, so make sure you keep or bookmark these instructions. &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting up the Tools&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Open up EditPlus. It doesn't matter if you have a new/existing document open or not.&lt;br /&gt;&lt;br /&gt;To follow these instructions, you need to know the drive and path where you installed your Java SDK. If you followed the default settings, this is probably c:\jdk1.5.0 or c:\Program Files\jdk1.5.0. If you have a different version of the Java SDK, then the folder name might vary slightly. It doesn't matter what it's called, as long as it contains the "bin" folder with all the SDK utilities. In the instructions, this folder will be referred to as the Java SDK folder.&lt;br /&gt;&lt;br /&gt;1.Select "Configure User Tools" from the "Tools" menu. &lt;br /&gt;2. You'll see "Groups and Tool Items" in the middle of the dialog box. Tool groups allow you to organize the different tools you want to create and maintain in EditPlus. We are going to create a tool group called "Java Tools". &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_h8w_fktOw40/SNdF2w18x5I/AAAAAAAAABg/3EP-lT3_MxI/s1600-h/ToolsDialog.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_h8w_fktOw40/SNdF2w18x5I/AAAAAAAAABg/3EP-lT3_MxI/s400/ToolsDialog.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5248740697850038162" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;a.You should see a dialog box like the image shown here. The default group name will probably be "Group 1". To change it, click on the Group Name button. &lt;br /&gt;b. In the New Name text box, type Java Tools &lt;br /&gt;c. Click OK. &lt;br /&gt;d. You should now see "Java Tools" in the pull-down box under the caption "Groups and Tool Items" &lt;br /&gt;&lt;br /&gt;3.Now you need to add some tools to your tool group. We'll start with a tool used to compile Java Source code files. If you don't have the Configure User Tools dialog box open, follow step 1 above. &lt;br /&gt;a.Click the Add Tool&gt;&gt;&gt; button and select Program from the pop-up menu. &lt;br /&gt;b.In the Menu Text field, type "Compile Java Source". This is the text you will see in the menu for this tool. &lt;br /&gt;c.Select the program that will run when you select the "Compile Java Source" menu item: Click the small button to the right of the "Command" field. &lt;br /&gt;d.Browse to your Java SDK folder and go into the "bin" subfolder. Find and select the file called JAVAC.EXE. Make sure you select the right file - there are a lot of files in this folder and they have similar names. When you're sure you have the right file, click Open. You should see the path and file information in the "Command" field. Of course you could type this in by hand instead of using the Browse button if you wanted to. &lt;br /&gt;e.When you run the Java compiler, you always give it the name of the source file as an argument. We can set this up for this tool: Click the button to the right of the "Argument" field and select File Name. You should see $(FileName) appear in the field. &lt;br /&gt;f.If you are using Java SDK 1.5 or higher, type -Xlint, followed by a space, in front of $(FileName). &lt;br /&gt;g.Click the button beside the "Initial Directory" field and select File Directory. You should see $(FileDir) appear in the field. This ensures that your compiler runs as if it were in the same folder as your Java source file. &lt;br /&gt;h.Lastly, check off the box for Capture Output. This will show the output to your compile in a small window at the bottom of the screen. If you prefer that the output i.Click the Apply button to save your tool changes&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_h8w_fktOw40/SNdHPO8AvDI/AAAAAAAAABo/Yy_w7Xt4IrE/s1600-h/configuredone.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_h8w_fktOw40/SNdHPO8AvDI/AAAAAAAAABo/Yy_w7Xt4IrE/s400/configuredone.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5248742217757015090" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;4.The next tool we need to add is for running our Java class files. Again, if you aren't in the configure user tools dialog box, follow step 1 above. &lt;br /&gt;&lt;br /&gt;a.Click the Add Tool&gt;&gt;&gt; button and select Program from the pop-up menu.&lt;br /&gt;&lt;br /&gt;b.In the Menu Text field, type Run Java Class. This is the text you will see in the menu for this tool.&lt;br /&gt;&lt;br /&gt;c.Select the program that will run when you select the "Run Java Class" menu item: Click the small button to the right of the "Command" field.&lt;br /&gt;&lt;br /&gt;d.Browse to your Java SDK's /bin folder and select the file called JAVA.EXE. Double check to make sure you have the right file selected, then click Open. You should see the path and file information in the "Command" field.&lt;br /&gt;&lt;br /&gt;e.When you use the JAVA command to run a Java class file, you always specify the name of the class file without the extension. We can set this up for this tool: Click the button to the right of the "Argument" field and select File Name without Extension. You should see $(FileNameNoExt) appear in the field.&lt;br /&gt;&lt;br /&gt;f.Click the button beside the "Initial Directory" field and select File Directory. You should see $(FileDir) appear in the field. This ensures that the java command interpreter runs as if it were in the same folder as your Java class file.&lt;br /&gt;&lt;br /&gt;g.Lastly, check off the box for &lt;span style="font-weight:bold;"&gt;Capture Output&lt;/span&gt;. This will show the output of your program (if any) in the same output window where you see the output to the compile process. If you would rather see the output in a command-prompt window, leave this option unchecked.&lt;br /&gt;&lt;br /&gt;h.Click the Apply button to save your tool changes. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;To run a program using command-line arguments&lt;/span&gt;, set up a new tool menu just like the one in step 3, but make sure you check off the box labeled "Prompt for Arguments". This will cause a dialog box to appear where you can type your command-line arguments (in the exact same format you would type them at the Dos prompt). &lt;br /&gt;&lt;br /&gt;You could also check off this box in the tool menu item you created in step 3, and when you run a program that does not require arguments, click the "Skip" button in the arguments dialog.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_h8w_fktOw40/SNdH70CVRQI/AAAAAAAAABw/Al1FkIlSxnA/s1600-h/dialogRun.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_h8w_fktOw40/SNdH70CVRQI/AAAAAAAAABw/Al1FkIlSxnA/s400/dialogRun.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5248742983629882626" /&gt;&lt;/a&gt;&lt;br /&gt;Dialog box with Run with Arguments settings &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_h8w_fktOw40/SNdIWA2ltfI/AAAAAAAAAB4/g3LD8RqckKk/s1600-h/dialogRunArgs.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_h8w_fktOw40/SNdIWA2ltfI/AAAAAAAAAB4/g3LD8RqckKk/s400/dialogRunArgs.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5248743433746888178" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Using the Tools&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To compile, go to the EditPlus window with the source file you want to compile and select "Compile Java Source" from the Tools menu. If you prefer using the keyboard, you can also compile the current program by pressing the Ctrl-1 keys.&lt;br /&gt;&lt;br /&gt;To run a class file, go to the EditPlus window with the source file you want to run (rather, the source file that is associated with the class file you want to run), and select "Run Java Class" from the Tools menu. If you prefer using the keyboard, you can also run the class file by pressing the Ctrl-2 keys.&lt;br /&gt;&lt;br /&gt;Note that the keyboard shortcuts may vary if you have already created user tools. You can see what shortcut keys are associated with your tools by looking at your tool menu items in the Tools menu.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-9051939611368222351?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/9051939611368222351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=9051939611368222351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/9051939611368222351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/9051939611368222351'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/09/compiling-and-running-java-source-files.html' title='Compiling and Running Java Source Files Using EditPlus Tools'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_h8w_fktOw40/SNdF2w18x5I/AAAAAAAAABg/3EP-lT3_MxI/s72-c/ToolsDialog.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-6689821455210178761</id><published>2008-09-11T02:38:00.000-07:00</published><updated>2008-09-11T02:39:05.963-07:00</updated><title type='text'>Primitive data types in java</title><content type='html'>2.4. Primitive Data Types&lt;br /&gt;Java supports eight basic data types known as primitive types. In addition, it supports classes and arrays as composite data types, or reference types. Classes and arrays are documented later in this chapter. The primitive types are: a boolean type, a character type, four integer types, and two floating-point types. The four integer types and the two floating-point types differ in the number of bits that represent them, and therefore in the range of numbers they can represent. Table 2-2 summarizes these primitive data types. &lt;br /&gt;&lt;br /&gt;Table 2-2. Java Primitive Data Types&lt;br /&gt;Type Contains Default Size Range &lt;br /&gt;boolean true or false false 1 bit NA &lt;br /&gt;char Unicode character \u0000 16 bits \u0000 to \uFFFF &lt;br /&gt;byte Signed integer 0 8 bits -128 to 127 &lt;br /&gt;short Signed integer 0 16 bits -32768 to 32767 &lt;br /&gt;int Signed integer 0 32 bits -2147483648 to 2147483647 &lt;br /&gt;long Signed integer 0 64 bits -9223372036854775808 to 9223372036854775807 &lt;br /&gt; &lt;br /&gt;float IEEE 754 floating point &lt;br /&gt; 0.0 32 bits ±1.4E-45 to ±3.4028235E+38 &lt;br /&gt; &lt;br /&gt;double IEEE 754 floating point &lt;br /&gt; 0.0 64 bits ±4.9E-324 to ±1.7976931348623157E+308 &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;2.4.1. The boolean Type&lt;br /&gt;The boolean type represents a truth value. There are only two possible values of this type, representing the two boolean states: on or off, yes or no, true or false. Java reserves the words true and false to represent these two boolean values. &lt;br /&gt;&lt;br /&gt;C and C++ programmers should note that Java is quite strict about its boolean type: boolean values can never be converted to or from other data types. In particular, a boolean is not an integral type, and integer values cannot be used in place of a boolean. In other words, you cannot take shortcuts such as the following in Java: &lt;br /&gt;&lt;br /&gt;if (o) {&lt;br /&gt;  while(i) {&lt;br /&gt;  }&lt;br /&gt;}Instead, Java forces you to write cleaner code by explicitly stating the comparisons you want: &lt;br /&gt;&lt;br /&gt;if (o != null) {&lt;br /&gt;  while(i != 0) {&lt;br /&gt;  }&lt;br /&gt;}2.4.2. The char Type&lt;br /&gt;The char type represents Unicode characters. It surprises many experienced programmers to learn that Java char values are 16 bits long, but in practice this fact is totally transparent. To include a character literal in a Java program, simply place it between single quotes (apostrophes): &lt;br /&gt;&lt;br /&gt;char c = 'A';You can, of course, use any Unicode character as a character literal, and you can use the \u Unicode escape sequence. In addition, Java supports a number of other escape sequences that make it easy both to represent commonly used nonprinting ASCII characters such as newline and to escape certain punctuation characters that have special meaning in Java. For example: &lt;br /&gt;&lt;br /&gt;char tab = '\t', apostrophe = '\'', nul = '\000', aleph='\u05D0';Table 2-3 lists the escape characters that can be used in char literals. These characters can also be used in string literals, which are covered later in this chapter. &lt;br /&gt;&lt;br /&gt;Table 2-3. Java Escape Characters&lt;br /&gt;Escape Sequence Character Value &lt;br /&gt;\b Backspace &lt;br /&gt;\t Horizontal tab &lt;br /&gt; \n Newline &lt;br /&gt;\f Form feed &lt;br /&gt;\r Carriage return &lt;br /&gt;\" Double quote &lt;br /&gt;\' Single quote &lt;br /&gt;\\ Backslash &lt;br /&gt;\xxx The Latin-1 character with the encoding xxx, where xxx is an octal (base 8) number between 000 and 377. The forms \x and \xx are also legal, as in '\0', but are not recommended because they can cause difficulties in string constants where the escape sequence is followed by a regular digit. &lt;br /&gt; &lt;br /&gt;\uxxxx The Unicode character with encoding xxxx, where xxxx is four hexadecimal digits. Unicode escapes can appear anywhere in a Java program, not only in character and string literals. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;char values can be converted to and from the various integral types. Unlike byte, short, int, and long, however, char is an unsigned type. The Character class defines a number of useful static methods for working with characters, including isDigit(), isJavaLetter(), isLowerCase(), and toUpperCase(). &lt;br /&gt;&lt;br /&gt;2.4.3. Integer Types&lt;br /&gt;The integer types in Java are byte, short, int, and long. As shown in Table 2-2, these four types differ only in the number of bits and, therefore, in the range of numbers each type can represent. All integral types represent signed numbers; there is no unsigned keyword as there is in C and C++. &lt;br /&gt;&lt;br /&gt;Literals for each of these types are written exactly as you would expect: as a string of decimal digits. Although it is not technically part of the literal syntax, any integer literal can be preceded by the unary minus operator to indicate a negative number. Here are some legal integer literals: &lt;br /&gt;&lt;br /&gt;0&lt;br /&gt;1&lt;br /&gt;123&lt;br /&gt;-42000Integer literals can also be expressed in hexadecimal or octal notation. A literal that begins with 0x or 0X is taken as a hexadecimal number, using the letters A to F (or a to f) as the additional digits required for base-16 numbers. Integer literals beginning with a leading 0 are taken to be octal (base-8) numbers and cannot include the digits 8 or 9. Java does not allow integer literals to be expressed in binary (base-2) notation. Legal hexadecimal and octal literals include: &lt;br /&gt;&lt;br /&gt;0xff              // Decimal 255, expressed in hexadecimal&lt;br /&gt;0377              // The same number, expressed in octal (base 8)&lt;br /&gt;0xCAFEBABE        // A magic number used to identify Java class filesInteger literals are 32-bit int values unless they end with the character L or l, in which case they are 64-bit long values: &lt;br /&gt;&lt;br /&gt;1234        // An int value&lt;br /&gt;1234L       // A long value&lt;br /&gt;0xffL       // Another long valueInteger arithmetic in Java is modular, which means that it never produces an overflow or an underflow when you exceed the range of a given integer type. Instead, numbers just wrap around. For example: &lt;br /&gt;&lt;br /&gt;byte b1 = 127, b2 = 1;   // Largest byte is 127&lt;br /&gt;byte sum = b1 + b2;      // Sum wraps to -128, which is the smallest byteNeither the Java compiler nor the Java interpreter warns you in any way when this occurs. When doing integer arithmetic, you simply must ensure that the type you are using has a sufficient range for the purposes you intend. Integer division by zero and modulo by zero are illegal and cause an ArithmeticException to be thrown. &lt;br /&gt;&lt;br /&gt;Each integer type has a corresponding wrapper class: Byte, Short, Integer, and Long. Each of these classes defines MIN_VALUE and MAX_VALUE constants that describe the range of the type. The classes also define useful static methods, such as Byte.parseByte() and Integer.parseInt(), for converting strings to integer values. &lt;br /&gt;&lt;br /&gt;2.4.4. Floating-Point Types&lt;br /&gt;Real numbers in Java are represented with the float and double data types. As shown in Table 2-3, float is a 32-bit, single-precision floating-point value, and double is a 64-bit, double-precision floating-point value. Both types adhere to the IEEE 754-1985 standard, which specifies both the format of the numbers and the behavior of arithmetic for the numbers. &lt;br /&gt;&lt;br /&gt;Floating-point values can be included literally in a Java program as an optional string of digits, followed by a decimal point and another string of digits. Here are some examples: &lt;br /&gt;&lt;br /&gt;123.45&lt;br /&gt;0.0&lt;br /&gt;.01Floating-point literals can also use exponential, or scientific, notation, in which a number is followed by the letter e or E (for exponent) and another number. This second number represents the power of ten by which the first number is multiplied. For example: &lt;br /&gt;&lt;br /&gt;1.2345E02      // 1.2345 * 10^2, or 123.45&lt;br /&gt;1e-6           // 1 * 10^-6, or 0.000001&lt;br /&gt;6.02e23        // Avagadro's Number: 6.02 * 10^23Floating-point literals are double values by default. To include a float value literally in a program, follow the number by the character f or F: &lt;br /&gt;&lt;br /&gt;double d = 6.02E23;&lt;br /&gt;float f = 6.02e23f;Floating-point literals cannot be expressed in hexadecimal or octal notation. &lt;br /&gt;&lt;br /&gt;Most real numbers, by their very nature, cannot be represented exactly in any finite number of bits. Thus, it is important to remember that float and double values are only approximations of the numbers they are meant to represent. A float is a 32-bit approximation, which results in at least 6 significant decimal digits, and a double is a 64-bit approximation, which results in at least 15 significant digits. In practice, these data types are suitable for most real-number computations. &lt;br /&gt;&lt;br /&gt;In addition to representing ordinary numbers, the float and double types can also represent four special values: positive and negative infinity, zero, and NaN. The infinity values result when a floating-point computation produces a value that overflows the representable range of a float or double. When a floating-point computation underflows the representable range of a float or a double, a zero value results. The Java floating-point types make a distinction between positive zero and negative zero, depending on the direction from which the underflow occurred. In practice, positive and negative zero behave pretty much the same. Finally, the last special floating-point value is NaN, which stands for not-a-number. The NaN value results when an illegal floating-point operation, such as 0/0, is performed. Here are examples of statements that result in these special values: &lt;br /&gt;&lt;br /&gt;double inf = 1/0;             // Infinity&lt;br /&gt;double neginf = -1/0;         // -Infinity&lt;br /&gt;double negzero = -1/inf;      // Negative zero&lt;br /&gt;double NaN = 0/0;             // NaNBecause the Java floating-point types can handle overflow to infinity and underflow to zero and have a special NaN value, floating-point arithmetic never throws exceptions, even when performing illegal operations, like dividing zero by zero or taking the square root of a negative number. &lt;br /&gt;&lt;br /&gt;The float and double primitive types have corresponding classes, named Float and Double. Each of these classes defines the following useful constants: MIN_VALUE, MAX_VALUE, NEGATIVE_INFINITY, POSITIVE_INFINITY, and NaN. &lt;br /&gt;&lt;br /&gt;The infinite floating-point values behave as you would expect. Adding or subtracting anything to or from infinity, for example, yields infinity. Negative zero behaves almost identically to positive zero, and, in fact, the = = equality operator reports that negative zero is equal to positive zero. The only way to distinguish negative zero from positive, or regular, zero is to divide by it. 1/0 yields positive infinity, but 1 divided by negative zero yields negative infinity. Finally, since NaN is not-a-number, the = = operator says that it is not equal to any other number, including itself ! To check whether a float or double value is NaN, you must use the Float.isNan() and Double.isNan() methods. &lt;br /&gt;&lt;br /&gt;2.4.5. Strings&lt;br /&gt;In addition to the boolean, character, integer, and floating-point data types, Java also has a data type for working with strings of text (usually simply called strings). The String type is a class, however, and is not one of the primitive types of the language. Because strings are so commonly used, though, Java does have a syntax for including string values literally in a program. A String literal consists of arbitrary text within double quotes. For example: &lt;br /&gt;&lt;br /&gt;"Hello, world"&lt;br /&gt;"'This' is a string!"String literals can contain any of the escape sequences that can appear as char literals (see Table 2-3). Use the \" sequence to include a double-quote within a String literal. Strings and string literals are discussed in more detail later in this chapter. Chapter 4, "The Java Platform", demonstrates some of the ways you can work with String objects in Java. &lt;br /&gt;&lt;br /&gt;2.4.6. Type Conversions&lt;br /&gt;Java allows conversions between integer values and floating-point values. In addition, because every character corresponds to a number in the Unicode encoding, char types can be converted to and from the integer and floating-point types. In fact, boolean is the only primitive type that cannot be converted to or from another primitive type in Java. &lt;br /&gt;&lt;br /&gt;There are two basic types of conversions. A widening conversion occurs when a value of one type is converted to a wider type--one that is represented with more bits and therefore has a wider range of legal values. A narrowing conversion occurs when a value is converted to a type that is represented with fewer bits. Java performs widening conversions automatically when, for example, you assign an int literal to a double variable or a char literal to an int variable. &lt;br /&gt;&lt;br /&gt;Narrowing conversions are another matter, however, and are not always safe. It is reasonable to convert the integer value 13 to a byte, for example, but it is not reasonable to convert 13000 to a byte, since byte can only hold numbers between -128 and 127. Because you can lose data in a narrowing conversion, the Java compiler complains when you attempt any narrowing conversion, even if the value being converted would in fact fit in the narrower range of the specified type: &lt;br /&gt;&lt;br /&gt;int i = 13;&lt;br /&gt;byte b = i;    // The compiler does not allow thisThe one exception to this rule is that you can assign an integer literal (an int value) to a byte or short variable, if the literal falls within the range of the variable. &lt;br /&gt;&lt;br /&gt;If you need to perform a narrowing conversion and are confident you can do so without losing data or precision, you can force Java to perform the conversion using a language construct known as a cast. Perform a cast by placing the name of the desired type in parentheses before the value to be converted. For example: &lt;br /&gt;&lt;br /&gt;int i = 13;&lt;br /&gt;byte b = (byte) i;   // Force the int to be converted to a byte&lt;br /&gt;i = (int) 13.456;    // Force this double literal to the int 13Casts of primitive types are most often used to convert floating-point values to integers. When you do this, the fractional part of the floating-point value is simply truncated (i.e., the floating-point value is rounded towards zero, not towards the nearest integer). The methods Math.round(), Math.floor(), and Math.ceil() perform other types of rounding. &lt;br /&gt;&lt;br /&gt;The char type acts like an integer type in most ways, so a char value can be used anywhere an int or long value is required. Recall, however, that the char type is unsigned, so it behaves differently than the short type, even though both of them are 16 bits wide: &lt;br /&gt;&lt;br /&gt;short s = (short) 0xffff; // These bits represent the number -1&lt;br /&gt;char c = '\uffff';        // The same bits, representing a Unicode character&lt;br /&gt;int i1 = s;               // Converting the short to an int yields -1&lt;br /&gt;int i2 = c;               // Converting the char to an int yields 65535&lt;br /&gt; Table 2-4 is a grid that shows which primitive types can be converted to which other types and how the conversion is performed. The letter N in the table means that the conversion cannot be performed. The letter Y means that the conversion is a widening conversion and is therefore performed automatically and implicitly by Java. The letter C means that the conversion is a narrowing conversion and requires an explicit cast. Finally, the notation Y* means that the conversion is an automatic widening conversion, but that some of the least significant digits of the value may be lost by the conversion. This can happen when converting an int or long to a float or double. The floating-point types have a larger range than the integer types, so any int or long can be represented by a float or double. However, the floating-point types are approximations of numbers and cannot always hold as many significant digits as the integer types. &lt;br /&gt;&lt;br /&gt;Table 2-4. Java Primitive Type Conversions&lt;br /&gt;Convert Convert To: &lt;br /&gt;From: boolean byte short char int long float double &lt;br /&gt;boolean - N N N N N N N &lt;br /&gt;byte N - Y C Y Y Y Y &lt;br /&gt;short N C - C Y Y Y Y &lt;br /&gt;char N C C - Y Y Y Y &lt;br /&gt;int N C C C - Y Y* Y &lt;br /&gt;long N C C C C - Y* Y* &lt;br /&gt;float N C C C C C - Y &lt;br /&gt;double N C C C C C C - &lt;br /&gt;&lt;br /&gt;2.4.7. Reference Types&lt;br /&gt;In addition to its eight primitive types, Java defines two additional categories of data types: classes and arrays. Java programs consist of class definitions; each class defines a new data type that can be manipulated by Java programs. For example, a program might define a class named Point and use it to store and manipulate X,Y points in a Cartesian coordinate system. This makes Point a new data type in that program. An array type represents a list of values of some other type. char is a data type, and an array of char values is another data type, written char[]. An array of Point objects is a data type, written Point[]. And an array of Point arrays is yet another type, written Point[][]. &lt;br /&gt;&lt;br /&gt;As you can see, there are an infinite number of possible class and array data types. Collectively, these data types are known as reference types. The reason for this name will become clear later in this chapter. For now, however, what is important to understand is that class and array types differ significantly from primitive types, in that they are compound, or composite, types. A primitive data type holds exactly one value. Classes and arrays are aggregate types that contain multiple values. The Point type, for example, holds two double values representing the X and Y coordinates of the point. And char[] is obviously a compound type because it represents a list of characters. By their very nature, class and array types are more complicated than the primitive data types. We'll discuss classes and arrays in detail later in this chapter and examine classes in even more detail in Chapter 3, "Object-Oriented Programming in Java".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-6689821455210178761?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/6689821455210178761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=6689821455210178761' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6689821455210178761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6689821455210178761'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/09/primitive-data-types-in-java.html' title='Primitive data types in java'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-171755029343983048</id><published>2008-07-22T06:11:00.000-07:00</published><updated>2008-07-22T06:16:49.375-07:00</updated><title type='text'>Core J2EE Patterns - Data Access Object</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Context&lt;/span&gt;&lt;br /&gt;Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly depending on the type of storage (relational databases, object-oriented databases, flat files, and so forth) and the vendor implementation.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Problem&lt;/span&gt;&lt;br /&gt;Many real-world Java 2 Platform, Enterprise Edition (J2EE) applications need to use persistent data at some point. For many applications, persistent storage is implemented with different mechanisms, and there are marked differences in the APIs used to access these different persistent storage mechanisms. Other applications may need to access data that resides on separate systems. For example, the data may reside in mainframe systems, Lightweight Directory Access Protocol (LDAP) repositories, and so forth. Another example is where data is provided by services through external systems such as business-to-business (B2B) integration systems, credit card bureau service, and so forth.&lt;br /&gt;&lt;br /&gt;Typically, applications use shared distributed components such as entity beans to represent persistent data. An application is considered to employ bean-managed persistence (BMP) for its entity beans when these entity beans explicitly access the persistent storage-the entity bean includes code to directly access the persistent storage. An application with simpler requirements may forego using entity beans and instead use session beans or servlets to directly access the persistent storage to retrieve and modify the data. Or, the application could use entity beans with container-managed persistence, and thus let the container handle the transaction and persistent details.&lt;br /&gt;&lt;br /&gt;Applications can use the JDBC API to access data residing in a relational database management system (RDBMS). The JDBC API enables standard access and manipulation of data in persistent storage, such as a relational database. The JDBC API enables J2EE applications to use SQL statements, which are the standard means for accessing RDBMS tables. However, even within an RDBMS environment, the actual syntax and format of the SQL statements may vary depending on the particular database product.&lt;br /&gt;&lt;br /&gt;There is even greater variation with different types of persistent storage. Access mechanisms, supported APIs, and features vary between different types of persistent stores such as RDBMS, object-oriented databases, flat files, and so forth. Applications that need to access data from a legacy or disparate system (such as a mainframe, or B2B service) are often required to use APIs that may be proprietary. Such disparate data sources offer challenges to the application and can potentially create a direct dependency between application code and data access code. When business components-entity beans, session beans, and even presentation components like servlets and helper objects for JavaServer Pages (JSP) pages --need to access a data source, they can use the appropriate API to achieve connectivity and manipulate the data source. But including the connectivity and data access code within these components introduces a tight coupling between the components and the data source implementation. Such code dependencies in components make it difficult and tedious to migrate the application from one type of data source to another. When the data source changes, the components need to be changed to handle the new type of data source.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Forces&lt;/span&gt;&lt;br /&gt;Components such as bean-managed entity beans, session beans, servlets, and other objects like helpers for JSP pages need to retrieve and store information from persistent stores and other data sources like legacy systems, B2B, LDAP, and so forth. &lt;br /&gt;&lt;br /&gt;Persistent storage APIs vary depending on the product vendor. Other data sources may have APIs that are nonstandard and/or proprietary. These APIs and their capabilities also vary depending on the type of storage-RDBMS, object-oriented database management system (OODBMS), XML documents, flat files, and so forth. There is a lack of uniform APIs to address the requirements to access such disparate systems. &lt;br /&gt;&lt;br /&gt;Components typically use proprietary APIs to access external and/or legacy systems to retrieve and store data. &lt;br /&gt;&lt;br /&gt;Portability of the components is directly affected when specific access mechanisms and APIs are included in the components. &lt;br /&gt;&lt;br /&gt;Components need to be transparent to the actual persistent store or data source implementation to provide easy migration to different vendor products, different storage types, and different data source types. &lt;br /&gt;&lt;br /&gt;Solution&lt;br /&gt;Use a Data Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.&lt;br /&gt;&lt;br /&gt;The DAO implements the access mechanism required to work with the data source. The data source could be a persistent store like an RDBMS, an external service like a B2B exchange, a repository like an LDAP database, or a business service accessed via CORBA Internet Inter-ORB Protocol (IIOP) or low-level sockets. The business component that relies on the DAO uses the simpler interface exposed by the DAO for its clients. The DAO completely hides the data source implementation details from its clients. Because the interface exposed by the DAO to clients does not change when the underlying data source implementation changes, this pattern allows the DAO to adapt to different storage schemes without affecting its clients or business components. Essentially, the DAO acts as an adapter between the component and the data source.&lt;br /&gt;&lt;br /&gt;Structure&lt;br /&gt;Figure 9.1 shows the class diagram representing the relationships for the DAO pattern.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_h8w_fktOw40/SIXdAE-VonI/AAAAAAAAABY/kjp5lAMHWA0/s1600-h/figure09_01.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_h8w_fktOw40/SIXdAE-VonI/AAAAAAAAABY/kjp5lAMHWA0/s400/figure09_01.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5225825936038273650" /&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;Figure 9.1 Data Access Object &lt;br /&gt;&lt;br /&gt;Participants and Responsibilities&lt;br /&gt;Figure 9.2 contains the sequence diagram that shows the interaction between the various participants in this pattern.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_02.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px;" src="http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_02.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Figure 9.2 Data Access Object sequence diagram &lt;br /&gt;&lt;br /&gt;BusinessObject&lt;br /&gt;The BusinessObject represents the data client. It is the object that requires access to the data source to obtain and store data. A BusinessObject may be implemented as a session bean, entity bean, or some other Java object, in addition to a servlet or helper bean that accesses the data source.&lt;br /&gt;&lt;br /&gt;DataAccessObject&lt;br /&gt;The DataAccessObject is the primary object of this pattern. The DataAccessObject abstracts the underlying data access implementation for the BusinessObject to enable transparent access to the data source. The BusinessObject also delegates data load and store operations to the DataAccessObject.&lt;br /&gt;&lt;br /&gt;DataSource&lt;br /&gt;This represents a data source implementation. A data source could be a database such as an RDBMS, OODBMS, XML repository, flat file system, and so forth. A data source can also be another system (legacy/mainframe), service (B2B service or credit card bureau), or some kind of repository (LDAP).&lt;br /&gt;&lt;br /&gt;TransferObject&lt;br /&gt;This represents a Transfer Object used as a data carrier. The DataAccessObject may use a Transfer Object to return data to the client. The DataAccessObject may also receive the data from the client in a Transfer Object to update the data in the data source.&lt;br /&gt;&lt;br /&gt;Strategies &lt;br /&gt;Automatic DAO Code Generation Strategy&lt;br /&gt;Since each BusinessObject corresponds to a specific DAO, it is possible to establish relationships between the BusinessObject, DAO, and underlying implementations (such as the tables in an RDBMS). Once the relationships are established, it is possible to write a simple application-specific code-generation utility that generates the code for all DAOs required by the application. The metadata to generate the DAO can come from a developer-defined descriptor file. Alternatively, the code generator can automatically introspect the database and provide the necessary DAOs to access the database. If the requirements for DAOs are sufficiently complex, consider using third-party tools that provide object-to-relational mapping for RDBMS databases. These tools typically include GUI tools to map the business objects to the persistent storage objects and thereby define the intermediary DAOs. The tools automatically generate the code once the mapping is complete, and may provide other value-added features such as results caching, query caching, integration with application servers, integration with other third-party products (e.g., distributed caching), and so forth.&lt;br /&gt;&lt;br /&gt;Factory for Data Access Objects Strategy&lt;br /&gt;The DAO pattern can be made highly flexible by adopting the Abstract Factory [GoF] and the Factory Method [GoF] patterns (see "Related Patterns" in this chapter).&lt;br /&gt;&lt;br /&gt;When the underlying storage is not subject to change from one implementation to another, this strategy can be implemented using the Factory Method pattern to produce a number of DAOs needed by the application. The class diagram for this case is shown in Figure 9.3.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_03.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px;" src="http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_03.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Figure 9.3 Factory for Data Access Object strategy using Factory Method &lt;br /&gt;&lt;br /&gt;When the underlying storage is subject to change from one implementation to another, this strategy may be implemented using the Abstract Factory pattern. The Abstract Factory can in turn build on and use the Factory Method implementation, as suggested in Design Patterns: Elements of Reusable Object-Oriented Software [GoF]. In this case, this strategy provides an abstract DAO factory object (Abstract Factory) that can construct various types of concrete DAO factories, each factory supporting a different type of persistent storage implementation. Once you obtain the concrete DAO factory for a specific implementation, you use it to produce DAOs supported and implemented in that implementation.&lt;br /&gt;&lt;br /&gt;The class diagram for this strategy is shown in Figure 9.4. This class diagram shows a base DAO factory, which is an abstract class that is inherited and implemented by different concrete DAO factories to support storage implementation-specific access. The client can obtain a concrete DAO factory implementation such as RdbDAOFactory and use it to obtain concrete DAOs that work with that specific storage implementation. For example, the data client can obtain an RdbDAOFactory and use it to get specific DAOs such as RdbCustomerDAO, RdbAccountDAO, and so forth. The DAOs can extend and implement a generic base class (shown as DAO1 and DAO2) that specifically describe the DAO requirements for the business object it supports. Each concrete DAO is responsible for connecting to the data source and obtaining and manipulating data for the business object it supports.&lt;br /&gt;&lt;br /&gt;The sample implementation for the DAO pattern and its strategies is shown in the "Sample Code" section of this chapter.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 9.4 Factory for Data Access Object strategy using Abstract Factory &lt;br /&gt;&lt;br /&gt;The sequence diagram describing the interactions for this strategy is shown in Figure 9.5.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 9.5 Factory for Data Access Objects using Abstract Factory sequence diagram &lt;br /&gt;&lt;br /&gt;Consequences&lt;br /&gt;Enables Transparency&lt;br /&gt;Business objects can use the data source without knowing the specific details of the data source's implementation. Access is transparent because the implementation details are hidden inside the DAO. &lt;br /&gt;&lt;br /&gt;Enables Easier Migration&lt;br /&gt;A layer of DAOs makes it easier for an application to migrate to a different database implementation. The business objects have no knowledge of the underlying data implementation. Thus, the migration involves changes only to the DAO layer. Further, if employing a factory strategy, it is possible to provide a concrete factory implementation for each underlying storage implementation. In this case, migrating to a different storage implementation means providing a new factory implementation to the application. &lt;br /&gt;&lt;br /&gt;Reduces Code Complexity in Business ObjectsBecause the DAOs manage all the data access complexities, it simplifies the code in the business objects and other data clients that use the DAOs. All implementation-related code (such as SQL statements) is contained in the DAO and not in the business object. This improves code readability and development productivity. &lt;br /&gt;&lt;br /&gt;Centralizes All Data Access into a Separate Layer&lt;br /&gt;Because all data access operations are now delegated to the DAOs, the separate data access layer can be viewed as the layer that can isolate the rest of the application from the data access implementation. This centralization makes the application easier to maintain and manage. &lt;br /&gt;&lt;br /&gt;Not Useful for Container-Managed Persistence&lt;br /&gt;Because the EJB container manages entity beans with container-managed persistence (CMP), the container automatically services all persistent storage access. Applications using container-managed entity beans do not need a DAO layer, since the application server transparently provides this functionality. However, DAOs are still useful when a combination of CMP (for entity beans) and BMP (for session beans, servlets) is required. &lt;br /&gt;&lt;br /&gt;Adds Extra Layer&lt;br /&gt;The DAOs create an additional layer of objects between the data client and the data source that need to be designed and implemented to leverage the benefits of this pattern. But the benefit realized by choosing this approach pays off for the additional effort. &lt;br /&gt;&lt;br /&gt;Needs Class Hierarchy Design&lt;br /&gt;When using a factory strategy, the hierarchy of concrete factories and the hierarchy of concrete products produced by the factories need to be designed and implemented. This additional effort needs to be considered if there is sufficient justification warranting such flexibility. This increases the complexity of the design. However, you can choose to implement the factory strategy starting with the Factory Method pattern first, and then move towards the Abstract Factory if necessary. &lt;br /&gt;&lt;br /&gt;Sample Code&lt;br /&gt;Implementing Data Access Object pattern&lt;br /&gt;An example DAO code for a persistent object that represents Customer information is shown in Example 9.4. The CloudscapeCustomerDAO creates a Customer Transfer Object when the findCustomer() method is invoked.&lt;br /&gt;&lt;br /&gt;The sample code to use the DAO is shown in Example 9.6. The class diagram for this example is shown in Figure 9.6.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 9.6 Implementing the DAO pattern &lt;br /&gt;&lt;br /&gt;Implementing Factory for Data Access Objects Strategy&lt;br /&gt;Using Factory Method Pattern&lt;br /&gt;Consider an example where we are implementing this strategy in which a DAO factory produces many DAOs for a single database implementation (e.g., Oracle). The factory produces DAOs such as CustomerDAO, AccountDAO, OrderDAO, and so forth. The class diagram for this example is shown in Figure 9.7.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 9.7 Implementing the Factory for DAO strategy using Factory Method &lt;br /&gt;&lt;br /&gt;The example code for the DAO factory (CloudscapeDAOFactory) is listed in Example 9.2.&lt;br /&gt;&lt;br /&gt;Using Abstract Factory Pattern&lt;br /&gt;Consider an example where we are considering implementing this strategy for three different databases. In this case, the Abstract Factory pattern can be employed. The class diagram for this example is shown in Figure 9.8. The sample code in Example 9.1 shows code excerpt for the abstract DAOFactory class. This factory produces DAOs such as CustomerDAO, AccountDAO, OrderDAO, and so forth. This strategy uses the Factory Method implementation in the factories produced by the Abstract Factory.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Figure 9.8 Implementing the Factory for DAO strategy using Abstract Factory Example 9.1 Abstract DAOFactory Class &lt;br /&gt;&lt;br /&gt;// Abstract class DAO Factory&lt;br /&gt;public abstract class DAOFactory {&lt;br /&gt;&lt;br /&gt;  // List of DAO types supported by the factory&lt;br /&gt;  public static final int CLOUDSCAPE = 1;&lt;br /&gt;  public static final int ORACLE = 2;&lt;br /&gt;  public static final int SYBASE = 3;&lt;br /&gt;  ...&lt;br /&gt;&lt;br /&gt;  // There will be a method for each DAO that can be &lt;br /&gt;  // created. The concrete factories will have to &lt;br /&gt;  // implement these methods.&lt;br /&gt;  public abstract CustomerDAO getCustomerDAO();&lt;br /&gt;  public abstract AccountDAO getAccountDAO();&lt;br /&gt;  public abstract OrderDAO getOrderDAO();&lt;br /&gt;  ...&lt;br /&gt;&lt;br /&gt;  public static DAOFactory getDAOFactory(&lt;br /&gt;      int whichFactory) {&lt;br /&gt;  &lt;br /&gt;    switch (whichFactory) {&lt;br /&gt;      case CLOUDSCAPE: &lt;br /&gt;          return new CloudscapeDAOFactory();&lt;br /&gt;      case ORACLE    : &lt;br /&gt;          return new OracleDAOFactory();      &lt;br /&gt;      case SYBASE    : &lt;br /&gt;          return new SybaseDAOFactory();&lt;br /&gt;      ...&lt;br /&gt;      default           : &lt;br /&gt;          return null;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The sample code for CloudscapeDAOFactory is shown in Example 9.2. The implementation for OracleDAOFactory and SybaseDAOFactory are similar except for specifics of each implementation, such as JDBC driver, database URL, and differences in SQL syntax, if any.&lt;br /&gt;&lt;br /&gt;Example 9.2 Concrete DAOFactory Implementation for Cloudscape &lt;br /&gt;&lt;br /&gt;// Cloudscape concrete DAO Factory implementation&lt;br /&gt;import java.sql.*;&lt;br /&gt;&lt;br /&gt;public class CloudscapeDAOFactory extends DAOFactory {&lt;br /&gt;  public static final String DRIVER=&lt;br /&gt;    "COM.cloudscape.core.RmiJdbcDriver";&lt;br /&gt;  public static final String DBURL=&lt;br /&gt;    "jdbc:cloudscape:rmi://localhost:1099/CoreJ2EEDB";&lt;br /&gt;&lt;br /&gt;  // method to create Cloudscape connections&lt;br /&gt;  public static Connection createConnection() {&lt;br /&gt;    // Use DRIVER and DBURL to create a connection&lt;br /&gt;    // Recommend connection pool implementation/usage&lt;br /&gt;  }&lt;br /&gt;  public CustomerDAO getCustomerDAO() {&lt;br /&gt;    // CloudscapeCustomerDAO implements CustomerDAO&lt;br /&gt;    return new CloudscapeCustomerDAO();&lt;br /&gt;  }&lt;br /&gt;  public AccountDAO getAccountDAO() {&lt;br /&gt;    // CloudscapeAccountDAO implements AccountDAO&lt;br /&gt;    return new CloudscapeAccountDAO();&lt;br /&gt;  }&lt;br /&gt;  public OrderDAO getOrderDAO() {&lt;br /&gt;    // CloudscapeOrderDAO implements OrderDAO&lt;br /&gt;    return new CloudscapeOrderDAO();&lt;br /&gt;  }&lt;br /&gt;  ...&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The CustomerDAO interface shown in Example 9.3 defines the DAO methods for Customer persistent object that are implemented by all concrete DAO implementations, such as CloudscapeCustomerDAO, OracleCustomerDAO, and SybaseCustomerDAO. Similar, but not listed here, are AccountDAO and OrderDAO interfaces that define the DAO methods for Account and Order business objects respectively.&lt;br /&gt;&lt;br /&gt;Example 9.3 Base DAO Interface for Customer &lt;br /&gt;&lt;br /&gt;// Interface that all CustomerDAOs must support&lt;br /&gt;public interface CustomerDAO {&lt;br /&gt;  public int insertCustomer(...);&lt;br /&gt;  public boolean deleteCustomer(...);&lt;br /&gt;  public Customer findCustomer(...);&lt;br /&gt;  public boolean updateCustomer(...);&lt;br /&gt;  public RowSet selectCustomersRS(...);&lt;br /&gt;  public Collection selectCustomersTO(...);&lt;br /&gt;  ...&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The CloudscapeCustomerDAO implements the CustomerDAO as shown in Example 9.4. The implementation of other DAOs, such as CloudscapeAccountDAO, CloudscapeOrderDAO, OracleCustomerDAO, OracleAccountDAO, and so forth, are similar.&lt;br /&gt;&lt;br /&gt;Example 9.4 Cloudscape DAO Implementation for Customer &lt;br /&gt;&lt;br /&gt;// CloudscapeCustomerDAO implementation of the &lt;br /&gt;// CustomerDAO interface. This class can contain all&lt;br /&gt;// Cloudscape specific code and SQL statements. &lt;br /&gt;// The client is thus shielded from knowing &lt;br /&gt;// these implementation details.&lt;br /&gt;&lt;br /&gt;import java.sql.*;&lt;br /&gt;&lt;br /&gt;public class CloudscapeCustomerDAO implements &lt;br /&gt;    CustomerDAO {&lt;br /&gt;  &lt;br /&gt;  public CloudscapeCustomerDAO() {&lt;br /&gt;    // initialization &lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  // The following methods can use&lt;br /&gt;  // CloudscapeDAOFactory.createConnection() &lt;br /&gt;  // to get a connection as required&lt;br /&gt;&lt;br /&gt;  public int insertCustomer(...) {&lt;br /&gt;    // Implement insert customer here.&lt;br /&gt;    // Return newly created customer number&lt;br /&gt;    // or a -1 on error&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  public boolean deleteCustomer(...) {&lt;br /&gt;    // Implement delete customer here&lt;br /&gt;    // Return true on success, false on failure&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public Customer findCustomer(...) {&lt;br /&gt;    // Implement find a customer here using supplied&lt;br /&gt;    // argument values as search criteria&lt;br /&gt;    // Return a Transfer Object if found,&lt;br /&gt;    // return null on error or if not found&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public boolean updateCustomer(...) {&lt;br /&gt;    // implement update record here using data&lt;br /&gt;    // from the customerData Transfer Object&lt;br /&gt;    // Return true on success, false on failure or&lt;br /&gt;    // error&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public RowSet selectCustomersRS(...) {&lt;br /&gt;    // implement search customers here using the&lt;br /&gt;    // supplied criteria.&lt;br /&gt;    // Return a RowSet. &lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public Collection selectCustomersTO(...) {&lt;br /&gt;    // implement search customers here using the&lt;br /&gt;    // supplied criteria.&lt;br /&gt;    // Alternatively, implement to return a Collection &lt;br /&gt;    // of Transfer Objects.&lt;br /&gt;  }&lt;br /&gt;  ...&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Customer Transfer Object class is shown in Example 9.5. This is used by the DAOs to send and receive data from the clients. The usage of Transfer Objects is discussed in detail in the Transfer Object pattern.&lt;br /&gt;&lt;br /&gt;Example 9.5 Customer Transfer Object &lt;br /&gt;&lt;br /&gt;public class Customer implements java.io.Serializable {&lt;br /&gt;  // member variables&lt;br /&gt;  int CustomerNumber;&lt;br /&gt;  String name;&lt;br /&gt;  String streetAddress;&lt;br /&gt;  String city;&lt;br /&gt;  ...&lt;br /&gt;&lt;br /&gt;  // getter and setter methods...&lt;br /&gt;  ...&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example 9.6 shows the usage of the DAO factory and the DAO. If the implementation changes from Cloudscape to another product, the only required change is the getDAOFactory() method call to the DAO factory to obtain a different factory.&lt;br /&gt;&lt;br /&gt;Example 9.6 Using a DAO and DAO Factory - Client Code &lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;// create the required DAO Factory&lt;br /&gt;DAOFactory cloudscapeFactory =   &lt;br /&gt;  DAOFactory.getDAOFactory(DAOFactory.DAOCLOUDSCAPE);&lt;br /&gt;&lt;br /&gt;// Create a DAO&lt;br /&gt;CustomerDAO custDAO = &lt;br /&gt;  cloudscapeFactory.getCustomerDAO();&lt;br /&gt;&lt;br /&gt;// create a new customer&lt;br /&gt;int newCustNo = custDAO.insertCustomer(...);&lt;br /&gt;&lt;br /&gt;// Find a customer object. Get the Transfer Object.&lt;br /&gt;Customer cust = custDAO.findCustomer(...);&lt;br /&gt;&lt;br /&gt;// modify the values in the Transfer Object.&lt;br /&gt;cust.setAddress(...);&lt;br /&gt;cust.setEmail(...);&lt;br /&gt;// update the customer object using the DAO&lt;br /&gt;custDAO.updateCustomer(cust);&lt;br /&gt;&lt;br /&gt;// delete a customer object&lt;br /&gt;custDAO.deleteCustomer(...);&lt;br /&gt;// select all customers in the same city &lt;br /&gt;Customer criteria=new Customer();&lt;br /&gt;criteria.setCity("New York");&lt;br /&gt;Collection customersList = &lt;br /&gt;  custDAO.selectCustomersTO(criteria);&lt;br /&gt;// returns customersList - collection of Customer&lt;br /&gt;// Transfer Objects. iterate through this collection to&lt;br /&gt;// get values.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-171755029343983048?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/171755029343983048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=171755029343983048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/171755029343983048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/171755029343983048'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/07/core-j2ee-patterns-data-access-object.html' title='Core J2EE Patterns - Data Access Object'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_h8w_fktOw40/SIXdAE-VonI/AAAAAAAAABY/kjp5lAMHWA0/s72-c/figure09_01.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-4132300096452964579</id><published>2008-07-17T23:14:00.000-07:00</published><updated>2008-07-17T23:15:34.097-07:00</updated><title type='text'>Useful SQL Queries</title><content type='html'>Create USER in mysql:&lt;br /&gt;&lt;br /&gt;mysql&gt; CREATE USER 'exampledb'@'localhost' IDENTIFIED BY 'password';&lt;br /&gt;Query OK, 0 rows affected (0.05 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; select User,Host from mysql.user;&lt;br /&gt;+-----------+-----------+&lt;br /&gt;| User      | Host      |&lt;br /&gt;+-----------+-----------+&lt;br /&gt;| exampledb  | localhost |&lt;br /&gt;| exampledb2 | localhost |&lt;br /&gt;+-----------+-----------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;Assigning Privileges:&lt;br /&gt;&lt;br /&gt;mysql&gt; GRANT CREATE,SELECT,INSERT,UPDATE,DELETE,DROP ON snappsapi.* TO 'exampledb'@'localhost';&lt;br /&gt;Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;&lt;br /&gt;To show the users in a MySQL database, first login as an administrative user, then run this query:&lt;br /&gt;&lt;br /&gt;SELECT * from mysql.user;&lt;br /&gt;&lt;br /&gt;Drop User in mysql:&lt;br /&gt;&lt;br /&gt;mysql&gt; drop user exampledb@localhost;&lt;br /&gt;Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;&lt;br /&gt;To know Privileges in myslq&lt;br /&gt;&lt;br /&gt;mysql&gt; show grants;&lt;br /&gt;+-------------------------------------------------------------+&lt;br /&gt;| Grants for root@%                                           |&lt;br /&gt;+-------------------------------------------------------------+&lt;br /&gt;| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |&lt;br /&gt;+-------------------------------------------------------------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;C:\Program Files\MySQL\MySQL Server 5.0\bin&gt;mysql -uUSERNAME -pPASSWORD &lt;c:/exampledb.sql&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-4132300096452964579?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/4132300096452964579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=4132300096452964579' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4132300096452964579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4132300096452964579'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/07/useful-sql-queries.html' title='Useful SQL Queries'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-3851989315527078785</id><published>2008-07-06T22:15:00.000-07:00</published><updated>2009-06-13T05:40:01.050-07:00</updated><title type='text'>AJAX Introduction</title><content type='html'>&lt;span style="font-weight:bold;"&gt;AJAX = Asynchronous JavaScript and XML&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;AJAX is not a new programming language, but a technique for creating better, faster, and more interactive web applications.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With AJAX, your JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, your JavaScript can trade data with a web server, without reloading the page.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;The AJAX technique makes Internet applications smaller, faster and more user-friendly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  AJAX is a browser technology independent of web server software. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AJAX is Based on Web Standards&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;AJAX is based on the following web standards:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;JavaScript &lt;br /&gt;&lt;br /&gt;XML &lt;br /&gt;&lt;br /&gt;HTML &lt;br /&gt;&lt;br /&gt;CSS &lt;br /&gt;&lt;br /&gt;The web standards used in AJAX are well defined, and supported by all major browsers. AJAX applications are browser and platform independent.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;AJAX is About Better Internet Applications&lt;br /&gt;&lt;br /&gt;Web applications have many benefits over desktop applications; they can reach a larger audience, they are easier to install and support, and easier to develop.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, Internet applications are not always as "rich" and user-friendly as traditional desktop applications. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With AJAX, Internet applications can be made richer and more user-friendly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AJAX Uses HTTP Requests&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In traditional JavaScript coding, if you want to get any information from a database or a file on the server, or send user information to a server, you will have to make an HTML form and GET or POST data to the server. The user will have to click the "Submit" button to send/get the information, wait for the server to respond, then a new page will load with the results.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Because the server returns a new page each time the user submits input, traditional web applications can run slowly and tend to be less user-friendly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With AJAX, your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With an HTTP request, a web page can make a request to, and get a response from a web server - without reloading the page. The user will stay on the same page, and he or she will not notice that scripts request pages, or send data to a server in the background.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The XMLHttpRequest Object&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By using the XMLHttpRequest object, a web developer can update a page with data from the server after the page has loaded!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;AJAX was made popular in 2005 by Google (with Google Suggest).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Google Suggest is using the XMLHttpRequest object to create a very dynamic web interface: When you start typing in Google's search box, a JavaScript sends the letters off to a server and the server returns a list of suggestions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The XMLHttpRequest object is supported in Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0 / Firefox, Opera 8+, and Netscape 7.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Your First AJAX Application&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To understand how AJAX works, we will create a small AJAX application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, we are going to create a standard HTML form with two text fields: username and time. The username field will be filled in by the user and the time field will be filled in using AJAX.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The HTML file will be named "testAjax.htm", and it looks like this (notice that the HTML form below has no submit button!):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;html&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;form name="myForm"&gt;&lt;br /&gt;&lt;br /&gt;Name: &lt;input type="text" name="username" /&gt;&lt;br /&gt;&lt;br /&gt;Time: &lt;input type="text" name="time" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/form&gt;&lt;/body&gt;&lt;br /&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AJAX - Browser Support&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The keystone of AJAX is the XMLHttpRequest object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Different browsers use different methods to create the XMLHttpRequest object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Internet Explorer uses an ActiveXObject, while other browsers uses the built-in JavaScript object called XMLHttpRequest.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To create this object, and deal with different browsers, we are going to use a "try and catch" statement. You can read more about the try and catch statement in our JavaScript tutorial.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Let's update our "testAjax.htm" file with the JavaScript that creates the XMLHttpRequest object:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;html&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;script type="text/javascript"&gt;function ajaxFunction()&lt;br /&gt;&lt;br /&gt;{var xmlHttp;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;&lt;br /&gt;  {  // Firefox, Opera 8.0+, Safari  xmlHttp=new XMLHttpRequest();  }&lt;br /&gt;&lt;br /&gt;catch (e)&lt;br /&gt;&lt;br /&gt;  {  // Internet Explorer  try&lt;br /&gt;&lt;br /&gt;    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }&lt;br /&gt;&lt;br /&gt;  catch (e)&lt;br /&gt;&lt;br /&gt;    {    try&lt;br /&gt;&lt;br /&gt;      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }&lt;br /&gt;&lt;br /&gt;    catch (e)&lt;br /&gt;&lt;br /&gt;      {      alert("Your browser does not support AJAX!");      return false;      }    }  }  }&lt;/script&gt;&lt;form name="myForm"&gt;&lt;br /&gt;&lt;br /&gt;Name: &lt;input type="text" name="username" /&gt;&lt;br /&gt;&lt;br /&gt;Time: &lt;input type="text" name="time" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/form&gt;&lt;/body&gt;&lt;br /&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example explained: First create a variable xmlHttp to hold the XMLHttpRequest object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Then try to create the object with XMLHttp=new XMLHttpRequest(). This is for the Firefox, Opera, and Safari browsers. If that fails, try xmlHttp=new ActiveXObject("Msxml2.XMLHTTP") which is for Internet Explorer 6.0+, if that also fails, try xmlHttp=new ActiveXObject("Microsoft.XMLHTTP") which is for Internet Explorer 5.5+&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If none of the three methods work, the user has a very outdated browser, and he or she will get an alert stating that the browser doesn't support AJAX.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note: The browser-specific code above is long and quite complex. However, this is the code you can use every time you need to create an XMLHttpRequest object, so you can just copy and paste it whenever you need it. The code above is compatible with all the popular browsers: Internet Explorer, Opera, Firefox, and Safari.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The next chapter shows how to use the XMLHttpRequest object to communicate with the server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AJAX - More About the XMLHttpRequest Object&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Before sending data to the server, we have to explain three important properties of the XMLHttpRequest object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The onreadystatechange Property&lt;br /&gt;&lt;br /&gt;After a request to the server, we need a function that can receive the data that is returned by the server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The onreadystatechange property stores the function that will process the response from a server. The following code defines an empty function and sets the onreadystatechange property at the same time:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The readyState Property&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The readyState property holds the status of the server's response. Each time the readyState changes, the onreadystatechange function will be executed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here are the possible values for the readyState property:&lt;br /&gt;&lt;br /&gt;State      Description &lt;br /&gt;&lt;br /&gt; 0     The request is not initialized &lt;br /&gt;&lt;br /&gt; 1     The request has been set up &lt;br /&gt;&lt;br /&gt; 2     The request has been sent &lt;br /&gt;&lt;br /&gt; 3     The request is in process &lt;br /&gt;&lt;br /&gt; 4     The request is complete &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We are going to add an If statement to the onreadystatechange function to test if our response is complete (this means that we can get our data):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xmlHttp.onreadystatechange=function()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if(xmlHttp.readyState==4)&lt;br /&gt;&lt;br /&gt;  {&lt;br /&gt;&lt;br /&gt;  // Get the data from the server's response&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The responseText Property&lt;br /&gt;&lt;br /&gt;The data sent back from the server can be retrieved with the responseText property.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In our code, we will set the value of our "time" input field equal to responseText:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xmlHttp.onreadystatechange=function()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if(xmlHttp.readyState==4)&lt;br /&gt;&lt;br /&gt;  {&lt;br /&gt;&lt;br /&gt;  document.myForm.time.value=xmlHttp.responseText;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;AJAX - Sending a Request to the Server&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To send off a request to the server, we use the open() method and the send() method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The open() method takes three arguments. The first argument defines which method to use when sending the request (GET or POST). The second argument specifies the URL of the server-side script. The third argument specifies that the request should be handled asynchronously. The send() method sends the request off to the server. If we assume that the HTML and ASP file are in the same directory, the code would be: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;xmlHttp.open("GET","time.asp",true);&lt;br /&gt;&lt;br /&gt;xmlHttp.send(null); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now we must decide when the AJAX function should be executed. We will let the function run "behind the scenes" when the user types something in the username text field:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;form name="myForm"&gt;&lt;br /&gt;&lt;br /&gt;Name: &lt;input type="text"&lt;br /&gt;&lt;br /&gt;onkeyup="ajaxFunction();" name="username" /&gt;&lt;br /&gt;&lt;br /&gt;Time: &lt;input type="text" name="time" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/form&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Our updated AJAX-ready "testAjax.htm" file now looks like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;html&gt;&lt;body&gt;&lt;script type="text/javascript"&gt;function ajaxFunction()&lt;br /&gt;&lt;br /&gt;{var xmlHttp;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;&lt;br /&gt;  {  // Firefox, Opera 8.0+, Safari  xmlHttp=new XMLHttpRequest();  }&lt;br /&gt;&lt;br /&gt;catch (e)&lt;br /&gt;&lt;br /&gt;  {  // Internet Explorer  try&lt;br /&gt;&lt;br /&gt;    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }&lt;br /&gt;&lt;br /&gt;  catch (e)&lt;br /&gt;&lt;br /&gt;    {    try&lt;br /&gt;&lt;br /&gt;      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }&lt;br /&gt;&lt;br /&gt;    catch (e)&lt;br /&gt;&lt;br /&gt;      {      alert("Your browser does not support AJAX!");      return false;      }    }  }&lt;br /&gt;&lt;br /&gt;  xmlHttp.onreadystatechange=function()&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    if(xmlHttp.readyState==4)&lt;br /&gt;&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;      document.myForm.time.value=xmlHttp.responseText;&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;  xmlHttp.open("GET","time.asp",true);&lt;br /&gt;&lt;br /&gt;  xmlHttp.send(null);  }&lt;/script&gt;&lt;form name="myForm"&gt;&lt;br /&gt;&lt;br /&gt;Name: &lt;input type="text"&lt;br /&gt;&lt;br /&gt;onkeyup="ajaxFunction();" name="username" /&gt;&lt;br /&gt;&lt;br /&gt;Time: &lt;input type="text" name="time" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/form&gt;&lt;/body&gt;&lt;br /&gt;&lt;br /&gt;&lt;/html&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;&lt;br /&gt;AJAX - The Server-Side ASP Script&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we are going to create the script that displays the current server time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The responseText property (explained in the previous chapter) will store the data returned from the server. Here we want to send back the current time. The code in "time.asp" looks like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;%&lt;br /&gt;&lt;br /&gt;response.expires=-1&lt;br /&gt;&lt;br /&gt;response.write(time)&lt;br /&gt;&lt;br /&gt;%&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note&lt;/span&gt;: The Expires property sets how long (in minutes) a page will be cached on a browser before it expires. If a user returns to the same page before it expires, the cached version is displayed. Response.Expires=-1 indicates that the page will never be cached.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-3851989315527078785?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/3851989315527078785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=3851989315527078785' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3851989315527078785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3851989315527078785'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/07/ajax-introduction.html' title='AJAX Introduction'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-2663233151130993229</id><published>2008-01-21T22:38:00.000-08:00</published><updated>2009-06-13T05:40:01.050-07:00</updated><title type='text'>MySQL - LEFT JOIN and RIGHT JOIN, INNER JOIN and OUTER JOIN</title><content type='html'>First, some sample data:&lt;br /&gt;Mr Brown, Person number 1, has a phone number 01225 708225&lt;br /&gt;Miss Smith, Person number 2, has a phone number 01225 899360&lt;br /&gt;Mr Pullen, Person number 3, has a phone number 01380 724040&lt;br /&gt;and also:&lt;br /&gt;Person number 1 is selling property number 1 - Old House Farm&lt;br /&gt;Person number 3 is selling property number 2 - The Willows&lt;br /&gt;Person number 3 is (also) selling property number 3 - Tall Trees&lt;br /&gt;Person number 3 is (also) selling property number 4 - The Melksham Florist&lt;br /&gt;Person number 4 is selling property number 5 - Dun Roamin.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; select * from demo_people;&lt;br /&gt;+------------+--------------+------+&lt;br /&gt;| name       | phone        | pid  |&lt;br /&gt;+------------+--------------+------+&lt;br /&gt;| Mr Brown   | 01225 708225 |    1 |&lt;br /&gt;| Miss Smith | 01225 899360 |    2 |&lt;br /&gt;| Mr Pullen  | 01380 724040 |    3 |&lt;br /&gt;+------------+--------------+------+&lt;br /&gt;3 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; select * from demo_property;&lt;br /&gt;+------+------+----------------------+&lt;br /&gt;| pid  | spid | selling              |&lt;br /&gt;+------+------+----------------------+&lt;br /&gt;|    1 |    1 | Old House Farm       |&lt;br /&gt;|    3 |    2 | The Willows          |&lt;br /&gt;|    3 |    3 | Tall Trees           |&lt;br /&gt;|    3 |    4 | The Melksham Florist |&lt;br /&gt;|    4 |    5 | Dun Roamin           |&lt;br /&gt;+------+------+----------------------+&lt;br /&gt;5 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If I do a regular JOIN (with none of the keywords INNER, OUTER, LEFT or RIGHT), then I get all records that match in the appropriate way in the two tables, and records in both incoming tables that do not match are not reported:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; select name, phone, selling &lt;br /&gt;from demo_people join demo_property &lt;br /&gt;on demo_people.pid = demo_property.pid;&lt;br /&gt;+-----------+--------------+----------------------+&lt;br /&gt;| name      | phone        | selling              |&lt;br /&gt;+-----------+--------------+----------------------+&lt;br /&gt;| Mr Brown  | 01225 708225 | Old House Farm       |&lt;br /&gt;| Mr Pullen | 01380 724040 | The Willows          |&lt;br /&gt;| Mr Pullen | 01380 724040 | Tall Trees           |&lt;br /&gt;| Mr Pullen | 01380 724040 | The Melksham Florist |&lt;br /&gt;+-----------+--------------+----------------------+&lt;br /&gt;4 rows in set (0.01 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If I do a LEFT JOIN, I get all records that match in the same way and IN ADDITION I get an extra record for each unmatched record in the left table of the join - thus ensuring (in my example) that every PERSON gets a mention:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; select name, phone, selling &lt;br /&gt;from demo_people left join demo_property &lt;br /&gt;on demo_people.pid = demo_property.pid; &lt;br /&gt;+------------+--------------+----------------------+&lt;br /&gt;| name       | phone        | selling              |&lt;br /&gt;+------------+--------------+----------------------+&lt;br /&gt;| Mr Brown   | 01225 708225 | Old House Farm       |&lt;br /&gt;| Miss Smith | 01225 899360 | NULL                 |&lt;br /&gt;| Mr Pullen  | 01380 724040 | The Willows          |&lt;br /&gt;| Mr Pullen  | 01380 724040 | Tall Trees           |&lt;br /&gt;| Mr Pullen  | 01380 724040 | The Melksham Florist |&lt;br /&gt;+------------+--------------+----------------------+&lt;br /&gt;5 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If I do a RIGHT JOIN, I get all the records that match and IN ADDITION I get an extra record for each unmatched record in the right table of the join - im my example, that means that each property gets a mention even if we don't have seller details:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; select name, phone, selling &lt;br /&gt;from demo_people right join demo_property &lt;br /&gt;on demo_people.pid = demo_property.pid;&lt;br /&gt;+-----------+--------------+----------------------+&lt;br /&gt;| name      | phone        | selling              |&lt;br /&gt;+-----------+--------------+----------------------+&lt;br /&gt;| Mr Brown  | 01225 708225 | Old House Farm       |&lt;br /&gt;| Mr Pullen | 01380 724040 | The Willows          |&lt;br /&gt;| Mr Pullen | 01380 724040 | Tall Trees           |&lt;br /&gt;| Mr Pullen | 01380 724040 | The Melksham Florist |&lt;br /&gt;| NULL      | NULL         | Dun Roamin           |&lt;br /&gt;+-----------+--------------+----------------------+&lt;br /&gt;5 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;An INNER JOIN does a full join, just like the first example, and the word OUTER may be added after the word LEFT or RIGHT in the last two examples - it's provided for ODBC compatability and doesn't add an extra capabilities.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-2663233151130993229?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/2663233151130993229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=2663233151130993229' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2663233151130993229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2663233151130993229'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/01/mysql-left-join-and-right-join-inner.html' title='MySQL - LEFT JOIN and RIGHT JOIN, INNER JOIN and OUTER JOIN'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-6946240676176860494</id><published>2008-01-01T21:00:00.000-08:00</published><updated>2009-06-13T05:40:01.050-07:00</updated><title type='text'>Java API for XML Processing</title><content type='html'>The Java API for XML Processing (JAXP) is for processing XML data using applications written in the Java programming language. JAXP leverages the parser standards Simple API for XML Parsing (SAX) and Document Object Model (DOM) so that you can choose to parse your data as a stream of events or to build an object representation of it. JAXP also supports the Extensible Stylesheet Language Transformations (XSLT) standard, giving you control over the presentation of the data and enabling you to convert the data to other XML documents or to other formats, such as HTML. JAXP also provides namespace support, allowing you to work with DTDs that might otherwise have naming conflicts. &lt;br /&gt;&lt;br /&gt;Designed to be flexible, JAXP allows you to use any XML-compliant parser from within your application. It does this with what is called a pluggability layer, which lets you plug in an implementation of the SAX or DOM API. The pluggability layer also allows you to plug in an XSL processor, letting you control how your XML data is displayed. &lt;br /&gt;&lt;br /&gt;The basic outline of the SAX parsing APIs are shown in Figure 4-1. To start the process, an instance of the SAXParserFactory class is used to generate an instance of the parser. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The main JAXP APIs are defined in the javax.xml.parsers package. That package contains vendor-neutral factory classes--SAXParserFactory, DocumentBuilderFactory, and TransformerFactory--which give you a SAXParser, a DocumentBuilder, and an XSLT transformer, respectively. DocumentBuilder, in turn, creates a DOM-compliant Document object. &lt;br /&gt;&lt;br /&gt;The factory APIs let you plug in an XML implementation offered by another vendor without changing your source code. The implementation you get depends on the setting of the javax.xml.parsers.SAXParserFactory, javax.xml.parsers.DocumentBuilderFactory, and javax.xml.transform.TransformerFactory system properties, using System.setProperties() in the code, &lt;sysproperty key="..." value="..."/&gt; in an Ant build script, or -DpropertyName="..." on the command line. The default values (unless overridden at runtime on the command line or in the code) point to Sun's implementation. &lt;br /&gt;&lt;br /&gt;The SAX and DOM APIs are defined by the XML-DEV group and by the W3C, respectively. The libraries that define those APIs are as follows: &lt;br /&gt;&lt;br /&gt;javax.xml.parsers: The JAXP APIs, which provide a common interface for different vendors' SAX and DOM parsers&lt;br /&gt;org.w3c.dom: Defines the Document class (a DOM) as well as classes for all the components of a DOM&lt;br /&gt;org.xml.sax: Defines the basic SAX APIs&lt;br /&gt;javax.xml.transform: Defines the XSLT APIs that let you transform XML into other forms&lt;br /&gt;The Simple API for XML (SAX) is the event-driven, serial-access mechanism that does element-by-element processing. The API for this level reads and writes XML to a data repository or the web. For server-side and high-performance applications, you will want to fully understand this level. But for many applications, a minimal understanding will suffice. &lt;br /&gt;&lt;br /&gt;The DOM API is generally an easier API to use. It provides a familiar tree structure of objects. You can use the DOM API to manipulate the hierarchy of application objects it encapsulates. The DOM API is ideal for interactive applications because the entire object model is present in memory, where it can be accessed and manipulated by the user. &lt;br /&gt;&lt;br /&gt;On the other hand, constructing the DOM requires reading the entire XML structure and holding the object tree in memory, so it is much more CPU- and memory-intensive. For that reason, the SAX API tends to be preferred for server-side applications and data filters that do not require an in-memory representation of the data. &lt;br /&gt;&lt;br /&gt;Finally, the XSLT APIs defined in javax.xml.transform let you write XML data to a file or convert it into other forms. And, as you'll see in the XSLT section of this tutorial, you can even use it in conjunction with the SAX APIs to convert legacy data to XML. &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_h8w_fktOw40/R3scj3QMhkI/AAAAAAAAAAw/GQjK5enjJE4/s1600-h/jaxpintro-saxApi.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_h8w_fktOw40/R3scj3QMhkI/AAAAAAAAAAw/GQjK5enjJE4/s200/jaxpintro-saxApi.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5150742001281173058" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The parser wraps a SAXReader object. When the parser's parse() method is invoked, the reader invokes one of several callback methods implemented in the application. Those methods are defined by the interfaces ContentHandler, ErrorHandler, DTDHandler, and EntityResolver. &lt;br /&gt;&lt;br /&gt;Here is a summary of the key SAX APIs: &lt;br /&gt;&lt;br /&gt;SAXParserFactory &lt;br /&gt;&lt;br /&gt;A SAXParserFactory object creates an instance of the parser determined by the system property, javax.xml.parsers.SAXParserFactory. &lt;br /&gt;&lt;br /&gt;SAXParser &lt;br /&gt;&lt;br /&gt;The SAXParser interface defines several kinds of parse() methods. In general, you pass an XML data source and a DefaultHandler object to the parser, which processes the XML and invokes the appropriate methods in the handler object. &lt;br /&gt;&lt;br /&gt;SAXReader &lt;br /&gt;&lt;br /&gt;The SAXParser wraps a SAXReader. Typically, you don't care about that, but every once in a while you need to get hold of it using SAXParser's getXMLReader() so that you can configure it. It is the SAXReader that carries on the conversation with the SAX event handlers you define. &lt;br /&gt;&lt;br /&gt;DefaultHandler &lt;br /&gt;&lt;br /&gt;Not shown in the diagram, a DefaultHandler implements the ContentHandler, ErrorHandler, DTDHandler, and EntityResolver interfaces (with null methods), so you can override only the ones you're interested in. &lt;br /&gt;&lt;br /&gt;ContentHandler &lt;br /&gt;&lt;br /&gt;Methods such as startDocument, endDocument, startElement, and endElement are invoked when an XML tag is recognized. This interface also defines the methods characters and processingInstruction, which are invoked when the parser encounters the text in an XML element or an inline processing instruction, respectively. &lt;br /&gt;&lt;br /&gt;ErrorHandler &lt;br /&gt;&lt;br /&gt;Methods error, fatalError, and warning are invoked in response to various parsing errors. The default error handler throws an exception for fatal errors and ignores other errors (including validation errors). That's one reason you need to know something about the SAX parser, even if you are using the DOM. Sometimes, the application may be able to recover from a validation error. Other times, it may need to generate an exception. To ensure the correct handling, you'll need to supply your own error handler to the parser. &lt;br /&gt;&lt;br /&gt;DTDHandler &lt;br /&gt;&lt;br /&gt;Defines methods you will generally never be called upon to use. Used when processing a DTD to recognize and act on declarations for an unparsed entity. &lt;br /&gt;&lt;br /&gt;EntityResolver &lt;br /&gt;&lt;br /&gt;The resolveEntity method is invoked when the parser must identify data identified by a URI. In most cases, a URI is simply a URL, which specifies the location of a document, but in some cases the document may be identified by a URN--a public identifier, or name, that is unique in the web space. The public identifier may be specified in addition to the URL. The EntityResolver can then use the public identifier instead of the URL to find the document--for example, to access a local copy of the document if one exists. &lt;br /&gt;&lt;br /&gt;A typical application implements most of the ContentHandler methods, at a minimum. Because the default implementations of the interfaces ignore all inputs except for fatal errors, a robust implementation may also want to implement the ErrorHandler methods. &lt;br /&gt;&lt;br /&gt;The SAX Packages &lt;br /&gt;The SAX parser is defined in the packages listed in Table 4-1.&lt;br /&gt;&lt;br /&gt;Table 4-1 SAX Packages  Package  Description  &lt;br /&gt;org.xml.sax  Defines the SAX interfaces. The name org.xml is the package prefix that was settled on by the group that defined the SAX API.  &lt;br /&gt;org.xml.sax.ext  Defines SAX extensions that are used for doing more sophisticated SAX processing--for example, to process a document type definition (DTD) or to see the detailed syntax for a file.  &lt;br /&gt;org.xml.sax.helpers  Contains helper classes that make it easier to use SAX--for example, by defining a default handler that has null methods for all the interfaces, so that you only need to override the ones you actually want to implement.  &lt;br /&gt;javax.xml.parsers  Defines the SAXParserFactory class, which returns the SAXParser. Also defines exception classes for reporting errors.  &lt;br /&gt;&lt;br /&gt;The Document Object Model APIs &lt;br /&gt;Figure 4-2 shows the DOM APIs in action. &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_h8w_fktOw40/R3sdCHQMhlI/AAAAAAAAAA4/eiYShPSxdiE/s1600-h/jaxpintro-domApi.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_h8w_fktOw40/R3sdCHQMhlI/AAAAAAAAAA4/eiYShPSxdiE/s200/jaxpintro-domApi.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5150742520972215890" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You use the javax.xml.parsers.DocumentBuilderFactory class to get a DocumentBuilder instance, and you use that instance to produce a Document object that conforms to the DOM specification. The builder you get, in fact, is determined by the system property javax.xml.parsers.DocumentBuilderFactory, which selects the factory implementation that is used to produce the builder. (The platform's default value can be overridden from the command line.) &lt;br /&gt;&lt;br /&gt;You can also use the DocumentBuilder newDocument() method to create an empty Document that implements the org.w3c.dom.Document interface. Alternatively, you can use one of the builder's parse methods to create a Document from existing XML data. The result is a DOM tree like that shown in Figure 4-2. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Note: Although they are called objects, the entries in the DOM tree are actually fairly low-level data structures. For example, consider this structure: &lt;color&gt;blue&lt;/color&gt;. There is an element node for the color tag, and under that there is a text node that contains the data, blue! This issue will be explored at length in the DOM section of the tutorial, but developers who are expecting objects are usually surprised to find that invoking getNodeValue() on the element node returns nothing! For a truly object-oriented tree, see the JDOM API at http://www.jdom.org. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;The DOM Packages &lt;br /&gt;The Document Object Model implementation is defined in the packages listed in Table 4-2.&lt;br /&gt;&lt;br /&gt;Table 4-2 DOM Packages  Package  Description  &lt;br /&gt;org.w3c.dom  Defines the DOM programming interfaces for XML (and, optionally, HTML) documents, as specified by the W3C.  &lt;br /&gt;javax.xml.parsers  Defines the DocumentBuilderFactory class and the DocumentBuilder class, which returns an object that implements the W3C Document interface. The factory that is used to create the builder is determined by the javax.xml.parsers system property, which can be set from the command line or overridden when invoking the new Instance method. This package also defines the ParserConfigurationException class for reporting errors. &lt;br /&gt;&lt;br /&gt;The Extensible Stylesheet Language Transformations APIs &lt;br /&gt;Figure 4-3 shows the XSLT APIs in action. &lt;br /&gt;&lt;br /&gt;A TransformerFactory object is instantiated and used to create a Transformer. The source object is the input to the transformation process. A source object can be created from a SAX reader, from a DOM, or from an input stream. &lt;br /&gt;&lt;br /&gt;Similarly, the result object is the result of the transformation process. That object can be a SAX event handler, a DOM, or an output stream. &lt;br /&gt;&lt;br /&gt;When the transformer is created, it can be created from a set of transformation instructions, in which case the specified transformations are carried out. If it is created without any specific instructions, then the transformer object simply copies the source to the result. &lt;br /&gt;&lt;br /&gt;The XSLT Packages &lt;br /&gt;The XSLT APIs are defined in the packages shown in Table 4-3.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_h8w_fktOw40/R3sdWHQMhmI/AAAAAAAAABA/Jjo1pW-u5XI/s1600-h/jaxpintro-xsltApi.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_h8w_fktOw40/R3sdWHQMhmI/AAAAAAAAABA/Jjo1pW-u5XI/s200/jaxpintro-xsltApi.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5150742864569599586" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Table 4-3 XSLT Packages  Package  Description  &lt;br /&gt;javax.xml.transform  Defines the TransformerFactory and Transformer classes, which you use to get an object capable of doing transformations. After creating a transformer object, you invoke its transform() method, providing it with an input (source) and output (result).  &lt;br /&gt;javax.xml.transform.dom  Classes to create input (source) and output (result) objects from a DOM.  &lt;br /&gt;javax.xml.transform.sax  Classes to create input (source) objects from a SAX parser and output (result) objects from a SAX event handler.  &lt;br /&gt;javax.xml.transform.stream  Classes to create input (source) objects and output (result) objects from an I/O stream.  &lt;br /&gt;&lt;br /&gt;Simple API for XML (&lt;span style="font-weight:bold;"&gt;SAX&lt;/span&gt;), an event-driven, serial-access mechanism for accessing XML documents. This protocol is frequently used by servlets and network-oriented programs that need to transmit and receive XML documents, because it's the fastest and least memory-intensive mechanism that is currently available for dealing with XML documents, other than StAX. &lt;br /&gt;&lt;br /&gt;SAX is an event-driven model (you provide the callback methods, and the parser invokes them as it reads the XML data), and that makes it harder to visualize. Finally, you can't "back up" to an earlier part of the document, or rearrange it, any more than you can back up a serial data stream or rearrange characters you have read from that stream. &lt;br /&gt;&lt;br /&gt;For those reasons, developers who are writing a user-oriented application that displays an XML document and possibly modifies it will want to use the DOM mechanism &lt;br /&gt;&lt;br /&gt;even if you plan to build DOM applications exclusively, there are several important reasons for familiarizing yourself with the SAX model: &lt;br /&gt;&lt;br /&gt;Same Error Handling: The same kinds of exceptions are generated by the SAX and DOM APIs, so the error handling code is virtually identical.&lt;br /&gt;Handling Validation Errors: By default, the specifications require that validation errors (which you'll learn more about in this part of the tutorial) are ignored. If you want to throw an exception in the event of a validation error (and you probably do), then you need to understand how SAX error handling works.&lt;br /&gt;Converting Existing Data: There is a mechanism we can use to convert an existing data set to XML. However, taking advantage of that mechanism requires an understanding of the SAX model.&lt;br /&gt;&lt;br /&gt;SAX is fast and efficient, but its event model makes it most useful for such state-independent filtering. For example, a SAX parser calls one method in your application when an element tag is encountered and calls a different method when text is found. If the processing you're doing is state-independent (meaning that it does not depend on the elements have come before), then SAX works fine. &lt;br /&gt;&lt;br /&gt;On the other hand, for state-dependent processing, where the program needs to do one thing with the data under element A but something different with the data under element B, then a pull parser such as the Streaming API for XML (StAX) would be a better choice. With a pull parser, you get the next node, whatever it happens to be, at any point in the code that you ask for it. So it's easy to vary the way you process text (for example), because you can process it multiple places in the program.&lt;br /&gt;&lt;br /&gt;SAX requires much less memory than DOM, because SAX does not construct an internal representation (tree structure) of the XML data, as a DOM does. Instead, SAX simply sends data to the application as it is read; your application can then do whatever it wants to do with the data it sees. &lt;br /&gt;&lt;br /&gt;Pull parsers and the SAX API both act like a serial I/O stream. You see the data as it streams in, but you can't go back to an earlier position or leap ahead to a different position. In general, such parsers work well when you simply want to read data and have the application act on it.&lt;br /&gt;But when you need to modify an XML structure--especially when you need to modify it interactively--an in-memory structure makes more sense. DOM is one such model.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-6946240676176860494?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/6946240676176860494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=6946240676176860494' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6946240676176860494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6946240676176860494'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2008/01/java-api-for-xml-processing.html' title='Java API for XML Processing'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_h8w_fktOw40/R3scj3QMhkI/AAAAAAAAAAw/GQjK5enjJE4/s72-c/jaxpintro-saxApi.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-6567477942125778217</id><published>2007-12-21T01:07:00.000-08:00</published><updated>2009-06-13T05:40:01.050-07:00</updated><title type='text'>How to load balance Tomcat 5.5 with Apache on Windows</title><content type='html'>How to load balance Tomcat 5.5 with Apache on Windows &lt;br /&gt;It's rather amazing that I could not find a single how-to that could detail the steps for using the Apache web server to load balance multiple Tomcat 5.5 instances on Windows. I found tons of articles- but they were either for older versions of Tomcat or Apache or for Unix flavors and none were accurate enough. Apache itself has fragmented documentation on the subject, and after much trial and error and pulling of hair, I succeeded.&lt;br /&gt;&lt;br /&gt;The least I can do is list the steps here for all others who have had trouble getting it right.&lt;br /&gt;The goal of this blog is to set up two Tomcat 5.5 instances with Apache in front, load balancing them. Please note that this does not cover clustering. I'll save that for another blog once I actually do it :-)&lt;br /&gt;Also, this is not a tutorial on load balancing. It will get you up and running- then you might want to look at the Tomcat documentation to find out what exactly all those options do.&lt;br /&gt;&lt;br /&gt;So, this is what you need to download:&lt;br /&gt;1. Apache HTTP server 2.2.4 from The Apache HTTP Server Project. I prefer the zip over the Windows Installer. You are free to choose the Windows Installer if you wish, but modify the service instructions below accordingly.&lt;br /&gt;&lt;br /&gt;2. Apache Tomcat 5.5.20 from Apache Tomcat downloads&lt;br /&gt;&lt;br /&gt;3. Mod JK Tomcat connector from here. Please note: You want to download the binary- click on JK 1.2 Binary Releases --&gt; win32 --&gt; jk-1.2.21 --&gt; mod_jk-apache-2.2.4.so&lt;br /&gt;&lt;br /&gt;Now let's start by installing Tomcat first.&lt;br /&gt;&lt;br /&gt;1. Extract the Tomcat zip. Hereafter, the directory you extracted to will be referred to as TOMCAT_HOME&lt;br /&gt;&lt;br /&gt;2. Test Tomcat to see that it works. Go to TOMCAT_HOME\bin and run startup.bat&lt;br /&gt;You may need to add an environment variable called CATALINA_HOME which is set to TOMCAT_HOME in case Tomcat fails to start.&lt;br /&gt;&lt;br /&gt;3. Open up your browser and access http://localhost:8080/&lt;br /&gt;If you see the default page, then Tomcat Instance 1 is working fine. Shut down Tomcat.&lt;br /&gt;&lt;br /&gt;4. Now set this up as a service. Go to your command prompt, change directory to TOMCAT_HOME\bin and set an environment variable called CATALINA_BASE. The value of this variable should again, be TOMCAT_HOME. For example:&lt;br /&gt;&lt;br /&gt;SET CATALINA_BASE=C:\Tomcat-5.5.20&lt;br /&gt;&lt;br /&gt;Then, execute the following: service install Tomcat5&lt;br /&gt;This will set up the Windows service for Tomcat.&lt;br /&gt;&lt;br /&gt;5. Go to your Services and see that Tomcat 5 is listed. Start the service, and then verify again that http://localhost:8080 is up.&lt;br /&gt;That's all for the first Tomcat instance. Now for the second.&lt;br /&gt;&lt;br /&gt;1. Make a directory called SecondInstance in TOMCAT_HOME&lt;br /&gt;&lt;br /&gt;2. Copy the conf, logs, shared, temp, webapps and work directories from the TOMCAT_HOME directory into the SecondInstance directory.&lt;br /&gt;&lt;br /&gt;3. Open up SecondInstance\conf\server.xml in a text editor. We've got to change the port numbers so that they don't conflict with the first instance.&lt;br /&gt;I just incremented by 10 and changed them as follows, but you could use other port numbers:&lt;br /&gt;&lt;br /&gt;&lt;Server port="8005" shutdown="SHUTDOWN"&gt; to &lt;Server port="8015" shutdown="SHUTDOWN"&gt;&lt;br /&gt;&lt;br /&gt;Connector port="8080" maxHttpHeaderSize="8192"... to Connector port="8090" maxHttpHeaderSize="8192"...&lt;br /&gt;&lt;br /&gt;&lt;Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /&gt; to &lt;Connector port="8019" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /&gt;&lt;br /&gt;&lt;br /&gt;Change the SSL port if you need it as well.&lt;br /&gt;&lt;br /&gt;4. Now set up the second instance to run as a service. Go to the command prompt, change to the TOMCAT_HOME\bin directory. Set the CATALINA_BASE environment variable to TOMCAT_HOME\SecondInstance. For example:&lt;br /&gt;&lt;br /&gt;SET CATALINA_BASE=C:\Tomcat5.5.20\SecondInstance&lt;br /&gt;Then, type:&lt;br /&gt;service install SecondTomcat&lt;br /&gt;&lt;br /&gt;Go to Services and start the SecondTomcat service. Test it out by pointing your browser to http://localhost:8090/&lt;br /&gt;Works ok? Great! Your second tomcat instance is now ready to be used.&lt;br /&gt;&lt;br /&gt;Next, let's set up the Apache HTTP Server. It's pretty simple...&lt;br /&gt;&lt;br /&gt;1. Run the installer you downloaded. The standard install will do.&lt;br /&gt;&lt;br /&gt;2. Open the Apache Server Monitor and start the web server if it's not already running.&lt;br /&gt;&lt;br /&gt;3. Point your browser to http://localhost/ to verify that Apache is running on port 80.&lt;br /&gt;&lt;br /&gt;4. Stop Apache.&lt;br /&gt;&lt;br /&gt;Finally, we reach mod JK. Let's set it up first just to delegate requests to the two Tomcat instances, and we'll load balance it a bit later.&lt;br /&gt;&lt;br /&gt;1. Copy the mod_jk-apache-2.2.4.so to the modules directory in your Apache installation.&lt;br /&gt;&lt;br /&gt;2. Rename it to mod_jk.so&lt;br /&gt;&lt;br /&gt;3. Open up httpd.conf in the conf directory of your Apache installation in a text edit, and add the following line at the end of the set of LoadModule statements:&lt;br /&gt;LoadModule jk_module modules/mod_jk.so&lt;br /&gt;&lt;br /&gt;4. Create a file called workers.properies in the conf directory. Add these lines to it:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;workers.tomcat_home=C:/tomcat-5.5.20&lt;br /&gt;&lt;br /&gt;workers.java_home=C:/jdk1.5.0_03&lt;br /&gt;&lt;br /&gt;worker.list=worker1,worker2&lt;br /&gt;&lt;br /&gt;worker.worker1.port=8009&lt;br /&gt;worker.worker1.host=localhost&lt;br /&gt;worker.worker1.type=ajp13&lt;br /&gt;&lt;br /&gt;worker.worker2.port=8019&lt;br /&gt;worker.worker2.host=localhost&lt;br /&gt;worker.worker2.type=ajp13&lt;br /&gt;&lt;br /&gt;This file defines which workers Apache can delegate to. We've listed worker1 and worker 2 to correspond to our two tomcat instances. Remember to set tomcat_home and java_home as well.&lt;br /&gt;&lt;br /&gt;5. Specify the worker properties in httpd.conf:&lt;br /&gt;&lt;br /&gt;Add these lines just after the LoadModule definitions-&lt;br /&gt;&lt;br /&gt;# Path to workers.properties&lt;br /&gt;JkWorkersFile c:/apache2.2/conf/workers.properties&lt;br /&gt;&lt;br /&gt;# Path to jk logs&lt;br /&gt;JkLogFile c:/apache2.2/mod_jk.log&lt;br /&gt;&lt;br /&gt;# Jk log level [debug/error/info]&lt;br /&gt;JkLogLevel info&lt;br /&gt;&lt;br /&gt;# Jk log format&lt;br /&gt;JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "&lt;br /&gt;&lt;br /&gt;# JkOptions for forwarding&lt;br /&gt;JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories&lt;br /&gt;&lt;br /&gt;# JkRequestLogFormat set the request format&lt;br /&gt;JkRequestLogFormat "%w %V %T"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;JkMount /jsp-examples worker1&lt;br /&gt;JkMount /jsp-examples/* worker1&lt;br /&gt;&lt;br /&gt;JkMount /tomcat-docs worker2&lt;br /&gt;JkMount /tomcat-docs/* worker2&lt;br /&gt;&lt;br /&gt;Defining these tells Apache where to look for definitions of its workers and tells it that any requests for the jsp-examples context should be handed off to the Tomcat instance represented by worker 1, and any requests for tomcat-docs context should be handed off to Tomcat Instance 2, represented by worker 2.&lt;br /&gt;&lt;br /&gt;5.5 [Added on April 11 2007]&lt;br /&gt;Edit the server.xml for Tomcat and Tomcat's SecondInstance and add a jvmRoute attribute to the Engine element:&lt;br /&gt;&lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1"&gt;&lt;br /&gt;for the first instance and&lt;br /&gt;&lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="worker2"&gt;&lt;br /&gt;for the second.&lt;br /&gt;&lt;br /&gt;6. Start Tomcat Instance 1 and 2. Start up the Apache webserver. Point your browser to http://localhost/jsp-examples/ and then to http://localhost/tomcat-docs. You should see the respective pages load. To distinguish which Tomcat is serving you the page, the easiest thing to do is edit the index page in the tomcat-docs and jsp-examples of Tomcat 2 and change the title for example. Then you can verify that tomcat-docs is being served only by the second instance.&lt;br /&gt;&lt;br /&gt;Thats it!! Apache is now delegating requests to both Tomcats.&lt;br /&gt;Now for our last task- we will load balance it so that Apache distributes load for jsp-examples between both instances of Tomcat. It also serves as a failover mechanism. If Tomcat 1 is down for whatever reason, Apache will automatically keep delegating to Tomcat 2 so your application remains accessible.&lt;br /&gt;&lt;br /&gt;Load balancing is a simple configuration. First shut down your Tomcat instances and Apache as well.&lt;br /&gt;&lt;br /&gt;1. Open workers.properties in a text editor.&lt;br /&gt;&lt;br /&gt;2. Edit it so it looks like this (changed lines in bold)-&lt;br /&gt;&lt;br /&gt;workers.tomcat_home=C:/tomcat-5.5.20&lt;br /&gt;workers.java_home=C:/jdk1.5.0_03&lt;br /&gt;&lt;br /&gt;#worker.list=worker1,worker2&lt;br /&gt;worker.list=balancer&lt;br /&gt;&lt;br /&gt;worker.worker1.port=8009&lt;br /&gt;worker.worker1.host=localhost&lt;br /&gt;worker.worker1.type=ajp13&lt;br /&gt;worker.worker1.lbfactor=1&lt;br /&gt;&lt;br /&gt;worker.worker2.port=8019&lt;br /&gt;worker.worker2.host=localhost&lt;br /&gt;worker.worker2.type=ajp13&lt;br /&gt;worker.worker2.lbfactor=1&lt;br /&gt;&lt;br /&gt;worker.balancer.type=lb&lt;br /&gt;worker.balancer.balance_workers=worker1,worker2&lt;br /&gt;worker.balancer.method=B&lt;br /&gt;&lt;br /&gt;We've changed the worker list to a single worker called balancer, and specified that the worker type of balancer is 'lb' or load balancer. The workers it manages are worker1 and worker2 (these do not need to appear in the workers list). And finally, we set the balance method to 'B' or balance by busy factor. Apache will delegate the next request to the Tomcat instance which is least busy. Please note that there are a couple of options for method- consult the Apache/Tomcat documentation which lists out options for workers properties to help you decide the best method for your type of application.&lt;br /&gt;&lt;br /&gt;3. Open httpd.conf and comment out the previous JkMount directives. Replace them with these:&lt;br /&gt;&lt;br /&gt;JkMount /jsp-examples balancer&lt;br /&gt;JkMount /jsp-examples/* balancer&lt;br /&gt;&lt;br /&gt;Very simple- we've just pointed Apache to a single worker- the balancer.&lt;br /&gt;&lt;br /&gt;4. Start up both Tomcats and Apache. Access http://localhost/jsp-examples&lt;br /&gt;You will either be served by Tomcat 1 or Tomcat 2. To prove that both are capable of serving, shut down the first instance and refresh your browser. You should be served by instance two.&lt;br /&gt;&lt;br /&gt;Congratulations! You've successfully set up Apache load balancing multiple tomcat instances!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-6567477942125778217?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/6567477942125778217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=6567477942125778217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6567477942125778217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/6567477942125778217'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/12/how-to-load-balance-tomcat-55-with.html' title='How to load balance Tomcat 5.5 with Apache on Windows'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-3302359781859398782</id><published>2007-12-13T04:23:00.000-08:00</published><updated>2009-06-13T05:40:01.050-07:00</updated><title type='text'>MySQL ssh tunnel</title><content type='html'>1.&lt;br /&gt;On your home machine: &lt;br /&gt;ssh -L 3307:domain.name.of.mysqlserver:3306 username@domain.name.of.gatewayserver&lt;br /&gt;&lt;br /&gt;Ex:&lt;br /&gt;$ ssh -L 3307:dbserver:3306 ananth@xxx.xxxxxxx.xxx&lt;br /&gt;&lt;br /&gt;This will open a tunnel, listening on localhost:3307 and forwarding everything to mysqlserver:3306, and doing it all via the ssh service on the gateway machine.&lt;br /&gt;&lt;br /&gt;2.&lt;br /&gt;Now, on your local machine, execute a mysql connection like so: &lt;br /&gt;mysql -u username -p -h 127.0.0.1 -P 3307 databasename&lt;br /&gt;&lt;br /&gt;Ex:&lt;br /&gt;C:\Program Files\MySQL\MySQL Server 5.0\bin&gt;mysql -u USERNAME -pPASSWORD -h 127.0.0.1 -P 3307 DATABASENAME&lt;br /&gt;&lt;br /&gt;In other words, mysql thinks it's connecting to localhost, but on a different port. In fact, the connection is being made securely to the remote mysql server, via the gateway machine and the local "mouth" of the ssh tunnel on your own machine. &lt;br /&gt;&lt;br /&gt;3.&lt;br /&gt;When you're finished with your mysql session, log out of the session on the gateway machine. That will properly close the tunnel.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-3302359781859398782?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/3302359781859398782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=3302359781859398782' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3302359781859398782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/3302359781859398782'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/12/mysql-ssh-tunnel.html' title='MySQL ssh tunnel'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-7564754802752919692</id><published>2007-10-15T02:17:00.000-07:00</published><updated>2009-06-13T05:40:01.050-07:00</updated><title type='text'>Beginning J2EE</title><content type='html'>This article provides a high-level introduction to J2EE. It is taken from chapter one of the book Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2004; ISBN: 1590593413).&lt;br /&gt;&lt;br /&gt;The word “enterprise” has magical powers in computer programming circles. It can increase the price of a product by an order of magnitude, and double the potential salary of an experienced consultant. Your application may be free of bugs, and cleanly coded using all the latest techniques and tools, but is it enterprise ready? What exactly is the magic ingredient that makes enterprise development qualitatively different from run-of-the-mill development?&lt;br /&gt;&lt;br /&gt;Enterprise applications solve business problems. This usually involves the safe storage, retrieval, and manipulation of business data: customer invoices, mortgage applications, flight bookings, and so on. They might have multiple user interfaces: a web interface for consumers, and a GUI application running on computers in the branch offices, for example. They have to deal with communication between remote systems, co-ordination of data in multiple stores, and ensure the system always follows the rules laid down by the business. If any part of the system crashes, the business loses part of its ability to function, and starts to lose money. If the business grows, the application needs to grow with it. All this adds up to what characterizes enterprise applications: robustness in the face of complexity.&lt;br /&gt;&lt;br /&gt;When we set out to build a GUI application, we don’t start out by working out how to draw pixels on the screen, and build our own code to track the user’s mouse around the screen; we rely on a GUI library, like Swing, to do that for us. Similarly, when we set out to create the components of a full-scale enterprise solution, we’d be crazy to start from scratch. Enterprise programmers build their applications on top   of systems called application servers. Just as GUI toolkits provide services of use to GUI applications, application servers provide services of use to enterprise applications – things like communication facilities to talk to other computers, management of database connections,   the ability to serve web pages, and management of transactions.&lt;br /&gt;&lt;br /&gt;Just as Java provides a uniform way to program GUI applications on any underlying operating system, nowadays Java can provide a uniform way to program enterprise applications on any underlying application server. The set of libraries developed by Sun Microsystems and the Java Community Process that represent this uniform application server API is what we call the Java 2 Platform, Enterprise Edition, and is the subject of this book.&lt;br /&gt;&lt;br /&gt;This chapter provides a high-level introduction to J2EE, and an introduction on how to get the most benefit from this book. After reading this chapter, you will:&lt;br /&gt;Have an understanding of the reasons why the concepts underlying J2EE are compelling and enabling technologies for large-scale applications &lt;br /&gt;Understand how J2EE relates to J2SE &lt;br /&gt;Be introduced to the cornerstone technologies of J2EE &lt;br /&gt;Be introduced to some of the essential architectural patterns that J2EE facilitates &lt;br /&gt;&lt;br /&gt;So, without further ado, let’s get started!&lt;br /&gt;What Is J2EE? &lt;br /&gt;&lt;br /&gt;Since you’re reading this book you’ve got some interest in J2EE, and probably have some notion of what you’re getting into. For many fledgling J2EE developers, J2EE equates to Enterprise JavaBeans. J2EE is a great deal more than just EJBs, though.&lt;br /&gt;&lt;br /&gt;While perhaps an oversimplification, J2EE is a suite of specifications for application programming interfaces, a distributed computing architecture, and definitions for packaging of distributable components for deployment. It’s a collection of standardized components, containers, and services for creating and deploying distributed applications within a well-defined distributed computing architecture.&lt;br /&gt;&lt;br /&gt;As its name pretty much spells out, Java 2 Enterprise Edition is targeted at large-scale business systems. Software that functions at that level doesn’t run on a single PC—it requires significantly more computing power and throughput than that. For that reason, the software needs to be partitioned into functional pieces and deployed on the appropriate hardware platforms to provide the necessary computing power. That is the essence of distributed computing. J2EE provides a collection of standardized components that facilitate software deployment, standard interfaces that define how the various software modules interconnect, and standard services that define how the different software modules communicate.&lt;br /&gt;How J2EE Relates to J2SE &lt;br /&gt;&lt;br /&gt;J2EE isn’t a replacement for the Java 2 Standard Edition. The J2SE provides the essential language framework that the J2EE builds upon. It is the core upon which J2EE is based. As you’ll see, J2EE consists of several layers, and J2SE is right at the base of that pyramid for each component of J2EE.&lt;br /&gt;&lt;br /&gt;As a Java developer, you’ve probably already learned how to build user interfaces with the JFC/Swing and AWT components. You’ll still be using those to build the user interfaces for your J2EE applications, as well as HTML-based user interfaces. Since J2SE is at the core of J2EE, everything that you’ve learned so far remains useful and relevant.&lt;br /&gt;&lt;br /&gt;In fact, J2EE provides pretty much nothing in the way of user interfaces. You’ll also see that the J2EE platform provides the most significant benefit in developing the “middle tier” portion of your application—that’s the business logic and the connections to back-end data sources. You’ll use familiar J2SE components and APIs in conjunction with the J2EE components and APIs to build that part of your applications.&lt;br /&gt;Why J2EE? &lt;br /&gt;&lt;br /&gt;J2EE defines a number of services that, to someone developing enterprise-class applications, are as essential as electricity and running water. Life is simple when you simply turn the faucet and water starts running, or flip the switch and lights come on. If you have ever been involved with building a house, you’ll know that there is a great deal of effort, time, and expense in building in that infrastructure of plumbing and wiring that is then so nicely hidden behind freshly painted walls. At the points where that infrastructure is exposed, there are standard interfaces for controlling (water faucets and light switches, for example) and connecting (power sockets, lamp sockets, and hose bibs, for example).&lt;br /&gt;&lt;br /&gt;In the same vein, there is a great deal of infrastructure required to write enterprise-class applications. There are a bunch of different system-level capabilities that you need in order to write distributed applications that are scaleable, robust, secure, and maintainable. Some vital pieces of that infrastructure include security, to ensure that a user is who they claim to be, and can only access the parts of the application that they’re entitled to access. Database access is also a fundamental component so that your application can store and retrieve data. Transaction support is required to make sure that the right data is updated at the right time. If you’re not familiar with some of these concepts, don’t worry—you’ll be introduced to them one at a time throughout this book.&lt;br /&gt;&lt;br /&gt;Suppose, though, that the wiring and plumbing in your home wasn’t there. You’d need to put in your own plumbing and electricity. Without standard components and interfaces, though, you’d have to fabricate your own pipes, wiring, and so on—it’d be terrifically expensive and an awful lot of work.&lt;br /&gt;&lt;br /&gt;Putting in a distributed computing infrastructure—the plumbing and wiring of an architecture that supports enterprise applications—is no simple feat. That’s why J2EE-based architectures are so compelling—the hard system-level infrastructure is already in place. But why not custom build (or pay someone to custom build) an infrastructure that is designed around your particular application? Well, for starters, it would take a fantastic amount of time, money, and effort. And even if you were to build up that infrastructure, it would be different from anyone else’s infrastructure, so you’d not be able to share components or interoperate with anyone else’s distributed computing model. That’s a lot of work for something that sounds like a dead end. Even if you were lucky enough to find a vendor that could sell you a software infrastructure, you should be wary about any solution that would lock you into any single vendor’s implementation that would preclude you from switching vendors at some point in the future.&lt;br /&gt;&lt;br /&gt;The good news is, no surprise, that J2EE defines a set of containers, connectors, and components that fill that gap. J2EE not only fills the gap, but it’s based on well-known, published specifications. That means that applications written for J2EE will run on any number of J2EE-compliant implementations. The reference implementation supplied with the J2EE Software Development Kit from Sun (J2SDKEE) provides a working model that we’ll use throughout this book, since it’s the implementation that Sun has built from the specification, and is freely available. In the next chapter you’ll get an introduction to installing and testing the J2SDKEE.&lt;br /&gt;&lt;br /&gt;It’s important to note that the reference implementation is a working model but it’s not designed to be used for enterprise-level deployment. It doesn’t provide some of the enterprise-level features that are outside of the scope of the J2EE specification, such as clustering (the ability to have multiple servers handling requests at the same time) or failover (the ability to have a group of servers that can recover when one crashes). Working with the reference implementation, though, ensures that you’ll get exposure to the core J2EE concepts that apply to ALL vendor implementations, and you won’t get bogged down with vendor-specific details.&lt;br /&gt;&lt;br /&gt;For production deployment, you’ll want to select one of a number of J2EE solutions available from a number of different vendors, which have been optimized for high volume throughput and are designed for your particular application. Sun (http://www.sun.com/software), IBM (http://www.ibm.com/websphere), Borland (http://www. borland.com/besappserver) and BEA (http://www.bea.com/ products/weblogic/server) are high-profile examples—but certainly not all—of the commercial implementations. JBoss (http:// www.jboss.org) is an open source implementation that has a huge following. You get to choose which one works best for you—that’s an exercise that’s beyond the scope of this book.&lt;br /&gt;&lt;br /&gt;Building a J2EE application for one J2EE implementation and deploying it on another is cheap, but it’s not free, nor is each vendor’s implementation of J2EE completely free of defects and operational quirks. Although Java and J2EE go a long way towards providing platform independence, that isn’t a guarantee that you can develop on one platform and deploy on another without any hiccups or surprises. Bugs, differences in performance, and other little “gotchas” can seriously delay or derail your project. When you are developing systems that will be deployed in a production environment, it is always a good idea to do your development and staging using the same platforms and technologies that the production environment is based upon. This will help to avoid unnecessary surprises during and after the rollout.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-7564754802752919692?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/7564754802752919692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=7564754802752919692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7564754802752919692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7564754802752919692'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/10/beginning-j2ee.html' title='Beginning J2EE'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-8429181264989345134</id><published>2007-09-12T08:37:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><title type='text'>Interface vs. abstract class</title><content type='html'>Choosing interfaces and abstract classes is not an either/or proposition. If you need to change your design, make it an interface. However, you may have abstract classes that provide some default behavior. Abstract classes are excellent candidates inside of application frameworks. &lt;br /&gt;&lt;br /&gt;Abstract classes let you define some behaviors; they force your subclasses to provide others. For example, if you have an application framework, an abstract class may provide default services such as event and message handling. Those services allow your application to plug in to your application framework. However, there is some application-specific functionality that only your application can perform. Such functionality might include startup and shutdown tasks, which are often application-dependent. So instead of trying to define that behavior itself, the abstract base class can declare abstract shutdown and startup methods. The base class knows that it needs those methods, but an abstract class lets your class admit that it doesn't know how to perform those actions; it only knows that it must initiate the actions. When it is time to start up, the abstract class can call the startup method. When the base class calls this method, Java calls the method defined by the child class.  &lt;br /&gt;&lt;br /&gt;Many developers forget that a class that defines an abstract method can call that method as well. Abstract classes are an excellent way to create planned inheritance hierarchies. They're also a good choice for nonleaf classes in class hierarchies. &lt;br /&gt;&lt;br /&gt; Q: Why use interfaces to develop Java applications? &lt;br /&gt;A: It is advisable to design relatively large applications using interfaces because it makes the whole system easier to modify, extend and integrate new features. To start with, you may only have one implementation of a given interface, but if you find you need slightly different behaviour in special circumstances, you only need write a class that conforms to one of the existing interfaces and it will drop in place without major modifications. &lt;br /&gt;&lt;br /&gt;Interfaces also allow you to adapt a class from a different hierarchy to work in an existing application. The class only needs to declare it implements the interface, provide the necessary methods and it can be integrated directly as if it were created for the job. &lt;br /&gt;&lt;br /&gt;Q: What is the difference between abstract classes and interfaces? &lt;br /&gt;A: A Java interface is a definition of a class type without any concrete implementation. Typically, an interface consists of one or more method signatures that a subclass must fulfil to conform to the type. In effect, all their methods are abstract, and interfaces cannot be instantiated&lt;br /&gt;&lt;br /&gt;Q: Do interfaces have member variables? &lt;br /&gt;A: Interfaces may have member variables, but these are implicitly final and static because they are not inherited by extension. In effect interface variables are constants that are available to all implementations and may be used as key references for method arguments for example. &lt;br /&gt;&lt;br /&gt;Q: Can we create an object for an interface? &lt;br /&gt;A: Yes, it is always necessary to create an object implementation for an interface. Interfaces cannot be instantiated in their own right, so you must write a class that implements the interface and fulfil all the methods defined in it. &lt;br /&gt;&lt;br /&gt;public class Concrete implements ExampleInterface {&lt;br /&gt;&lt;br /&gt;  ...&lt;br /&gt;}&lt;br /&gt;      Q: What is a marker interface? &lt;br /&gt;A: Marker interfaces are those which do not declare any required methods, but signify their compatibility with certain operations. The java.io.Serializable interface is a typical marker interface. It does not contain any methods, but classes must implement this interface in order to be serialized and de-serialized. &lt;br /&gt;&lt;br /&gt;Q: Should I use a public access modifier for interface methods? &lt;br /&gt;A: Java interfaces are used to define a public Application Programming Interface (API) for classes to implement, so a public modifier is redundant in this context. Non-public modifiers are not valid for interfaces, so the compiler should fail and warn you in this case. &lt;br /&gt;&lt;br /&gt;Interface usage &lt;br /&gt;Q: What are the rules for passing subclasses for method arguments? &lt;br /&gt;A: It may help to discuss an example using birds: an interface called Avian, a superclass FlyingBird that implements Avian and two concrete classes: Parrot and Penguin. Parrot extends FlyingBird, so is implicitly an Avian type, but Penguin does not, it only implements Avian. The examples below work through all possibilities, passing references to methods soundBirdCall(FlyingBird) and displayPlumage(Avian)&lt;br /&gt;&lt;br /&gt;Q: When should I use abstract classes rather than interfaces? &lt;br /&gt;A: Abstract classes are are often used to provide methods that will be common to a range of similar subclasses, to avoid duplicating the same code in each case. Each subclass adds its own features on top of the common abstract methods. &lt;br /&gt;&lt;br /&gt;Q: Can an interface be declared final? &lt;br /&gt;A: It is not permitted to declare an interface as final, it will cause a compilation error. It does not make sense to declare an interface final because it contains no implementation code and cannot instantiated in its own right. The final modifier is used to prevent the extension of concrete classes. &lt;br /&gt;&lt;br /&gt;Q: This code seems to be instantiating an interface! &lt;br /&gt;A: The code you are looking at declares an inline anonymous class that implements an interface, which has a similar effect. This declaration does not instantiate the interface, but defines the type of the anonymous class, which has no name of its own. This approach is often used in AWT or Swing applications where a class is required to fulfil a minimal interface and it is not necessary to retain a reference to it by assignment.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-8429181264989345134?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/8429181264989345134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=8429181264989345134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/8429181264989345134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/8429181264989345134'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/09/interface-vs-abstract-class.html' title='Interface vs. abstract class'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-2168997241666919954</id><published>2007-09-12T08:22:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><title type='text'>Ocerriding vs Hiding</title><content type='html'>Can I override a static method? &lt;br /&gt;Many people have heard that you can't override a static method. This is true - you can't. However it is possible to write code like this:&lt;br /&gt;&lt;br /&gt;class Foo {&lt;br /&gt;    public static void method() {&lt;br /&gt;        System.out.println("in Foo");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;//commited  by  sanjay&lt;br /&gt;class Bar extends Foo {&lt;br /&gt;    public static void method() {&lt;br /&gt;        System.out.println("in Bar");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;This compiles and runs just fine. Isn't it an example of a static method overriding another static method? The answer is no - it's an example of a static method hiding another static method. If you try to override a static method, the compiler doesn't actually stop you - it just doesn't do what you think it does. &lt;br /&gt;So what's the difference? &lt;br /&gt;&lt;br /&gt;Briefly, when you override a method, you still get the benefits of run-time polymorphism, and when you hide, you don't. So what does that mean? Take a look at this code:&lt;br /&gt;&lt;br /&gt;class Foo {&lt;br /&gt;    public static void classMethod() {&lt;br /&gt;        System.out.println("classMethod() in Foo");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void instanceMethod() {&lt;br /&gt;        System.out.println("instanceMethod() in Foo");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Bar extends Foo {&lt;br /&gt;    public static void classMethod() {&lt;br /&gt;        System.out.println("classMethod() in Bar");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void instanceMethod() {&lt;br /&gt;        System.out.println("instanceMethod() in Bar");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;class Test {&lt;br /&gt;    public static void main(String[] args) {&lt;br /&gt;        Foo f = new Bar();&lt;br /&gt;        f.instanceMethod();&lt;br /&gt;        f.classMethod();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;If you run this, the output is&lt;br /&gt;instanceMethod() in Bar&lt;br /&gt;classMethod() in Foo&lt;br /&gt;Why do we get instanceMethod from Bar, but classMethod() from Foo? Aren't we using the same instance f to access both of these? Yes we are - but since one is overriding and the other is hiding, we see different behavior. &lt;br /&gt;Since instanceMethod() is (drum roll please...) an instance method, in which Bar overrides the method from Foo, at run time the JVM uses the actual class of the instance f to determine which method to run. Although f was declared as a Foo, the actual instance we created was a new Bar(). So at runtime, the JVM finds that f is a Bar instance, and so it calls instanceMethod() in Bar rather than the one in Foo. That's how Java normally works for instance methods. &lt;br /&gt;&lt;br /&gt;With classMethod() though. since (ahem) it's a class method, the compiler and JVM don't expect to need an actual instance to invoke the method. And even if you provide one (which we did: the instance referred to by f) the JVM will never look at it. The compiler will only look at the declared type of the reference, and use that declared type to determine, at compile time, which method to call. Since f is declared as type Foo, the compiler looks at f.classMethod() and decides it means Foo.classMethod. It doesn't matter that the instance reffered to by f is actually a Bar - for static methods, the compiler only uses the declared type of the reference. That's what we mean when we say a static method does not have run-time polymorphism. &lt;br /&gt;&lt;br /&gt;Because instance methods and class methods have this important difference in behavior, we use different terms - "overriding" for instance methods and "hiding" for class methods - to distinguish between the two cases. And when we say you can't override a static method, what that means is that even if you write code that looks like it's overriding a static method (like the first Foo and Bar at the top of this page) - it won't behave like an overridden method. &lt;br /&gt;&lt;br /&gt;So what about accessing a static method using an instance? &lt;br /&gt;&lt;br /&gt;It's possible in Java to write something like: &lt;br /&gt;&lt;br /&gt;   f.classMethod();&lt;br /&gt;] where f is an instance of some class, and classMethod() is a class method (i.e. a static method) of that class. This is legal, but it's a bad idea because it creates confusion. The actual instance f is not really important here. Only the decleared type of f matters. That is, what class is f declared to be? Since classMethod() is static, the class of f (as determined by the compiler at compile time) is all we need. &lt;br /&gt;Rather than writing:&lt;br /&gt;&lt;br /&gt;    f.classMethod();&lt;br /&gt;It would be better coding style to write either:&lt;br /&gt;    Foo.classMethod();&lt;br /&gt;or&lt;br /&gt;    Bar.classMethod(); &lt;br /&gt;That way, it is crystal clear which class method you would like to call. It is also clear that the method you are calling is indeed a class method. &lt;br /&gt;Barring that, you could always come up with this monstrosity:&lt;br /&gt;&lt;br /&gt;    f.getClass().getMethod("classMethod", new Class[]).invoke(f, new Object[]);&lt;br /&gt;But all this could be avoided by simply not trying to override your static (class) methods. :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-2168997241666919954?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/2168997241666919954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=2168997241666919954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2168997241666919954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2168997241666919954'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/09/ocerriding-vs-hiding.html' title='Ocerriding vs Hiding'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-8046455015092039324</id><published>2007-09-11T05:36:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><title type='text'>Java Virtual Machine</title><content type='html'>&lt;span style="font-weight:bold;"&gt;What is the Java Virtual Machine? Why is it here?&lt;/span&gt;&lt;br /&gt;The Java Virtual Machine, or JVM, is an abstract computer that runs compiled Java programs. The JVM is "virtual" because it is generally implemented in software on top of a "real" hardware platform and operating system. All Java programs are compiled for the JVM. Therefore, the JVM must be implemented on a particular platform before compiled Java programs will run on that platform. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_h8w_fktOw40/RuaMe2AGlsI/AAAAAAAAAAg/vKRnTnBmo5s/s1600-h/Sandwich.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_h8w_fktOw40/RuaMe2AGlsI/AAAAAAAAAAg/vKRnTnBmo5s/s200/Sandwich.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5108925288818316994" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The JVM plays a central role in making Java portable. It provides a layer of abstraction between the compiled Java program and the underlying hardware platform and operating system. The JVM is central to Java's portability because compiled Java programs run on the JVM, independent of whatever may be underneath a particular JVM implementation. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What makes the JVM lean and mean? The JVM is lean because it is small when implemented in software. It was designed to be small so that it can fit in as many places as possible -- places like TV sets, cell phones, and personal computers. The JVM is mean because it of its ambition. "Ubiquity!" is its battle cry. It wants to be everywhere, and its success is indicated by the extent to which programs written in Java will run everywhere. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Java bytecodes&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java programs are compiled into a form called Java bytecodes. The JVM executes Java bytecodes, so Java bytecodes can be thought of as the machine language of the JVM. The Java compiler reads Java language source (.java) files, translates the source into Java bytecodes, and places the bytecodes into class (.class) files. The compiler generates one class file per class in the source. &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_h8w_fktOw40/RuaMq2AGltI/AAAAAAAAAAo/EVr6zLCD4Ko/s1600-h/Filter.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_h8w_fktOw40/RuaMq2AGltI/AAAAAAAAAAo/EVr6zLCD4Ko/s200/Filter.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5108925494976747218" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To the JVM, a stream of bytecodes is a sequence of instructions. Each instruction consists of a one-byte opcode and zero or more operands. The opcode tells the JVM what action to take. If the JVM requires more information to perform the action than just the opcode, the required information immediately follows the opcode as operands. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A mnemonic is defined for each bytecode instruction. The mnemonics can be thought of as an assembly language for the JVM.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-8046455015092039324?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/8046455015092039324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=8046455015092039324' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/8046455015092039324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/8046455015092039324'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/09/java-virtual-machine.html' title='Java Virtual Machine'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_h8w_fktOw40/RuaMe2AGlsI/AAAAAAAAAAg/vKRnTnBmo5s/s72-c/Sandwich.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-7728293532857040749</id><published>2007-09-11T05:01:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><title type='text'>Java bytecode:</title><content type='html'>This article gives you an understanding of Java bytecode that will enable you to be a better programmer. Like a C or C++ compiler translates source code into assembler code, Java compilers translate Java source code into bytecode. Java programmers should take the time to understand what the bytecode is, how it works, and most importantly, what bytecode is being generated by the Java compiler.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Why understand bytecode?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Bytecode is the intermediate representation of Java programs just as assembler is the intermediate representation of C or C++ programs. The most knowlegable C and C++ programmers know the assembler instruction set of the processor for which they are compiling. This knowledge is crucial when debugging and doing performance and memory usage tuning. Knowing the assembler instructions that are generated by the compiler for the source code you write, helps you know how you might code differently to achieve memory or performance goals. In addition, when tracking down a problem, it is often useful to use a debugger to disassemble the source code and step through the assembler code that is executing. &lt;br /&gt;&lt;br /&gt;An often overlooked aspect of Java is the bytecode that is generated by the javac compiler. Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer. &lt;br /&gt;&lt;br /&gt;The bytecode is your program. Regardless of a JIT or Hotspot runtime, the bytecode is an important part of the size and execution speed of your code. Consider that the more bytecode you have, the bigger the .class file is and the more code that has to be compiled by a JIT or Hotspot runtime. The remainder of this article gives you an in depth look at Java bytecode. &lt;br /&gt;&lt;br /&gt;Generating bytecode&lt;br /&gt;&lt;br /&gt;javac Employee.java&lt;br /&gt;javap -c Employee &gt; Employee.bc&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Compiled from Employee.java&lt;br /&gt;class Employee extends java.lang.Object {&lt;br /&gt;public Employee(java.lang.String,int);&lt;br /&gt;public java.lang.String employeeName();&lt;br /&gt;public int employeeNumber();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Method Employee(java.lang.String,int)&lt;br /&gt;0 aload_0&lt;br /&gt;1 invokespecial #3 &lt;Method java.lang.Object()&gt;&lt;br /&gt;4 aload_0&lt;br /&gt;5 aload_1&lt;br /&gt;6 putfield #5 &lt;Field java.lang.String name&gt;&lt;br /&gt;9 aload_0&lt;br /&gt;10 iload_2&lt;br /&gt;11 putfield #4 &lt;Field int idNumber&gt;&lt;br /&gt;14 aload_0&lt;br /&gt;15 aload_1&lt;br /&gt;16 iload_2&lt;br /&gt;17 invokespecial #6 &lt;Method void storeData(java.lang.String, int)&gt;&lt;br /&gt;20 return&lt;br /&gt;&lt;br /&gt;Method java.lang.String employeeName()&lt;br /&gt;0 aload_0&lt;br /&gt;1 getfield #5 &lt;Field java.lang.String name&gt;&lt;br /&gt;4 areturn&lt;br /&gt;&lt;br /&gt;Method int employeeNumber()&lt;br /&gt;0 aload_0&lt;br /&gt;1 getfield #4 &lt;Field int idNumber&gt;&lt;br /&gt;4 ireturn&lt;br /&gt;&lt;br /&gt;Method void storeData(java.lang.String, int)&lt;br /&gt;0 return&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This class is very simple. It contains two instance variables, a constructor and three methods. The first five lines of the bytecode file list the file name that is used to generate this code, the class definition, its inheritance (by default, all classes inherit from java.lang.Object ), and its constructors and methods. Next, the bytecode for each of the constructors is listed. Then, each method is listed in alphabetical order with its associated bytecode. &lt;br /&gt;&lt;br /&gt;You might notice on closer inspection of the bytecode that certain opcodes are prefixed with an `a' or an `i'. For example, in the Employee class constructor you see aload_0 and iload_2. The prefix is representative of the type that the opcode is working with. The prefix `a' means that the opcode is manipulating an object reference. The prefix `i' means the opcode is manipulating an integer. Other opcodes use `b' for byte, `c' for char, `d' for double, etc. This prefix gives you immediate knowledge about what type of data is being manipulated.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The details&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To understand the details of the bytecode, we need to discuss how a Java Virtual Machine (JVM) works regarding the execution of the bytecode. A JVM is a stack-based machine. Each thread has a JVM stack which stores frames. A frame is created each time a method is invoked, and consists of an operand stack, an array of local variables, and a reference to the runtime constant pool of the class of the current method. Conceptually, it might look like this: &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_h8w_fktOw40/RuaEHmAGlrI/AAAAAAAAAAY/0KDtIXu5NGY/s1600-h/bytecode_1.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_h8w_fktOw40/RuaEHmAGlrI/AAAAAAAAAAY/0KDtIXu5NGY/s200/bytecode_1.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5108916093293336242" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The array of local variables, also called the local variable table, contains the parameters of the method and is also used to hold the values of the local variables. The parameters are stored first, beginning at index 0. If the frame is for a constructor or an instance method, the reference is stored at location 0. Then location 1 contains the first formal parameter, location 2 the second, and so on. For a static method, the first formal method parameter is stored in location 0, the second in location 1, and so on. &lt;br /&gt;&lt;br /&gt;The size of the array of local variables is determined at compile time and is dependent on the number and size of local variables and formal method parameters. The operand stack is a LIFO stack used to push and pop values. Its size is also determined at compile time. Certain opcode instructions push values onto the operand stack; others take operands from the stack, manipulate them, and push the result. The operand stack is also used to receive return values from methods. &lt;br /&gt;&lt;br /&gt;public String employeeName()&lt;br /&gt;{&lt;br /&gt;return name;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Method java.lang.String employeeName()&lt;br /&gt;0 aload_0&lt;br /&gt;1 getfield #5 &lt;Field java.lang.String name&gt;&lt;br /&gt;4 areturn&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The bytecode for this method consists of three opcode instructions. The first opcode, aload_0, pushes the value from index 0 of the local variable table onto the operand stack. Earlier, it was mentioned that the local variable table is used to pass parameters to methods. The this reference is always stored at location 0 of the local variable table for constructors and instance methods. The this reference must be pushed because the method is accessing the instance data, name, of the class.&lt;br /&gt;&lt;br /&gt;The next opcode instruction, getfield, is used to fetch a field from an object. When this opcode is executed, the top value from the stack, this, is popped. Then the #5 is used to build an index into the runtime constant pool of the class where the reference to name is stored. When this reference is fetched, it is pushed onto the operand stack. &lt;br /&gt;&lt;br /&gt;The last instruction, areturn, returns a reference from a method. More specifically, the execution of areturn causes the top value on the operand stack, the reference to name, to be popped and pushed onto the operand stack of the calling method.&lt;br /&gt;&lt;br /&gt;The employeeName method is fairly simple. Before looking at a more complex example, we need to examine the values to the left of each opcode. In the employeeName method's bytecode, these values are 0, 1, and 4. Each method has a corresponding bytecode array. These values correspond to the index into the array where each opcode and its arguments are stored. You might wonder why the values are not sequential. Since bytecode got its name because each instruction occupies one byte, why are the indexes not 0, 1, and 2? The reason is some of the opcodes have parameters that take up space in the bytecode array. For example, the aload_0 instruction has no parameters and naturally occupies one byte in the bytecode array. Therefore, the next opcode, getfield, is in location 1. However, areturn is in location 4. This is because the getfield opcode and its parameters occupy location 1, 2, and 3. Location 1 is used for the getfield opcode, location 2 and 3 are used to hold its parameters. These parameters are used to construct an index into the runtime constant pool for the class to where the value is stored. The following diagram shows what the bytecode array looks like for the employeeName method:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Actually, the bytecode array contains bytes that represent the instructions. Looking at a .class file with a hex editor, you would see the following values in the bytecode array: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2A , B4 , and B0 correspond to aload_0, getfield, and areturn, respectively.&lt;br /&gt;&lt;br /&gt;public Employee(String strName, int num)&lt;br /&gt;{&lt;br /&gt;name = strName;&lt;br /&gt;idNumber = num;&lt;br /&gt;storeData(strName, num);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Method Employee(java.lang.String,int)&lt;br /&gt;0 aload_0&lt;br /&gt;1 invokespecial #3 &lt;Method java.lang.Object()&gt;&lt;br /&gt;4 aload_0&lt;br /&gt;5 aload_1&lt;br /&gt;6 putfield #5 &lt;Field java.lang.String name&gt;&lt;br /&gt;9 aload_0&lt;br /&gt;10 iload_2&lt;br /&gt;11 putfield #4 &lt;Field int idNumber&gt;&lt;br /&gt;14 aload_0&lt;br /&gt;15 aload_1&lt;br /&gt;16 iload_2&lt;br /&gt;17 invokespecial #6 &lt;Method void storeData(java.lang.String, int)&gt;&lt;br /&gt;20 return&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The first opcode instruction at location 0, aload_0, pushes the this reference onto the operand stack. (Remember, the first entry of the local variable table for instance methods and constructors is the this reference.) &lt;br /&gt;&lt;br /&gt;The next opcode instruction at location 1, invokespecial, calls the constructor of this class's superclass. Because all classes that do not explicitly extend any other class implicitly inherit from java.lang.Object , the compiler provides the necessary bytecode to invoke this base class constructor. During this opcode, the top value from the operand stack, this, is popped.&lt;br /&gt;&lt;br /&gt;The next two opcodes, at locations 4 and 5 push the first two entries from the local variable table onto the operand stack. The first value to be pushed is the this reference. The second value is the first formal parameter to the constructor, strName . These values are pushed in preparation for the putfield opcode instruction at location 6. &lt;br /&gt;&lt;br /&gt;The putfield opcode pops the two top values off the stack and stores a reference to strName into the instance data name of the object referenced by this . &lt;br /&gt;&lt;br /&gt;The next three opcode instructions at locations 9, 10, and 11 perform the same operation with the second formal parameter to the constructor, num , and the instance variable, idNumber . &lt;br /&gt;&lt;br /&gt;The next three opcode instructions at locations 14, 15, and 16 prepare the stack for the storeData method call. These instructions push the this reference, strName , and num , respectively. The this reference must be pushed because an instance method is being called. If the method was declared static, the this reference would not need to be pushed. The strName and num values are pushed since they are the parameters to the storeData method. When the storeData method executes, the this reference, strName , and num , will occupy indexes 0, 1, and 2, respectively, of the local variable table contained in the frame for that method. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Compiler options&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The javac compiler provides a few options that you need to know. The first is the -O option. The JDK documentation claims that -O will optimize your code for execution speed. Using -O with the javac compiler with the Sun Java 2 SDK has no effect on the generated code. Previous versions of the Sun javac compiler performed some rudimentary bytecode optimizations, but these have since been removed. The SDK documentation, however, has not been updated. The only reason -O remains as an option is for compatibility with older make files. Therefore, there is currently no reason to use it. &lt;br /&gt;&lt;br /&gt;This also means that the bytecode that is generated by the javac compiler is not any better than the code that you write. For example, if you write a loop that contains an invariant, the invariant will not be removed from the loop by the javac compiler. Programmers are used to compilers from other languages that clean up badly written code. Unfortunately, javac does not do this. More importantly, the javac compiler does not perform simple optimizations like loop unrolling, algebraic simplification, strength reduction, and others. To get these benefits and other simple optimizations, the programmer must perform them on the Java source code and not rely on the javac compiler to perform them. There are many techniques you can use to make the Java compiler generate faster and smaller bytecode. Unfortunately, until Java compilers perform them, you must implement them yourself to achieve their benefits. &lt;br /&gt;&lt;br /&gt;The javac compiler also supplies the -g and -g:none options. The -g option tells the compiler to generate all the debugging information. The -g:none option tells the compiler to generate no debugging information. Compiling with -g:none generates the smallest possible .class file. Therefore, this option should be used when trying to generate the smallest possible .class files prior to deployment. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Java debuggers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One very useful feature that I have yet to see in a Java debugger is a disassembly view similar to that of a C or C++ debugger. Disassembling Java code would reveal the bytecode, much like disassembling C or C++ code reveals assembler code. In addition to this feature, another useful feature could be the ability to single step through the bytecode, executing one opcode at a time. &lt;br /&gt;&lt;br /&gt;This level of functionality would allow the programmer to see, first hand, the bytecode generated by the Java compiler as well as step through it during debugging. The more information a programmer has about the code generated and executed, the better chance there is of avoiding problems. This type of debugger feature would also encourage programmers to look at, and understand, the bytecode that is executing for their source code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-7728293532857040749?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/7728293532857040749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=7728293532857040749' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7728293532857040749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7728293532857040749'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/09/java-bytecode.html' title='Java bytecode:'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_h8w_fktOw40/RuaEHmAGlrI/AAAAAAAAAAY/0KDtIXu5NGY/s72-c/bytecode_1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-8970539440221995937</id><published>2007-09-06T06:39:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><title type='text'>Server-side web programming</title><content type='html'>Web applications are client/server applications. The web browser is the client. The server is a program running on some computer which is identified by a number called the port to distinguish it from other server programs. Clients access the server program via the pair (server,port) called a socket. The browser client (as well as other client programs) initiates the interaction with a URL request: &lt;br /&gt;protocol://data_source&lt;br /&gt;&lt;br /&gt;where the protocol is any number of possiblities, including http, file, https, ftp, etc. The data_source can be any number of things from a regular file on the client's machine to a file or program on some server such as these: &lt;br /&gt;file://file&lt;br /&gt;http://server/dir1/dir2/file&lt;br /&gt;http://server/dir1/program&lt;br /&gt;http://server:port/file       (server running on alternate port)&lt;br /&gt;&lt;br /&gt;The protocol normally dictates the port, but we can specify it if it's different than the usual one. If the target file is a directory, then a default file or program is chosen as the source. &lt;br /&gt;&lt;br /&gt;Server-side web programming means that an HTTP request from a browser causes the web server to run a program which generates HTML (or other data) and sends it back to the browser. Java uses Servlets and Java Server Pages (JSP) for server-side programming. These two software technologies are Java's contribution to the two primary styles of server-side programming: &lt;br /&gt;HTML code generated entirely by programming: Perl/CGI, Servlets &lt;br /&gt;program code embedded within HTML code: PHP, ASP, JSP &lt;br /&gt;Server-side programming stands in contrast to client-side programming which is usually equated with JavaScript, but can also be effected by Java Applets, Flash, or any others which provide a browser plugin. &lt;br /&gt;&lt;br /&gt;Tomcat web server&lt;br /&gt;A Java Servlet is an object that can the executed by an HTTP server due to the invocation of a browser client. This ability is not automatically part of standard web servers like Apache and Microsoft's IIS so we need a specialized web server for that purpose. The Apache open source tomcat web server serves our needs; its website is this: &lt;br /&gt;http://tomcat.apache.org/ &lt;br /&gt;In order to permit user access and not to conflict with other web services — the standard web service runs on port 80, a restricted port in UNIX system — tomcat runs on the standard port 8080. The Tomcat web server starts a Java virtual machine (JVM) and handles browser client accesses by executing the servlets in threads created by this JVM which makes the entire web service process very fast, in contrast, say to CGI programming in which each web server activation requires a new process creation. &lt;br /&gt;Eclipse Web applications setup&lt;br /&gt;The Eclipse IDE supports many plugin tools and allows developers to directly create and modify plugins. It's not clear at this stage of development what will be the definitive plugin tool for web development but the so-called webtools development packages found at &lt;br /&gt;http://www.eclipse.org/webtools/ &lt;br /&gt;seems like a likely contender. We'll use the webtools current release build, version R-1.5.2-200610261841, which requires eclipse version 3.1.1. The current stable webtools release is 1.5M4, but this requires eclipse version 3.2M4. &lt;br /&gt;&lt;br /&gt;The eclipse webtools and support plugins you'll need are these: &lt;br /&gt;wtp-sdk-R-1.5.2-200610261841.zip &lt;br /&gt;emf-sdo-xsd-SDK-2.2.1.zip &lt;br /&gt;GEF-SDK-3.2.1.zip &lt;br /&gt;JEM-SDK-1.2.1.zip &lt;br /&gt;&lt;br /&gt;The Apache tomcat web server, currently version 6.0.14, uses this distribution file, also available through the tomcat website: &lt;br /&gt;apache-tomcat-6.0.14.zip&lt;br /&gt;&lt;br /&gt;Install Webtools&lt;br /&gt;Assuming that eclipse 3.1.1 is installed as the directory "eclipse", extract these zip archives: &lt;br /&gt;wtp-sdk-R-1.5.2-200610261841.zip &lt;br /&gt;emf-sdo-xsd-SDK-2.2.1.zip &lt;br /&gt;GEF-SDK-3.2.1.zip &lt;br /&gt;JEM-SDK-1.2.1.zip &lt;br /&gt;&lt;br /&gt;into the directory containing the eclipse subdirectory (e.g., the C:\ directory in my suggested Windows installation of Eclipse). These zip archives already have eclipse as their top-level directory, and so their contents will be extracted correctly into the eclipse subdirectory. &lt;br /&gt;&lt;br /&gt;The zip files extract almost entirely into the features and plugins subdirectories of eclipse. The EMF zip archive contains duplicates of the top-level files epl-v10.html and notice.html You can either let them be overwritten or not — it is unimportant. &lt;br /&gt;Install Tomcat&lt;br /&gt;Unzip the file apache-tomcat-6.0.14.zip into your folder of choice; it creates the subdirectory &lt;br /&gt;apache-tomcat-6.0.14&lt;br /&gt;A good choice for location might be the same directory holding eclipse. &lt;br /&gt;Tomcat Server Setup in Eclipse&lt;br /&gt;Open Eclipse and select New  Other. You should see quite a number of new categories now available due to the plugin additions. &lt;br /&gt;&lt;br /&gt;To create the Tomcat server: &lt;br /&gt;Open the Server category, select the Server entry within and click Next. &lt;br /&gt;In the Define a New Server window, select Apache  Tomcat v5.5 Server, click Next. &lt;br /&gt;In the Tomcat Server window, click the Browse button to specify the Tomcat installation directory, apache-tomcat-6.0.14. Click Finish. &lt;br /&gt;Specify the web browser to use&lt;br /&gt;Eclipse has its own internal web browser that can be used to display web content, but you may want to use an external web browser. In eclipse, select: &lt;br /&gt;Window  Preferences  General  Web Browser &lt;br /&gt;It's not clear that the so-called Default System Web Browser will find the right thing. You can add your own external browser if necessary. On a Windows installation, Internet Explorer will be among the list of browsers; you can simply select it, it takes no parameters. &lt;br /&gt;&lt;br /&gt;For other browsers, e.g., firefox or mozilla browsers, if already on the list, select it, click Edit, and set the parameters to &lt;br /&gt;-url %URL%&lt;br /&gt;&lt;br /&gt;If not in the list, click New, fill in the Name (e.g., "Firefox"); browse to find the location of the executable and finally set the parameters as above. &lt;br /&gt;The structure of a Servlet&lt;br /&gt;The activation of a servlet is initiated by a client-side (browser) request. There are two types of requests: GET and POST. GET requests are most standard and always activated by typing any URL into a browser. GET requests are also those in which you see parameters delivered in the URL itself after the "?" character, a portion called the query string. POST requests are less frequent and are normally initiated by HTML forms. &lt;br /&gt;&lt;br /&gt;A Java Servlet is an extension of the javax.servlet.http.HttpServlet. A GET or POST request activates one of the two built-in functions: doGet or doPost, respectively. Many server-side programs do not need to differentiate between these two activations and it is often common to merge the behaviors of these activations. &lt;br /&gt;Servlet template&lt;br /&gt;import java.io.*;             // for PrintWriter, IOException&lt;br /&gt;import javax.servlet.*;       // for Servlet*&lt;br /&gt;import javax.servlet.http.*;  // for HttpServlet*&lt;br /&gt;&lt;br /&gt;public class MyServlet extends HttpServlet implements Servlet&lt;br /&gt;{&lt;br /&gt;  protected void &lt;br /&gt;    doGet(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;  throws ServletException, IOException {&lt;br /&gt;    /* ... */&lt;br /&gt;  }&lt;br /&gt;    &lt;br /&gt;  protected void &lt;br /&gt;    doPost(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;  throws ServletException, IOException { &lt;br /&gt;    /* ... */&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Typical content for the doGet or doPost function is as follows: &lt;br /&gt;response.setContentType("text/html");&lt;br /&gt;PrintWriter out = response.getWriter();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-8970539440221995937?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/8970539440221995937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=8970539440221995937' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/8970539440221995937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/8970539440221995937'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/09/server-side-web-programming.html' title='Server-side web programming'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-4717697897559760889</id><published>2007-09-02T04:11:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hibernate tutorial examples'/><title type='text'>Hibernate</title><content type='html'>&lt;b&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;What is Hibernate?&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;Hibernate 3.0, the latest Open Source persistence technology at the heart of J2EE EJB 3.0 is available for download from &lt;a href="http://www.hibernate.org/Download/DownloadOverview" target="_blank"&gt;Hibernet.org&lt;/a&gt;.The Hibernate 3.0 core is 68,549 lines of Java code together with 27,948 lines of unit tests, all freely available under the LGPL, and has been in development for well over a year. Hibernate maps the Java classes to the database tables. It also provides the data query and retrieval facilities that significantly reduces the development time.  Hibernate is not the best solutions for data centric applications that only uses the stored-procedures to implement the business logic in database. It is most useful with object-oriented domain modes and business logic in the Java-based middle-tier. Hibernate allows transparent persistence that enables the applications to switch any database. Hibernate can be used in Java Swing applications, Java Servlet-based applications, or J2EE applications using EJB session beans. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Features of Hibernate&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Hibernate 3.0 provides      three full-featured query facilities: &lt;b&gt;Hibernate Query Language&lt;/b&gt;, the      newly enhanced &lt;b&gt;Hibernate Criteria Query API&lt;/b&gt;, and enhanced support      for queries expressed in the &lt;b&gt;native SQL &lt;/b&gt;dialect of the database.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Filters for working with      temporal (historical), regional or permissioned data.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Enhanced Criteria query      API: with full support for projection/aggregation and subselects.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Runtime performance      monitoring: via JMX or local Java API, including a second-level cache      browser.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Eclipse support,      including a suite of Eclipse plug-ins for working with Hibernate 3.0,      including mapping editor, interactive query prototyping, schema reverse      engineering tool.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Hibernate is Free under      LGPL: Hibernate can be used to develop/package and distribute the      applications for free.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Hibernate is Scalable:      Hibernate is very performant and due to its dual-layer architecture can be      used in the clustered environments.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Less Development Time:      Hibernate reduces the development timings as it supports inheritance,      polymorphism, composition and the Java Collection framework.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Automatic Key      Generation: Hibernate supports the automatic generation of primary key for      your.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt; JDK 1.5      Enhancements: The new JDK has been released as a preview earlier this year      and we expect a slow migration to the new 1.5 platform throughout 2004.      While Hibernate3 still runs perfectly with JDK 1.2, Hibernate3 will make      use of some new JDK features. JSR 175 annotations, for example, are a      perfect fit for Hibernate metadata and we will embrace them aggressively.      We will also support Java generics, which basically boils down to allowing      type safe collections.&lt;br /&gt;       &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;EJB3-style persistence      operations: EJB3 defines the &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;create()&lt;/span&gt;&lt;/tt&gt;      and &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;merge()&lt;/span&gt;&lt;/tt&gt; operations,      which are slightly different to Hibernate's &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;saveOrUpdate()&lt;/span&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;saveOrUpdateCopy()&lt;/span&gt;&lt;/tt&gt;      operations. Hibernate3 will support all four operations as methods of the &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;Session&lt;/span&gt;&lt;/tt&gt; interface.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Hibernate XML binding      enables data to be represented as XML and POJOs interchangeably.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;The EJB3 draft      specification support for POJO persistence and annotations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In this lesson you will learn the architecture of Hibernate.  The following diagram describes the high level architecture of hibernate:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:281.25pt;"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" href="http://www.roseindia.net/hibernate/hibernatearchitecture.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image001.gif" shapes="_x0000_i1025" border="0" height="375" width="375" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;The above diagram shows that Hibernate is using the database and configuration data to provide persistence services (and persistent objects) to the application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="color: navy;"&gt;To use Hibernate, it is required to create Java classes that represents the table in the database and then map the instance variable in the class with the columns in the database. Then Hibernate can be used to perform operations on the database like select, insert, update and delete the records in the table. Hibernate automatically creates the query to perform these operations. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Hibernate architecture has three main components:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: navy;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Connection Management&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Hibernate Connection management service provide efficient management of the database connections. Database connection is the most expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.&lt;br /&gt;   &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: navy;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Transaction management:&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Transaction management service provide the ability to the user to execute more than one database statements at a time.&lt;br /&gt;   &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: navy;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Object relational mapping:&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Object relational mapping is technique of mapping the data representation from an object model to a relational data model. This part of the hibernate is used to select, insert, update and delete the records form the underlying table. When we pass an object to a &lt;b&gt;Session.save()&lt;/b&gt; method, Hibernate reads the state of the variables of that object and executes the necessary query. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Hibernate is very good tool as far as object relational mapping is concern, but in terms of connection management and transaction management, it is lacking in performance and capabilities. So usually hibernate is being used with other connection management and transaction management tools. For example apache DBCP is used for connection pooling with the Hibernate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Hibernate provides a lot of flexibility in use. It is called "&lt;b&gt;Lite&lt;/b&gt;" architecture when we only uses the object relational mapping component. While in "&lt;b&gt;Full Cream&lt;/b&gt;" architecture all the three component Object Relational mapping, Connection Management and Transaction Management) are used.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In this section I will show you how to create a simple program to insert record in MySQL database. You can run this program from Eclipse or from command prompt as well. I am assuming that you are familiar with MySQL and Eclipse environment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Configuring Hibernate&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;In this application Hibernate provided connection pooling and transaction management is used for simplicity. Hibernate uses the hibernate.cfg.xml to create the connection pool and setup required environment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style="color: navy;"&gt;Here is the code:&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 478.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="638"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 475.5pt;" width="634"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: black;"&gt;&lt;?xml version='1.0'   encoding='utf-8'?&gt;&lt;br /&gt;  &lt;!DOCTYPE hibernate-configuration PUBLIC&lt;br /&gt;  "-//Hibernate/Hibernate Configuration DTD//EN"&lt;br /&gt;  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;hibernate-configuration&gt;&lt;br /&gt;  &lt;session-factory&gt;&lt;br /&gt;        &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;&lt;br /&gt;        &lt;property name="hibernate.connection.url"&gt;&lt;b&gt;jdbc:mysql://localhost/hibernatetutorial&lt;/b&gt;&lt;/property&gt;&lt;br /&gt;        &lt;property name="hibernate.connection.username"&gt;&lt;b&gt;root&lt;/b&gt;&lt;/property&gt;&lt;br /&gt;        &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;&lt;br /&gt;        &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;&lt;br /&gt;        &lt;property name="show_sql"&gt;&lt;b&gt;true&lt;/b&gt;&lt;/property&gt;&lt;br /&gt;        &lt;property name="dialect"&gt;&lt;b&gt;org.hibernate.dialect.MySQLDialect&lt;/b&gt;&lt;/property&gt;&lt;br /&gt;        &lt;property name="hibernate.hbm2ddl.auto"&gt;&lt;b&gt;update&lt;/b&gt;&lt;/property&gt;&lt;br /&gt;        &lt;!-- Mapping files --&gt;&lt;br /&gt;        &lt;mapping resource=""&gt;contact.hbm.xml&lt;/b&gt;"/&gt;&lt;br /&gt;  &lt;/session-factory&gt;&lt;br /&gt;  &lt;/hibernate-configuration&gt;&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In the above configuration file we specified to use the "&lt;b&gt;hibernatetutorial"&lt;/b&gt; which is running on &lt;b&gt;localhost&lt;/b&gt; and the user of the database is root with no password. The &lt;b&gt;dialect&lt;/b&gt; property  is &lt;b&gt;org.hibernate.dialect.MySQLDialect&lt;/b&gt; which tells the Hibernate that we are using MySQL Database. Hibernate supports many database. With the use of the &lt;a href="http://www.hibernate.org/" target="_blank" title="Visit page outside Confluence"&gt;Hibernate&lt;/a&gt; (Object/Relational Mapping and Transparent Object Persistence for Java and SQL Databases),  we can use the following databases dialect type property:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;DB2 - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.DB2Dialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;HypersonicSQL - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.HSQLDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Informix - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.InformixDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Ingres - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.IngresDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Interbase - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.InterbaseDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Pointbase - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.PointbaseDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;PostgreSQL - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Mckoi SQL - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.MckoiDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Microsoft SQL Server - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.SQLServerDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;MySQL - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.MySQLDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Oracle (any version) - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.OracleDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Oracle 9 - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.Oracle9Dialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Progress - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.ProgressDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;FrontBase - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.FrontbaseDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;SAP DB - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.SAPDBDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Sybase - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.SybaseDialect&lt;/span&gt;&lt;/tt&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Sybase Anywhere - &lt;tt&gt;&lt;span style="font-size: 10pt;"&gt;org.hibernate.dialect.SybaseAnywhereDialect&lt;/span&gt;&lt;/tt&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;The &lt;mapping resource=""&gt;contact.hbm.xml&lt;/b&gt;"/&gt; property is the mapping for our contact table. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Writing First Persistence Class&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Hibernate uses the Plain Old Java Objects (POJOs) classes to map to the database table. We can configure the variables to map to the database column. Here is the code for Contact.java:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 391.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="522"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 2.25pt; width: 384pt;" nowrap="nowrap" valign="top" width="512"&gt;   &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;package &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;roseindia.tutorial.hibernate;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@author &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;Deepak Kumar&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* Java Class to map to the datbase Contact Table&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public class &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Contact {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;private &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;String firstName;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;private &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;String lastName;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;private &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;String email;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;private long &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;id;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@return &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;Email&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;String getEmail() {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;return &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;email;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@return &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;First Name&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;String getFirstName() {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;return &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;firstName;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/** &lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@return &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;Last name&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;String getLastName() {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;return &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;lastName;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;string Sets the Email&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public void &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;setEmail(String string) {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;email = string;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;string Sets the First Name&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public void &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;setFirstName(String string) {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;firstName = string;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;string sets the Last Name&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public void &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;setLastName(String string) {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;lastName = string;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@return &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;ID Returns ID&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public long &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;getId() {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;return &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;id;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;l Sets the ID&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;   &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public void &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;setId(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;long &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;l) {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;id = l;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Mapping the Contact Object to the Database Contact table&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;The file contact.hbm.xml is used to map Contact Object to the Contact table in the database. Here is the code for contact.hbm.xml:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 478.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="638"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 475.5pt;" width="634"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: black;"&gt;&lt;?xml   version="1.0"?&gt;&lt;br /&gt;  &lt;!DOCTYPE hibernate-mapping PUBLIC&lt;br /&gt;  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"&lt;br /&gt;  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;hibernate-mapping&gt;&lt;br /&gt;    &lt;class name="roseindia.tutorial.hibernate.Contact" table="CONTACT"&gt;&lt;br /&gt;     &lt;id name="id" type="long" column="ID"&gt;&lt;br /&gt;     &lt;generator class="assigned"&gt;&lt;br /&gt;    &lt;/id&gt;&lt;br /&gt; &lt;br /&gt;    &lt;property name="firstName"&gt;&lt;br /&gt;       &lt;column name="FIRSTNAME"&gt;&lt;br /&gt;    &lt;/property&gt;&lt;br /&gt;    &lt;property name="lastName"&gt;&lt;br /&gt;      &lt;column name="LASTNAME"&gt;&lt;br /&gt;    &lt;/property&gt;&lt;br /&gt;    &lt;property name="email"&gt;&lt;br /&gt;      &lt;column name="EMAIL"&gt;&lt;br /&gt;    &lt;/property&gt;&lt;br /&gt;   &lt;/class&gt;&lt;br /&gt;  &lt;/hibernate-mapping&gt;&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Setting Up MySQL Database&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;In the configuration file(hibernate.cfg.xml) we have specified to use &lt;b&gt;hibernatetutorial&lt;/b&gt; database running on localhost.  So, create the databse ("&lt;b&gt;hibernatetutorial") &lt;/b&gt;on the MySQL server running on localhost. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Developing Code to Test Hibernate example&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Now we are ready to write a program to insert the data into database. We should first understand about the Hibernate's Session. Hibernate Session is the main runtime interface between a Java application and Hibernate. First we are required to get the Hibernate Session.SessionFactory allows application to create the Hibernate Sesssion by reading the configuration from hibernate.cfg.xml file.  Then the save method on session object is used to save the contact information to the database:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;session.save(contact)&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Here is the code of FirstExample.java&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="400"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 2.25pt;" nowrap="nowrap" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;package &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;roseindia.tutorial.hibernate;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;org.hibernate.Session;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;org.hibernate.SessionFactory;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;org.hibernate.cfg.Configuration;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(127, 159, 191);"&gt;@author &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;Deepak Kumar&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* http://www.roseindia.net&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;* Hibernate example to inset data into Contact table&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt; &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public class &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;FirstExample {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;public static void &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;main(String[] args) {&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Session session = &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;;&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;{&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 127, 95);"&gt;// This step will read hibernate.cfg.xml and prepare hibernate for use&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;SessionFactory sessionFactory = &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Configuration().configure().buildSessionFactory();&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;       &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;session =sessionFactory.openSession();&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 127, 95);"&gt;//Create new instance of Contact and set values in it by reading them from form object&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;         &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(42, 0, 255);"&gt;"Inserting Record"&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Contact contact = &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Contact();&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;contact.setId(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(153, 0, 0);"&gt;3&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;contact.setFirstName(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(42, 0, 255);"&gt;"Deepak"&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;contact.setLastName(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(42, 0, 255);"&gt;"Kumar"&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;contact.setEmail(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(42, 0, 255);"&gt;"deepak_38@yahoo.com"&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;session.save(contact);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;        &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(42, 0, 255);"&gt;"Done"&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;(Exception e){&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;System.out.println(e.getMessage());&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(127, 0, 85);"&gt;finally&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;{&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: rgb(63, 127, 95);"&gt;// Actual contact insertion will happen at this step&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;session.flush();&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;session.close();&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;      &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;    &lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: white;"&gt;  &lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;code&gt;&lt;span style="font-size: 10pt; color: black;"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In the next section I will show how to run and test the program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Hibernate is free open source software it can be download from &lt;a href="http://www.hibernate.org/6.html"&gt;http://www.hibernate.org/6.html&lt;/a&gt;. Visit the site and download Hibernate 3.0. You can download the Hibernate and install it yourself. But I have provided very thing in one zip file. Download the example code and library from &lt;a href="http://www.roseindia.net/hibernate/hibernate.zip"&gt;here&lt;/a&gt; and extract the content in your favorite directory say "C:\hibernateexample". Download file contains the Eclipse project. To run the example you should have the Eclipse IDE on your machine. Start the Eclipse project and select Java Project as shown below. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:377.25pt;height:377.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image002.gif" href="http://www.roseindia.net/hibernate/newproj.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image002.gif" shapes="_x0000_i1026" border="0" height="503" width="503" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Click on "Next" button. In the new screen, enter "hibernateexample" as project name and browse the extracted directory "C:\hibernateexample". &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style="'width:375.75pt;height:374.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image003.gif" href="http://www.roseindia.net/hibernate/hibernateexample.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image003.gif" shapes="_x0000_i1027" border="0" height="499" width="501" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Click on "Next" button. In the next screen leave the output folder as default "hibernateexample/bin" .&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style="'width:377.25pt;height:374.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image004.gif" href="http://www.roseindia.net/hibernate/outputfolder.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image004.gif" shapes="_x0000_i1028" border="0" height="499" width="503" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Click on the "Finish" button.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Now Open the FirstExample.java in the editor as show below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1029" type="#_x0000_t75" alt="" style="'width:375pt;height:112.5pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image005.jpg" href="http://www.roseindia.net/hibernate/openexample.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image006.jpg" shapes="_x0000_i1029" border="0" height="150" width="500" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Copy  contact.hbm.xml, and hibernate.cfg.xml in the bin directory of the project using windows explorer. To run the example select Run-&gt; Run As -&gt; Java Application from the menu bar as shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1030" type="#_x0000_t75" alt="" style="'width:344.25pt;height:271.5pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image007.gif" href="http://www.roseindia.net/hibernate/run.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image007.gif" shapes="_x0000_i1030" border="0" height="362" width="459" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;This will run the Hibernate example program in Eclipse following output will displayed on the Eclipse Console.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1031" type="#_x0000_t75" alt="" style="'width:517.5pt;height:117pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\INNOVE~1\LOCALS~1\Temp\msohtml1\01\clip_image008.gif" href="http://www.roseindia.net/hibernate/output.gif"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/INNOVE%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image008.gif" shapes="_x0000_i1031" border="0" height="156" width="690" /&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In this section I showed you how to run the our first Hibernate 3.0 example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;In the last example we created contact.hbm.xml to map Contact Object to the Contact table in the database. Now let's understand the each component of the mapping file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;To recall here is the content of contact.hbm.xml:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 478.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="638"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 475.5pt;" width="634"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: black;"&gt;&lt;?xml   version="1.0"?&gt;&lt;br /&gt;  &lt;!DOCTYPE hibernate-mapping PUBLIC&lt;br /&gt;  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"&lt;br /&gt;  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;hibernate-mapping&gt;&lt;br /&gt;    &lt;class name="roseindia.tutorial.hibernate.Contact" table="CONTACT"&gt;&lt;br /&gt;     &lt;id name="id" type="long" column="ID"&gt;&lt;br /&gt;     &lt;generator class="assigned"&gt;&lt;br /&gt;    &lt;/id&gt;&lt;br /&gt; &lt;br /&gt;    &lt;property name="firstName"&gt;&lt;br /&gt;       &lt;column name="FIRSTNAME"&gt;&lt;br /&gt;    &lt;/property&gt;&lt;br /&gt;    &lt;property name="lastName"&gt;&lt;br /&gt;      &lt;column name="LASTNAME"&gt;&lt;br /&gt;    &lt;/property&gt;&lt;br /&gt;    &lt;property name="email"&gt;&lt;br /&gt;      &lt;column name="EMAIL"&gt;&lt;br /&gt;    &lt;/property&gt;&lt;br /&gt;   &lt;/class&gt;&lt;br /&gt;  &lt;/hibernate-mapping&gt;&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;Hibernate mapping documents are simple xml documents. Here are important elements of the mapping file:.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;hibernate-mapping&gt;      element&lt;/b&gt;&lt;br /&gt;     The first or root element of hibernate mapping document is &lt;hibernate-mapping&gt;      element. Between the &lt;&lt;b&gt;hibernate-mapping&gt;&lt;/b&gt; tag class element(s)      are present.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt; &lt;class&gt;      element&lt;/b&gt;&lt;br /&gt;     The &lt;class&gt; element maps the class object with corresponding entity      in the database. It also tells what table in the database has to access      and what column in that table it should use. Within one      &lt;hibernate-mapping&gt; element, several &lt;class&gt; mappings are      possible.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt; &lt;id&gt;      element&lt;/b&gt;&lt;br /&gt;     The &lt;id&gt; element in unique identifier to identify and object. In      fact &lt;id&gt; element map with the primary key of the table. In our code      :&lt;br /&gt;     &lt;span style="color: blue;"&gt;&lt;id name="id" type="long" column="ID"&gt;&lt;br /&gt;     &lt;/span&gt;primary key maps to the &lt;b&gt;ID&lt;/b&gt; field of the table &lt;b&gt;CONTACT&lt;/b&gt;.      The attributes of the &lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;id&lt;/span&gt; element are: &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;name: &lt;/b&gt;The       property name used by the persistent class. &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;column:&lt;/b&gt; The       column used to store the primary key value. &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;type:&lt;/b&gt; The Java       data type used. &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;unsaved-value:&lt;/b&gt;       This is the value used to determine if a class has been made persistent.       If the value of the id attribute is null, then it means that this object       has not been persisted.&lt;br /&gt;           &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;generator&gt;      element&lt;/b&gt;&lt;br /&gt;     The &lt;b&gt;&lt;generator&gt; &lt;/b&gt;method&lt;b&gt; &lt;/b&gt;is used to generate the primary      key for the new record. Here is some of the commonly used generators :&lt;br /&gt;       &lt;br /&gt;     &lt;b&gt;*&lt;/b&gt; &lt;b&gt;Increment &lt;/b&gt;- This is used to generate primary keys of type      long, short or int that are unique only. It should not be used in the clustered      deployment environment.&lt;br /&gt;       &lt;br /&gt;     &lt;b&gt;*  Sequence&lt;/b&gt; - Hibernate can also use the sequences to generate      the primary key. It can be used with DB2, PostgreSQL, Oracle, SAP DB      databases.&lt;br /&gt;      &lt;br /&gt;     &lt;b&gt;* Assigned&lt;/b&gt; - Assigned method is used when application code      generates the primary key.&lt;br /&gt;       &lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;property&gt;      element&lt;/b&gt;&lt;br /&gt;     The &lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;property&lt;/span&gt; elements define standard Java attributes      and their mapping into database schema. The &lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;property&lt;/span&gt;      element supports the &lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;column&lt;/span&gt; child element to specify      additional properties, such as the index name on a column or a specific      column type. &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In this lesson you will learn about hibernate &lt;generator&gt; method in detail. Hibernate generator element generates the primary key for new record. There are many options provided by the generator method to be used in different situations. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;The &lt;generator&gt; element&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;This is the optional element under &lt;id&gt; element. The &lt;generator&gt; element is used to specify the class name to be used to generate the primary key for new record while saving a new record. The &lt;param&gt; element is used to pass the parameter (s) to the  class. Here is the example of generator element from our first application:&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: blue;"&gt;&lt;generator class="assigned"&gt;&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;In this case &lt;generator&gt; element do not generate the primary key and it is required to set the primary key value before calling save() method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Here are the list of some commonly used generators in hibernate: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 50%; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; background: rgb(255, 255, 153) none repeat scroll 0% 50%; width: 16%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Generator&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; background: rgb(255, 255, 153) none repeat scroll 0% 50%; width: 84%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Description&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;increment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;It generates identifiers of type   long, short or int that are unique only when no other process is inserting   data into the same table. It should not the used in the clustered   environment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;identity&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;It supports identity columns in   DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier   is of type long, short or int.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;sequence&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;The sequence generator uses a   sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in   Interbase. The returned identifier is of type long, short or int&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;st1:city&gt;&lt;st1:place&gt;&lt;span style="color: navy;"&gt;hilo&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;The &lt;/span&gt;&lt;st1:city&gt;&lt;st1:place&gt;&lt;span style="color: navy;"&gt;hilo&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;span style="color: navy;"&gt; generator uses a hi/lo algorithm to efficiently generate   identifiers of type long, short or int, given a table and column (by default   hibernate_unique_key and next_hi respectively) as a source of hi values. The   hi/lo algorithm generates identifiers that are unique only for a particular   database. Do not use this generator with connections enlisted with JTA or   with a user-supplied connection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;seqhilo&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;The seqhilo generator uses a   hi/lo algorithm to efficiently generate identifiers of type long, short or   int, given a named database sequence.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;uuid&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;The uuid generator uses a 128-bit   UUID algorithm to generate identifiers of type string, unique within a   network (the IP address is used). The UUID is encoded as a string of   hexadecimal digits of length 32.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;guid&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;It uses a database-generated GUID   string on MS SQL Server and MySQL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;native&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;It picks identity, sequence or &lt;/span&gt;&lt;st1:city&gt;&lt;st1:place&gt;&lt;span style="color: navy;"&gt;hilo&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;span style="color: navy;"&gt; depending upon the capabilities of the underlying   database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;assigned&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;lets the application to assign an   identifier to the object before save() is called. This is the default   strategy if no &lt;generator&gt; element is specified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;select&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;retrieves a primary key assigned   by a database trigger by selecting the row by some unique key and retrieving   the primary key value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 16%;" width="16%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;foreign&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in; width: 84%;" width="84%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;uses the identifier of another   associated object. Usually used in conjunction with a &lt;one-to-one&gt;   primary key association.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;As we have seen in the last section that the increment class generates identifiers of type long, short or int that are unique only when no other process is inserting data into the same table. In this lesson I will show you how to write running program to demonstrate it. You should not use this method to generate the primary key in case of clustured environment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;In this we will create a new table in database, add mappings in the contact.hbm.xml file, develop the POJO class (Book.java), write the program to test it out.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Create Table in the mysql database:&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;User the following sql statement to create a new table in the database.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt; CREATE TABLE `book` (&lt;br /&gt;`id` int(11) NOT NULL default '0',&lt;br /&gt;`bookname` varchar(50) default NULL,&lt;br /&gt;PRIMARY KEY (`id`)&lt;br /&gt;) TYPE=MyISAM &lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Developing POJO Class (Book.java)&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Book.java is our POJO class which is to be persisted to the database table "book". &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 2.25pt;" nowrap="nowrap" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@author &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;Deepak Kumar&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* http://www.roseindia.net&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* Java Class to map to the database Book table&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;package &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;roseindia.tutorial.hibernate;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public class &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Book {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;private long &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;lngBookId;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;private &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;String strBookName;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@return &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;Returns the lngBookId.&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public long &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;getLngBookId() {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;return &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;lngBookId;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;lngBookId The lngBookId to set.&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public void &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;setLngBookId(&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;long &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;lngBookId) {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;.lngBookId = lngBookId;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@return &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;Returns the strBookName.&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;String getStrBookName() {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;return &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;strBookName;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;strBookName The strBookName to set.&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public void &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;setStrBookName(String strBookName) {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;.strBookName = strBookName;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Adding Mapping entries to contact.hbm.xml&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Add the following mapping code into the contact.hbm.xml file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="80%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 100%;" width="100%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--&gt;   &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;   &lt;/script&gt;&lt;class name="roseindia.tutorial.hibernate.Book" table="book"&gt;&lt;br /&gt;       &lt;id name="lngBookId" type="long" column="id"&gt;&lt;br /&gt;          &lt;b&gt;&lt;generator class="increment"&gt;&lt;br /&gt;  &lt;/b&gt;     &lt;/id&gt;&lt;br /&gt; &lt;br /&gt;      &lt;property name="strBookName"&gt;&lt;br /&gt;           &lt;column name="bookname"&gt;&lt;br /&gt;       &lt;/property&gt;&lt;br /&gt;  &lt;/class&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt; Note that we have used &lt;b&gt;increment&lt;/b&gt; for the generator class. *&lt;/span&gt;&lt;span style="font-size: 10pt; color: navy;"&gt;After adding the entries to the xml file copy it to the bin directory of your hibernate eclipse project(this step is required if you are using eclipse).&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Write the client program and test it out&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Here is the code of our client program to test the application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 2.25pt;" nowrap="nowrap" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@author &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;Deepak Kumar&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* http://www.roseindia.net&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* Example to show the increment class of hibernate generator element to &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* automatically generate the primay key&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;package &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;roseindia.tutorial.hibernate;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;//Hibernate Imports&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.Session;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.SessionFactory;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.cfg.Configuration;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public class &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;IdIncrementExample {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public static void &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;main(String[] args) {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Session session = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;// This step will read hibernate.cfg.xml and prepare hibernate for use&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;SessionFactory sessionFactory = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Configuration().configure().buildSessionFactory();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;session =sessionFactory.openSession();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.Transaction tx = session.beginTransaction();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;//Create new instance of Contact and set values in it by reading them from form object&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Inserting Book object into database.."&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Book book = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Book();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;book.setStrBookName(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Hibernate Tutorial"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;session.save(book);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Book object persisted to the database."&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;          &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;tx.commit();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;          &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;session.flush();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;          &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;session.close();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;(Exception e){&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(e.getMessage());&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;finally&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;To test the program Select Run-&gt;Run As -&gt; Java Application from the eclipse menu bar. This will create a new record into the book table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;In this tutorial we will show how to update a row with new information by retrieving data from the underlying database using the hibernate. Lets first write a java class to update a row to the database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Create a java class:&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;Here is the code of our java file (&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;UpdateExample&lt;/span&gt;&lt;span style="color: navy;"&gt;.java), where we will update a field name "&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;InsuranceName"&lt;/span&gt;&lt;span style="color: navy;"&gt; with a value="&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;Jivan Dhara&lt;/span&gt;&lt;span style="color: navy;"&gt;" from a row of the insurance table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Here is the code of delete query: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;UpdateExample .java &lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 2.25pt;" nowrap="nowrap" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;package &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;roseindia.tutorial.hibernate;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;java.util.Date;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.Session;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.SessionFactory;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.Transaction;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.cfg.Configuration;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public class &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;UpdateExample {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@param &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;args&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public static void &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;main(String[] args) {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;// TODO Auto-generated method stub&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Session sess = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;try &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;SessionFactory fact = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Configuration().configure().buildSessionFactory();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;sess = fact.openSession();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Transaction tr = sess.beginTransaction();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Insurance ins = (Insurance)sess.get(Insurance.class, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Long(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(153, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;));&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;ins.setInsuranceName(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Jivan Dhara"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;ins.setInvestementAmount(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(153, 0, 0);"&gt;20000&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;ins.setInvestementDate(&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Date());&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;sess.update(ins);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;tr.commit();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;sess.close();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Update successfully!"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;(Exception e){&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(e.getMessage());&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;&lt;a href="http://www.roseindia.net/hibernate/UpdateExample.java"&gt;Download this code.&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Output:&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="width: 71%;" border="1" cellpadding="0" width="71%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt; width: 100%;" width="100%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; color: red;"&gt;log4j:WARN No   appenders could be found for logger (org.hibernate.cfg.Environment). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; color: red;"&gt;log4j:WARN Please initialize the log4j   system properly.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Hibernate: select insurance0_.ID as   ID0_0_, insurance0_.insurance_name as insurance2_0_0_,   insurance0_.invested_amount as invested3_0_0_, insurance0_.investement_date   as investem4_0_0_ from insurance insurance0_ where insurance0_.ID=?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Hibernate: update insurance set   insurance_name=?, invested_amount=?, investement_date=? where ID=?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; color: black;"&gt;Update successfully!&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;Hibernate Query Language or HQL for short is extremely powerful query language. HQL is much like SQL  and are case-insensitive, except for the names of the Java Classes and properties. Hibernate Query Language is used to execute queries against database. Hibernate automatically generates the sql query and execute it against underlying database if HQL is used in the application. HQL is based on the relational object models and makes the SQL object oriented. Hibernate Query Language uses Classes and properties instead of tables and columns. Hibernate Query Language is extremely powerful and it supports Polymorphism, Associations, Much less verbose than SQL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;There are other options that can be used while using Hibernate. These are &lt;b&gt;Query By Criteria (QBC)&lt;/b&gt; and &lt;b&gt;Query BY Example (QBE) &lt;/b&gt;using Criteria API and the &lt;b&gt;Native SQL&lt;/b&gt; queries. In this lesson we will understand HQL in detail. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Why to use HQL?&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;Full support for      relational operations: &lt;/b&gt;HQL allows representing SQL queries in the form      of objects. Hibernate Query Language uses Classes and properties instead      of tables and columns.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;Return result as      Object: &lt;/b&gt;The HQL queries return the query result(s) in the form of      object(s), which is easy to use. This elemenates the need of creating the      object and populate the data from result set.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;Polymorphic Queries:&lt;/b&gt;      HQL fully supports &lt;b&gt;polymorphic queries&lt;/b&gt;. Polymorphic queries results      the query results along with all the child objects if any.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;Easy to Learn:&lt;/b&gt;      Hibernate Queries are easy to learn and it can be easily implemented in      the applications.&lt;br /&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;Support for Advance      features:&lt;/b&gt; HQL contains many advance features such as pagination, fetch      join with dynamic profiling, Inner/outer/full joins, Cartesian products.      It also supports Projection, Aggregation (max, avg) and grouping,      Ordering, Sub queries and SQL function calls.&lt;br /&gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;Database independent:&lt;/b&gt;      Queries written in HQL are database independent (If database supports the      underlying feature). &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Understanding HQL Syntax&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;Any Hibernate Query Language may consist of following elements:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Clauses &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Aggregate functions &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;Subqueries &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Clauses in the HQL are:&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hibernatefromclauseexample.shtml"&gt;from&lt;/a&gt;&lt;/b&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/selectclause.shtml"&gt;select&lt;/a&gt;&lt;/b&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hqlwhereclauseexample.shtml"&gt;where&lt;/a&gt;&lt;/b&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hibernateorderbyexample.shtml"&gt;order      by&lt;/a&gt;&lt;/b&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/groupbyclauseexample.shtml"&gt;group      by&lt;/a&gt;&lt;/b&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Aggregate functions are:&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hibernate-avg.shtml"&gt;avg(...)&lt;/a&gt;&lt;/b&gt;,      &lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/groupbyclauseexample.shtml"&gt;sum(...)&lt;/a&gt;&lt;/b&gt;,      &lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hibernate-min.shtml"&gt;min(...)&lt;/a&gt;&lt;/b&gt;,      &lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hibernate-max.shtml"&gt;max(...)&lt;/a&gt;&lt;/b&gt;       &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;&lt;b&gt;&lt;a href="http://www.roseindia.net/hibernate/hibernate-count.shtml"&gt;count(*)&lt;/a&gt;&lt;/b&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: navy;"&gt;count(...),      count(distinct ...), count(all...) &lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;Subqueries&lt;/span&gt;&lt;/b&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;Subqueries are nothing but its a query within another query. Hibernate supports Subqueries if the underlying database supports it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;In this lesson we will create insurance table and populate it with the data. We will use insurance table for rest of the HQL tutorial.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: navy;"&gt;To create the insurance table and insert the sample data, run the following sql query:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="color: navy;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 50%; width: 74%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="74%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 100%;" width="100%"&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;/*Table structure for table `insurance` */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;drop table if exists `insurance`;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;CREATE TABLE `insurance` (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;span style=""&gt;  &lt;/span&gt;`ID` int(11) NOT NULL default '0',&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;span style=""&gt;  &lt;/span&gt;`insurance_name` varchar(50) default NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;span style=""&gt;  &lt;/span&gt;`invested_amount` int(11) default NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;span style=""&gt;  &lt;/span&gt;`investement_date` datetime default NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;span style=""&gt;  &lt;/span&gt;PRIMARY KEY&lt;span style=""&gt;  &lt;/span&gt;(`ID`)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;) TYPE=MyISAM;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;/*Data for the table `insurance` */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (1,'Car Insurance',1000,'2005-01-05 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (2,'Life Insurance',100,'2005-10-01 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (3,'Life Insurance',500,'2005-10-15 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (4,'Car Insurance',2500,'2005-01-01 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (5,'Dental Insurance',500,'2004-01-01 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (6,'Life Insurance',900,'2003-01-01 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (7,'Travel Insurance',2000,'2005-02-02 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (8,'Travel Insurance',600,'2005-03-03 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (9,'Medical Insurance',700,'2005-04-04 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (10,'Medical Insurance',900,'2005-03-03 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (11,'Home Insurance',800,'2005-02-02 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (12,'Home Insurance',750,'2004-09-09 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (13,'Motorcycle Insurance',900,'2004-06-06 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: navy;"&gt;insert into `insurance` values (14,'Motorcycle Insurance',780,'2005-03-03 &lt;/span&gt;&lt;st1:time minute="0" hour="0"&gt;&lt;span style="color: navy;"&gt;00:00:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="color: navy;"&gt;');&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;In this lesson we will write example code to select the data from Insurance table using Hibernate Select Clause. The select clause picks up objects and properties to return in the query result set. Here is the query:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: blue;"&gt;Select insurance.lngInsuranceId, insurance.insuranceName, insurance.investementAmount, insurance.investementDate from Insurance insurance&lt;/span&gt;&lt;span style="color: navy;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;which selects all the rows (&lt;b&gt;insurance.lngInsuranceId, insurance.insuranceName, insurance.investementAmount, insurance.investementDate&lt;/b&gt;) from Insurance table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: navy;"&gt;Hibernate generates the necessary sql query and selects all the records from Insurance table. Here is the code of our java file which shows how select HQL can be used:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 2.25pt;" nowrap="nowrap" valign="top"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;package &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;roseindia.tutorial.hibernate;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.Session;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.*;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;org.hibernate.cfg.*;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;import &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;java.util.*;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;/**&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 159, 191);"&gt;@author &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;Deepak Kumar&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* http://www.roseindia.net&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;* HQL Select Clause Example&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 95, 191);"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public class &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;SelectClauseExample {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public static void &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;main(String[] args) {&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Session session = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt; &lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;try&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;// This step will read hibernate.cfg.xml and prepare hibernate for use&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;SessionFactory sessionFactory = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Configuration().configure()&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;.buildSessionFactory();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;session =sessionFactory.openSession();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;//Create Select Clause HQL&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;String SQL_QUERY =&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Select insurance.lngInsuranceId,insurance.insuranceName," &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;+ &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"insurance.investementAmount,insurance.investementDate from Insurance insurance"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Query query = session.createQuery(SQL_QUERY);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;(Iterator it=query.iterate();it.hasNext();){&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;Object[] row = (Object[]) it.next();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"ID: " &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;+ row[&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(153, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;]);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Name: " &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;+ row[&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(153, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;]);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;       &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"Amount: " &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;+ row[&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(153, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;]);&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;     &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;        &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;session.close();&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;catch&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;(Exception e){&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;System.out.println(e.getMessage());&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;finally&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;    &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: white;"&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;span style="color: navy;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;b&gt;&lt;span style="color: navy;"&gt;http://www.roseindia.net/hibernate/index.shtml&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-4717697897559760889?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/4717697897559760889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=4717697897559760889' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4717697897559760889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4717697897559760889'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/09/hibernate.html' title='Hibernate'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-2933723811382794874</id><published>2007-08-20T00:54:00.000-07:00</published><updated>2009-06-13T05:40:01.051-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP 1.5 Mocks'/><title type='text'>SCJP 1.5 Mocks</title><content type='html'>&lt;p&gt; &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a target="_blank" href="http://enigma.vm.bytemark.co.uk/webstart.html"&gt;John Meyer's SCJP  1.5 exam&lt;/a&gt; with GUI support for drag and drops.  &lt;/li&gt;&lt;li&gt;&lt;a target="_blank" href="http://www.whizlabs.com/scjp/scjp-5.0-details.html"&gt;WhizLabs SCJP  Preparation Kit&lt;/a&gt; with free sample exam  &lt;/li&gt;&lt;li&gt;EPractize Labs free demo: &lt;a target="_blank" href="http://www.epractizelabs.com/scjp-exam-5-prepkit.html"&gt;25 questions&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;ENTHUWARE's JQPlus V5 - 11 Tests - Most Advanced Java Based Simulator - &lt;a target="_blank" href="http://www.enthuware.com/jqplus/index.html"&gt;Free Sample Exam&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;eXamulator: &lt;a target="_blank" href="http://www.examulator.com/phezam/login.php"&gt;62  questions in total&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;eJavaGuru.com's &lt;a target="_blank" href="http://www.ejavaguru.com/scjp5freemockexam.php"&gt;quiz on Enums&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;&lt;a target="_blank" href="http://www.javablackbelt.com/QuestDefListing.wwa"&gt;JavaBlackBelt.com&lt;/a&gt;   &lt;/li&gt;&lt;li&gt;&lt;a target="_blank" href="http://www.examulator.com/phezam/login.php"&gt;Marcus Green's 1.5  exam&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;&lt;a target="_blank" href="http://www.ucertify.com/vendors/Sun.html"&gt;uCertify Java Preparation  Kits&lt;/a&gt; with free Practice Test and Study Notes, Article and How Tos.  &lt;/li&gt;&lt;li&gt;&lt;a target="_blank" href="http://www.blogger.com/java/Cafe4Java"&gt;Cafe4Java&lt;/a&gt;'s Collection of &lt;a target="_blank" href="http://cafe4java.com/mockexams/mockexamlist.php"&gt;free SCJP 5.0 exam  questions&lt;/a&gt;, arranged by (sub)objectives like collections, file I/O etc&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-2933723811382794874?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/2933723811382794874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=2933723811382794874' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2933723811382794874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/2933723811382794874'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/08/scjp-15-mocks.html' title='SCJP 1.5 Mocks'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-7553055044499919821</id><published>2007-08-07T22:09:00.000-07:00</published><updated>2009-06-13T05:40:01.052-07:00</updated><title type='text'>SCJP Mock Exams</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;a href="http://www.akgupta.com/Java/mock_exam.htm" target="_blank"&gt;http://www.akgupta.com/Java/mock_exam.htm&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a target="_blank" href="http://java.about.com/gi/dynamic/offsite.htm?zi=1/XJ&amp;sdn=java&amp;amp;amp;amp;amp;amp;amp;cdn=compute&amp;tm=15&amp;amp;gps=142_240_1020_521&amp;f=00&amp;amp;su=p284.8.150.ip_&amp;tt=3&amp;amp;bt=0&amp;bts=0&amp;amp;zu=http%3A//www.jdiscuss.com/index.html"&gt;http://java.about.com/gi/dynamic/offsite.htm&lt;/a&gt;  &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a target="_blank" href="http://java.about.com/gi/dynamic/offsite.htm?zi=1/XJ&amp;sdn=java&amp;amp;amp;amp;amp;amp;amp;cdn=compute&amp;tm=30&amp;amp;gps=148_408_1020_521&amp;f=00&amp;amp;su=p284.8.150.ip_&amp;tt=3&amp;amp;bt=0&amp;bts=0&amp;amp;zu=http%3A//www.javaprepare.com/quests/test.html"&gt;http://java.about.com/gi/dynamic/offsite.htm &lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a target="_blank" href="http://www.javacertificate.net/scjp_1.htm"&gt;http://www.javacertificate.net/scjp_1.htm&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;   &lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a target="_blank" href="http://www.javaprepare.com/quests/test.html"&gt;http://www.javaprepare.com/quests/test.html&lt;/a&gt;&lt;br /&gt;&lt;/div&gt; &lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;a target="_blank" href="http://www.javaranch.com/maha/_Mock_Exams/_mock_exams.html"&gt;http://www.javaranch.com/maha/_Mock_Exams/_mock_exams.html&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://www.javacertificationexams.com/scjp-mock-exams.php"&gt;http://www.javacertificationexams.com/scjp-mock-exams.php&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-7553055044499919821?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/7553055044499919821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=7553055044499919821' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7553055044499919821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/7553055044499919821'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/08/scjp-mock-exams.html' title='SCJP Mock Exams'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-452902570914363294</id><published>2007-08-01T23:59:00.000-07:00</published><updated>2009-06-13T05:40:01.052-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rm'/><category scheme='http://www.blogger.com/atom/ns#' term='pwd'/><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='wc'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='rmdir'/><category scheme='http://www.blogger.com/atom/ns#' term='cd'/><category scheme='http://www.blogger.com/atom/ns#' term='mkdir'/><category scheme='http://www.blogger.com/atom/ns#' term='cp'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><category scheme='http://www.blogger.com/atom/ns#' term='ls'/><category scheme='http://www.blogger.com/atom/ns#' term='la'/><title type='text'>Linux Files and Directories</title><content type='html'>&lt;h3&gt;&lt;a name="Display_name_of_current_directory"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;  &lt;h3&gt;&lt;span style=""&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;pwd - Display name of current directory&lt;/span&gt;&lt;/span&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;span style="font-family: Arial;"&gt; &lt;/span&gt;&lt;/h3&gt;  &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;b&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;pwd&lt;/span&gt;&lt;/b&gt; is used to display the full path name of the current directory.&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="width: 100%;" border="0" cellpadding="0" cellspacing="0" width="100%"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in; width: 100%;" valign="top" width="100%"&gt;   &lt;h3&gt;&lt;a name="Switch_to_another_directory"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;cd - Switch to another directory&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p class="style4"&gt;&lt;span style="font-family: Arial;"&gt;To switch to another   directory, the command &lt;b&gt;cd&lt;/b&gt; is used.&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 55%;" border="1" cellpadding="0" cellspacing="0" width="55%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 20%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Examples&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="80%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" width="20%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cd&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will     place you in your &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;home directory&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" width="20%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cd /&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will     move you to the &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;root directory&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" width="20%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cd /etc&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will     move you to the&lt;strong&gt;&lt;span style="font-family: Arial;"&gt; /etc directory&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" width="20%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cd ../&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will     move you &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;back one directory&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="Create/Delete_directories"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;mkdir and rmdir - Create/Delete directories&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;b&gt;mkdir&lt;/b&gt;   is used to create a new directory.&lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;b&gt;rmdir&lt;/b&gt;   or &lt;b&gt;rm -r&lt;/b&gt; is used to delete a directory or directories. &lt;span style="color: red;"&gt;Be careful in testing the following delete commands. You   will probably want to create sample directories first.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 75%;" border="1" cellpadding="0" cellspacing="0" width="75%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 34%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="34%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Examples&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 66%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="66%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 34%;" valign="top" width="34%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;mkdir mydirectory&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 66%;" valign="top" width="66%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;create a new directory&lt;/span&gt;&lt;/strong&gt; named     'mydirectory'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 34%;" valign="top" width="34%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;rmdir existingdirectory&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 66%;" valign="top" width="66%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;delete&lt;/span&gt;&lt;/strong&gt; the existing directory     named 'existingdirectory'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 34%;" valign="top" width="34%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;rm -r existingdirectories&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 66%;" valign="top" width="66%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Will &lt;b&gt;delete&lt;/b&gt;     the existing directory named 'existingdirectories' and all directories and     files below it.&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="List_the_Contents_of_a_directory"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;ls - List the Contents of a directory&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;b&gt;ls&lt;/b&gt; is   used to the contents of a directory.&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 75%;" border="1" cellpadding="0" cellspacing="0" width="75%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 20%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Options&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="80%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-l&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;long     listing&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-R&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     current directory and all other directories within current directory&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style="height: 12.75pt;"&gt;     &lt;td style="padding: 0in; width: 20%; height: 12.75pt;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-a&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%; height: 12.75pt;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     hidden files&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style="height: 12.75pt;"&gt;     &lt;td style="padding: 0in; width: 20%; height: 12.75pt;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-CF&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%; height: 12.75pt;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list in     column format and append '*' to executable files, '@' to symbolic linked     files, '/' to directories&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style="height: 12.75pt;"&gt;     &lt;td style="padding: 0in; width: 20%; height: 12.75pt;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-r&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%; height: 12.75pt;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list in     reverse alphabetically order&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style="height: 12.75pt;"&gt;     &lt;td style="padding: 0in; width: 20%; height: 12.75pt;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-t&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%; height: 12.75pt;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     more recent accessed files first&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style="height: 12.75pt;"&gt;     &lt;td style="padding: 0in; width: 20%; height: 12.75pt;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;filename(s)&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%; height: 12.75pt;" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Values     to match&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="display: none;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 75%;" border="1" cellpadding="0" cellspacing="0" width="75%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;     &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Examples&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;     &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;ls&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;only     list file/directory names in current directory&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;ls -l&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     all file/directory information in current directory(long version)&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;ls -R&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     all files in current directories and below&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;ls -lt&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     all files, sorted by most recent accessed first&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;ls -lt /etc/rc*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in;"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;list     files in the '/etc/ directory, only starting with 'rc' and sort results by     most recent&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="Wildcards"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;Wildcards&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Wildcard characters are   used to help find file or directory names&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 75%;" border="1" cellpadding="0" cellspacing="0" width="75%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 20%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Options&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="80%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" valign="top" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;*&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" valign="top" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;asterisk     symbol is used to represent &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;any&lt;/span&gt;&lt;/strong&gt;     character(s)&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" valign="top" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;?&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" valign="top" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;question     mark is used to represent any &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;single&lt;/span&gt;&lt;/strong&gt;     character&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" valign="top" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;[from-to ]&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" valign="top" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Values     entered within square brackets represent a &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;range&lt;/span&gt;&lt;/strong&gt; (from-to) for a single character&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 20%;" valign="top" width="20%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;[!from-to ]&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 80%;" valign="top" width="80%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Values     entered within square brackets represent a &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;range&lt;/span&gt;&lt;/strong&gt; (from-to) to &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;exclude&lt;/span&gt;&lt;/strong&gt; for a single character&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="display: none;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 89%;" border="1" cellpadding="0" cellspacing="0" width="89%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 15%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Examples&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 85%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="85%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;a*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files starting with the letter 'a'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;*z&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files where the last character is a 'z'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;a*m&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files that start with the letter 'a' and end with 'm'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;th??&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files that start with 'th' and are only four characters long&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;[a-c]*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files that start with 'a, b or c'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;x[A-C]*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files that start with the letter 'x' and the second character contains 'A,     B or C'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 15%;" width="15%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;[!M-O]*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 85%;" width="85%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;all     files except those that start with 'M, N or O'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="Copy_files"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;cp -   Copy files&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;To copy a file, the   command &lt;b&gt;cp&lt;/b&gt; is used&lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;em&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Example:&lt;/span&gt;&lt;/em&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;cp   oldfile myfile&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; - Will copy the existing file 'oldfile' to a new file   'myfile'&lt;/span&gt;&lt;/p&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="Rename_files"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;mv -   Rename files&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;b&gt;mv&lt;/b&gt; is   used to rename a file&lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;em&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Example:&lt;/span&gt;&lt;/em&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;mv   myfile yourfile&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;- Will rename the file 'myfile' to 'yourfile'&lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="Delete_files"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;rm -   Delete files&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 75%;" border="1" cellpadding="0" cellspacing="0" width="75%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 18%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="18%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Examples&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 82%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="82%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 18%;" valign="top" width="18%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;rm myfile&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 82%;" valign="top" width="82%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;remove     the file 'myfile'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 18%;" valign="top" width="18%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;rm -i abc*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 82%;" valign="top" width="82%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;prompt     to remove each file in current directory starting with 'abc'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 18%;" valign="top" width="18%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;rm abc*&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 82%;" valign="top" width="82%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;remove     all files in current directory starting with 'abc' automatically&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;   &lt;hr align="center" size="2" width="100%"&gt;   &lt;/div&gt;   &lt;h3&gt;&lt;a name="Count_the_number_of_lines_or_characters"&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;wc - Count the number of lines or characters&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;   &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;b&gt;wc&lt;/b&gt; is   used to count lines, words or characters in a file or piped results from   another command. &lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 38%;" border="1" cellpadding="0" cellspacing="0" width="38%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 28%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="28%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Options&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 72%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="72%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 28%;" width="28%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-c&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 72%;" width="72%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Number     of characters&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 28%;" width="28%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-w&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 72%;" width="72%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Number     of words&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style="height: 12.75pt;"&gt;     &lt;td style="padding: 0in; width: 28%; height: 12.75pt;" width="28%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-l&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 72%; height: 12.75pt;" width="72%"&gt;     &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 28%;" width="28%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;filename&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 72%;" width="72%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;file     name(s) to use&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="display: none;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="width: 88%;" border="1" cellpadding="0" cellspacing="0" width="88%"&gt;    &lt;tbody&gt;&lt;tr style=""&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 24%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="24%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;Examples&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; background: rgb(0, 51, 153) none repeat scroll 0% 50%; width: 76%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="76%"&gt;     &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: white;"&gt;What it does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 24%;" valign="top" width="24%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;wc /etc/sendmail.cf&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 76%;" valign="top" width="76%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Lists     the number of lines, words and characters in the file 'sendmail.cf'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;    &lt;tr style=""&gt;     &lt;td style="padding: 0in; width: 24%;" valign="top" width="24%"&gt;     &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;ls /etc | wc -l&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;     &lt;/td&gt;     &lt;td style="padding: 0in; width: 76%;" valign="top" width="76%"&gt;     &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Lists     the number of files and directories in the directory 'etc'&lt;/span&gt;&lt;/p&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt;   &lt;p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;h3&gt;&lt;a name="file"&gt;&lt;/a&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;file - Display Type-of-File Description&lt;/span&gt;&lt;/h3&gt;  &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Files can consist of several types. The command file is used to display a description for the type.&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Example:&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; &lt;strong&gt;&lt;span style="font-family: Arial; color: rgb(0, 102, 0);"&gt;file a*&lt;/span&gt;&lt;/strong&gt; will list all files in the current directory that start with the letter "a" and provide a description for the file type.&lt;/span&gt;&lt;/p&gt;  &lt;div class="MsoNormal" style="text-align: center;" align="center"&gt;  &lt;hr align="center" size="2" width="100%"&gt;  &lt;/div&gt;  &lt;h3&gt;&lt;a name="cat"&gt;&lt;/a&gt;&lt;span style="font-family: Arial; color: rgb(0, 51, 153);"&gt;cat - concatenate files&lt;/span&gt;&lt;/h3&gt;  &lt;p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The command &lt;strong&gt;&lt;span style="font-family: Arial;"&gt;cat&lt;/span&gt;&lt;/strong&gt; is a multi-purpose utility and is mostly used with TEXT files.&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Create a &lt;b&gt;new file&lt;/b&gt; and optionally allow the &lt;b&gt;manual      entry of contents&lt;/b&gt;&lt;/span&gt; &lt;/li&gt;&lt;ul type="circle"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cat       &gt;[filename]&lt;/span&gt;&lt;/b&gt; &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Example: &lt;strong&gt;&lt;span style="font-family: Arial; color: rgb(0, 102, 0);"&gt;cat &gt;myfile&lt;/span&gt;&lt;/strong&gt;       will create a file named myfile and allow you to enter contents. &lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Press &lt;b&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Control-D&lt;/span&gt; to exit&lt;/b&gt; entry mode. &lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: red;"&gt;WARNING: If       "myfile" already existed, this command would replace the old       file with the contents of the new file. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Combine text files&lt;/span&gt;&lt;/b&gt; &lt;/li&gt;&lt;ul type="circle"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cat file1 file2       &gt;newfile - &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;This       will combine &lt;span style="color: rgb(0, 51, 153);"&gt;file1&lt;/span&gt; and &lt;span style="color: rgb(0, 51, 153);"&gt;file2&lt;/span&gt; into &lt;span style="color: rgb(0, 51, 153);"&gt;newfile&lt;/span&gt;.&lt;/span&gt;       &lt;/li&gt;&lt;/ul&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Dissplay the contents&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; of a file&lt;/span&gt; &lt;/li&gt;&lt;ul type="circle"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cat myfile&lt;/span&gt;&lt;/b&gt;       &lt;/li&gt;&lt;/ul&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Delete the contents&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; of a file&lt;/span&gt; &lt;/li&gt;&lt;ul type="circle"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 102, 0);"&gt;cat /dev/null       &gt;myfile&lt;/span&gt;&lt;/b&gt; &lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-452902570914363294?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/452902570914363294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=452902570914363294' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/452902570914363294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/452902570914363294'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/08/linux-files-and-directories.html' title='Linux Files and Directories'/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5334619773603269475.post-4920698205837224725</id><published>2007-07-21T21:38:00.000-07:00</published><updated>2009-06-13T05:39:19.930-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='learn java online'/><title type='text'></title><content type='html'>Starting point for Sun's Java technology certification.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.enterprisedeveloper.com/jcertify/"&gt;JCertify&lt;/a&gt; - http://www.enterprisedeveloper.com/jcertify/ Java Certification exam simulator with tutorials and integrated training content. [Commercial]&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.whizlabs.com/jwhiz.html"&gt;Whizlabs&lt;/a&gt; - http://www.whizlabs.com/jwhiz.html Provides exam simulators and online training for Sun Java Certification exams: SCJP, SCWCD, SCBCD and SCEA [Commercial].&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.levteck.com/"&gt;Levteck.com&lt;/a&gt; - http://www.levteck.com/ Includes list of certification books, study aides, links for mock exams and salary surveys.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www-106.ibm.com/developerworks/edu/j-dw-java-scjp-i.html"&gt;Java certification success, Part 1: SCJP&lt;/a&gt; - http://www-106.ibm.com/developerworks/edu/j-dw-java-scjp-i.html A tutorial designed to prepare programmers for SCJP 1.4 exam, providing a detailed overview of the exam's main objectives.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.jchq.net/"&gt;Marcus Green's Java Certification&lt;/a&gt; - http://www.jchq.net/ SCJP exam resource with tutorials, mock exam and community features.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/wahjava/"&gt;Wah! Java&lt;/a&gt; - http://www.geocities.com/wahjava/ Contains topic-wise mock tests, tips from those who passed, recommended books and links to other testing/java resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javaprepare.com/"&gt;JavaPrepare&lt;/a&gt; - http://www.javaprepare.com/ Tutorials, mock exams and other preparation material for SCJP and SCWCD.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://groups.yahoo.com/group/javacertstudy/"&gt;Java Certification Study Group&lt;/a&gt; - http://groups.yahoo.com/group/javacertstudy/ Study community with forums, chat and resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://resources.corejsp.com/scwcd.html"&gt;SCWCD Certification Resources&lt;/a&gt; - http://resources.corejsp.com/scwcd.html Contains links to study guides, exam simulators and other resources for SCWCD examination.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://courses.coreservlets.com/Course-Materials/pdf/msajsp/15-Web-Component-Certification.pdf"&gt;SCWCD Exam Review&lt;/a&gt; - http://courses.coreservlets.com/Course-Materials/pdf/msajsp/15-Web-Component-Certification.pdf Review notes for the Sun Certified Web Component Developer exam.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.danchisholm.net/"&gt;Certified Java Programmer Mock Exam (310-025, 310-035)&lt;/a&gt; - http://www.danchisholm.net/ Contains mock exams and tutorials for SCJP exam.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.absolutejava.com/"&gt;Absolute Java&lt;/a&gt; - http://www.absolutejava.com/ Collection of tidbits to prepare for SCJP exam.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.jiris.com/"&gt;Jiris&lt;/a&gt; - http://www.jiris.com/ Contains mock exams, links, forum, code examples and other SCJP/SCWCD resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javacertificate.com/"&gt;JavaCertificate&lt;/a&gt; - http://www.javacertificate.com/ A free online training centre that will help prepare for the Sun Certified Programmer for Java(tm) 2 Platform exam (SCJP 1.4).&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.anilbachi.8m.com/"&gt;Anilbachi Java Certification Resources&lt;/a&gt; - http://www.anilbachi.8m.com/ SCJP tutorial, mock exams, objectives, mock exam links and discussion forum.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.whizlabs.com/tutorial/scjp/index.html"&gt;Java certification success, Part 1: SCJP&lt;/a&gt; - http://www.whizlabs.com/tutorial/scjp/index.html A SCJP Tutorial to test the knowledge of Java fundamentals and requires in-depth knowledge of the syntax and semantics.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.aniyog.com/java/certification.htm"&gt;Certification: The Java Mock Test&lt;/a&gt; - http://www.aniyog.com/java/certification.htm Offers free applet based mock exam for SCJP2.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.akgupta.com/Java/certification.htm"&gt;Java Certification (SCJP)&lt;/a&gt; - http://www.akgupta.com/Java/certification.htm Contains SCJP mock exam, tidbits, exam notes and links to other resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/velmurugan_p/"&gt;Java Certification Study Notes&lt;/a&gt; - http://www.geocities.com/velmurugan_p/ SCJP &amp; SCWCD study notes, resources and tips.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.jguru.com/forums/JavaCertification"&gt;Java Guru: Java Certification Forum Home Page&lt;/a&gt; - http://www.jguru.com/forums/JavaCertification Forum to pose and view the who, what, where, why and how questions on Java certification.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/sunjava4u/"&gt;Sun Java 4 U&lt;/a&gt; - http://www.geocities.com/sunjava4u/ Links and resources useful for SCJP aspirants includes exam simulators, mock exams, study guides.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://java.certifiedprogrammer.com/"&gt;Java.CertifiedProgrammer.com&lt;/a&gt; - http://java.certifiedprogrammer.com/ Contains study aides, news and mock exams.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.acmerocket.com/skinny/"&gt;The Java Skinny&lt;/a&gt; - http://www.acmerocket.com/skinny/ Contains sample questions, SCJP exam objectives with code examples and other resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/skmajji/Main.html"&gt;Sun Certified Java Programmer sample test paper!&lt;/a&gt; - http://www.geocities.com/skmajji/Main.html A practice test for SCJP comprising of 30 questions with answers.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.enthuware.com/"&gt;Enthuware&lt;/a&gt; - http://www.enthuware.com/ Test simulators for Sun certification exams. [Commercial]&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.janeg.ca/index.html"&gt;Java Quick Reference&lt;/a&gt; - http://www.janeg.ca/index.html Comprises of concise study notes for SCJP exam and other links.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javabeat.net/"&gt;JavaBeat&lt;/a&gt; - http://www.javabeat.net/ Java certification resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://certification.about.com/cs/freequestions/index.htm"&gt;About.com - Java Certifications&lt;/a&gt; - http://certification.about.com/cs/freequestions/index.htm Explore information and links for Java and Sun certifications. Includes articles, practice tests, software reviews, book reviews, and forums.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.certgear.com/products/vendor/java.htm"&gt;CertGear Systems - Java&lt;/a&gt; - http://www.certgear.com/products/vendor/java.htm Java certification resources, including practice tests (SCJP SCWCD SCBCD ), free quizzes, and study aids.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.examsguide.com/"&gt;Exams guide&lt;/a&gt; - http://www.examsguide.com Java certification resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://java.boot.by/scjp-tiger/"&gt;SCJP Tiger Study Guide&lt;/a&gt; - http://java.boot.by/scjp-tiger/ Study Guide for exam CX-310-055 (Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0).&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/gnashes30/java/mock.htm"&gt;VoodooExam&lt;/a&gt; - http://www.geocities.com/gnashes30/java/mock.htm SCJP mock exam engine with facility to add new question/answers. Needs jdk1.2.1 or higher [download].&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.inesystems.com/"&gt;Inesystem's Java Certification&lt;/a&gt; - http://www.inesystems.com Provides exam simulators and online training for Sun Java Certification exams.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://prasks.webahn.com/architect/scja.html"&gt;Prasks Resources&lt;/a&gt; - http://prasks.webahn.com/architect/scja.html Sun Certified Java Architect resources and experiences.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javadeveloper.co.in/"&gt;Java Certification Resources&lt;/a&gt; - http://www.javadeveloper.co.in Includes tutorials, mock exams, study notes and exam simulators for SCJP and SCWCD exams.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.tipsmart.com/"&gt;Tipsmart.com&lt;/a&gt; - http://www.tipsmart.com/ Contains interactive quizzes, pitfalls, FAQs by programmers, list of integrated development tools.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.valoxo.ch/jr/mocks/mock01a.html"&gt;Mock Exam&lt;/a&gt; - http://www.valoxo.ch/jr/mocks/mock01a.html Javascript based SCJP Mock Exam.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://home-1.tiscali.nl/~bmc88/java/javacert/"&gt;Java Certification Exam Questions&lt;/a&gt; - http://home-1.tiscali.nl/~bmc88/java/javacert/ SCJP mock tests, exam notes and other resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/rraje_2000/MockExam.html"&gt;SCJP2 MockExam&lt;/a&gt; - http://www.geocities.com/rraje_2000/MockExam.html 60 questions mock test [Download].&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/r_palwai/scjp.htm"&gt;Radhika Palwai's Web Development Resources&lt;/a&gt; - http://www.geocities.com/r_palwai/scjp.htm Contains links to SCJP resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.michael-thomas.com/"&gt;Free Java Certification Training&lt;/a&gt; - http://www.michael-thomas.com/ Contains mock tests, source code, resources for Sun Certifications, resources on Web-development and UML.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://dreamjava.blogspot.com/"&gt;Everything you want to know about SCJP&lt;/a&gt; - http://dreamjava.blogspot.com A Blog to help SCJP aspirants with links and daily question.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.jai.ch/"&gt;Learn + play Java&lt;/a&gt; - http://www.jai.ch/ Interactive, downloadable course for SCJP with built-in Java source interpreter. Work and experiment with class libraries using the tests and JLS Summary.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.certlobby.com/sun-java-certification.html"&gt;Sun Java Certification Resource Center&lt;/a&gt; - http://www.certlobby.com/sun-java-certification.html Contains concise details on various Sun certification exams and links to resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/developergrp/"&gt;Dallas SCJD Study Group&lt;/a&gt; - http://www.geocities.com/developergrp/ Developer exam resources including FAQs, guidelines, presentations, free books and discussion forum.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javaprogrammingworld.com/"&gt;Sun Java Certification SCJP, Java Tutorials and ebooks&lt;/a&gt; - http://www.javaprogrammingworld.com The contents of this page are intended for SCJP 1.2 exam (310-025) and resources specific to SCJP 1.4 exam (310-035).&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javacertificate.net/"&gt;Java Mock Exams, Practice Questions, Tutorails, Articles&lt;/a&gt; - http://www.javacertificate.net Contains practice questions and mock exams for various Sun and IBM certifications.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javaquestion.tripod.com/"&gt;JavaQuestion Bank&lt;/a&gt; - http://javaquestion.tripod.com/ Includes general and certification questions and other java resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.xyzws.com/"&gt;SUN Certification Study Materials&lt;/a&gt; - http://www.xyzws.com Provides study guides &amp; mock exams (needs registration) for SCJP 5.0 (CX-310-055) and SCDJWS (CX-311-220) tests.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javaqueries.com/"&gt;JavaQueries&lt;/a&gt; - http://www.javaqueries.com/ SCEA Mock Exam, Solutions for JavaQueries.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.softlearn-systems.com/"&gt;SoftLearn Systems&lt;/a&gt; - http://www.softlearn-systems.com/ Provides simulators for SCBCD and SCJD exams. [Commercial]&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/rameshchhabra2002/Java/certification.htm"&gt;Universal teacher&lt;/a&gt; - http://www.geocities.com/rameshchhabra2002/Java/certification.htm SCJP exam simulator containing 600 questions [Download].&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.examsguide.com/scjp/freesimulator.html"&gt;SCJP Simulator&lt;/a&gt; - http://www.examsguide.com/scjp/freesimulator.html Offers an exam simulator with provision to add more questions.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://home.worldonline.dk/qjava/"&gt;Quick Java&lt;/a&gt; - http://home.worldonline.dk/qjava/ Contains a Java lookup reference and test-simulator based on a book.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://rohitgeorge.netfirms.com/scjp.html"&gt;Java Certification Guide&lt;/a&gt; - http://rohitgeorge.netfirms.com/scjp.html Contains tutorial on SCJP. Also contains a downloadable PDF version.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www-106.ibm.com/developerworks/java/library/j-scjp/"&gt;SCJP 1.4 certification primer&lt;/a&gt; - http://www-106.ibm.com/developerworks/java/library/j-scjp/ Outlines the new programmer certification exam with suggestions for preparation, sample questions and links to resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.angelfire.com/or/abhilash/"&gt;Abhilash's java quiz site&lt;/a&gt; - http://www.angelfire.com/or/abhilash/ Comprises of set of nine practice quizzes for SCJP exam with answers.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://otn.oracle.com/training/certification/jdeveloper_ocpds.html"&gt;Oracle Certified Java Developer&lt;/a&gt; - http://otn.oracle.com/training/certification/jdeveloper_ocpds.html Starting point for Oracle Certified Java Developer OCP program.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.korayguclu.de/"&gt;Home Page of Koray Guclu&lt;/a&gt; - http://www.korayguclu.de/ Contains excerpts from an ongoing SCJP book, exam information, notes and links to Mock exams/resources. Also publications, resume, photography, banner art.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.mycgiserver.com/~go4java/"&gt;go4java- Java Certification Site&lt;/a&gt; - http://www.mycgiserver.com/~go4java/ Includes SCJP experiences, FAQs, mock exams, tutorials and links to other resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/technofundo/tech/scjp/scjp.html"&gt;Java Programmer Certification&lt;/a&gt; - http://www.geocities.com/technofundo/tech/scjp/scjp.html SCJP Revision notes, links and other resources.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.webring.com/hub?ring=javacert"&gt;Java Certification Webring&lt;/a&gt; - http://www.webring.com/hub?ring=javacert Web-ring of sites involved with certification.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://home.worldonline.nl/~bmc88/java/javacert/revision.html"&gt;Sun Certified Programmer Examination Revision Book&lt;/a&gt; - http://home.worldonline.nl/~bmc88/java/javacert/revision.html SCJP Tutorial based on Sun's Objectives.&lt;br /&gt; &lt;a href="http://www.google.com/intl/en/dirhelp.html#pagerank"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://jamal.pisem.net/scjpnotes.htm"&gt;j-think&lt;/a&gt; &lt;br /&gt;&lt;a href="http://jamal.pisem.net/scjpnotes.htm"&gt; Contains SCJP notes.&lt;br /&gt; &lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.geocities.com/valoxo/scjp2/scjp2v1final.zip"&gt;Concentrated Guide to SCJP2&lt;/a&gt; - &lt;a href="http://www.geocities.com/valoxo/scjp2/scjp2v1final.zip"&gt; A zip archive consisting of SCJP Notes (PDF) and Questions and Answers (Word document) compiled by Ashraf Fouad Ayoub and Ashraf Samir Helmy.&lt;br /&gt; &lt;/a&gt;&lt;br /&gt;&lt;a href="http://blog.markwshead.com/archives/2005/01/02/taking-the-java-programmer-certification-exam.html"&gt;Passing the Java Programmer Certification Exam&lt;/a&gt; - &lt;a href="http://blog.markwshead.com/archives/2005/01/02/taking-the-java-programmer-certification-exam.html"&gt; Article discusses how to prepare for the Java Programmer certification. Includes suggestions on how to study for the exam.&lt;br /&gt; &lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.examnotes.net/forum71.html"&gt;Java certification forum&lt;/a&gt; - &lt;a href="http://www.examnotes.net/forum71.html"&gt; A discussion forum dedicated to Java certification exams.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5334619773603269475-4920698205837224725?l=ananthsjava.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ananthsjava.blogspot.com/feeds/4920698205837224725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5334619773603269475&amp;postID=4920698205837224725' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4920698205837224725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5334619773603269475/posts/default/4920698205837224725'/><link rel='alternate' type='text/html' href='http://ananthsjava.blogspot.com/2007/07/starting-point-for-suns-java-technology.html' title=''/><author><name>ANANTH KRISHNA</name><uri>http://www.blogger.com/profile/14083069456447228169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry></feed>
