<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>JAVA Programming Language</title>
	<atom:link href="http://javarocks.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://javarocks.wordpress.com</link>
	<description>Lets share views about the greatest programming language... Core Java...</description>
	<lastBuildDate>Tue, 28 Sep 2010 19:02:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='javarocks.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/f26bf9c7b9da44b94bd84c60677a2749?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>JAVA Programming Language</title>
		<link>http://javarocks.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://javarocks.wordpress.com/osd.xml" title="JAVA Programming Language" />
	<atom:link rel='hub' href='http://javarocks.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Java Interview Questions</title>
		<link>http://javarocks.wordpress.com/2010/09/28/java-interview-questions/</link>
		<comments>http://javarocks.wordpress.com/2010/09/28/java-interview-questions/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 19:02:44 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=66</guid>
		<description><![CDATA[Q: What is the difference between an Interface and an Abstract class? A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=66&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>What                                         is the difference between an  Interface                                         and an Abstract class? <a name="q1"></a></strong></span></td>
</tr>
<tr valign="top">
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">An abstract class can have instance  methods                                       that implement a default behavior.  An Interface                                       can only declare constants and  instance                                       methods, but cannot implement  default behavior and all methods are implicitly abstract. An interface  has all public members and no implementation. An abstract class is   a  class which may have the usual flavors of class members (private,  protected,   etc.), but has some abstract methods.<br />
. </span></td>
</tr>
<tr valign="top">
<td></td>
<td valign="bottom"></td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>What                                         is the purpose of garbage  collection in                                         Java, and when is it used?<a name="q2"></a></strong></span></td>
</tr>
<tr valign="top">
<td height="65"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">The                                       purpose of garbage collection is  to identify                                       and discard objects that are no  longer needed                                       by a program so that their  resources can                                       be reclaimed and reused. A Java  object is                                       subject to garbage collection when  it becomes                                       unreachable to the program in  which it is                                       used. </span></td>
</tr>
<tr valign="top">
<td></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><strong>Describe                                          synchronization in respect to  multithreading.<a name="q3"></a></strong></span></span></td>
</tr>
<tr valign="top">
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;">With                                       respect to multithreading,  synchronization                                       is the capability to control the  access                                       of multiple threads to shared  resources.                                       Without synchonization, it is  possible for                                       one thread to modify a shared  variable while                                       another thread is in the process  of using                                       or updating same shared variable.  This usually                                       leads to significant errors.</span></span><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"> </span></td>
</tr>
<tr valign="top">
<td></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong> Explain different way of using  thread?                                         <a name="q4"></a> </strong></span></td>
</tr>
<tr valign="top">
<td height="48"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">The                                       thread could be implemented by  using runnable                                       interface or by inheriting from  the Thread                                       class. The former is more  advantageous,                                       &#8217;cause when you are going for  multiple inheritance..the                                       only interface can help.</span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong><span style="font-size:x-small;">What                                         are pass by reference and passby  value?</span><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"> <a id="q5" name="q5"></a> </span></strong></span></td>
</tr>
<tr valign="top">
<td height="34"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-size:x-small;">Pass By Reference  means the                                       passing the address itself rather  than passing                                       the value. Passby Value  means passing a                                       copy of the value to be passed. </span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">What                                         is HashMap and Map?</span></strong><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><a name="q6"></a></span></span></td>
</tr>
<tr valign="top">
<td height="16"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">Map                                       is Interface and Hashmap is class  that implements                                       that.</span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Difference                                          between HashMap and HashTable?<a name="q7"></a></strong></span></td>
</tr>
<tr valign="top">
<td height="27"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">The                                       HashMap class is roughly  equivalent                                       to Hashtable, except that it is  unsynchronized                                       and permits nulls. (HashMap allows  null                                       values as key and value whereas  Hashtable                                       doesnt allow). HashMap does not  guarantee                                       that the order of the map will  remain constant                                       over time. HashMap is  unsynchronized and                                       Hashtable is </span><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">synchronized</span>.</td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong> Difference between Vector and  ArrayList?<a id="q8" name="q8"></a></strong></span></td>
</tr>
<tr valign="top">
<td height="19"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">Vector                                       is synchronized whereas arraylist  is not.</span></td>
</tr>
<tr valign="top">
<td height="19"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Difference                                         between Swing and Awt?<a name="q9"></a></strong></span></td>
</tr>
<tr valign="top">
<td height="18"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">AWT                                       are heavy-weight componenets.  Swings are                                       light-weight components. Hence  swing works                                       faster than AWT.</span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>What                                         is the difference between a  constructor                                         and a method? <a name="q10"></a></strong></span></td>
</tr>
<tr valign="top">
<td height="81"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">A                                       constructor is a member function  of a class                                       that is used to create objects of  that class.                                       It has the same name as the class  itself,                                       has no return type, and is invoked  using                                       the new operator.<br />
A method is an ordinary member  function                                       of a class. It has its own name, a  return                                       type (which may be void), and is  invoked                                       using the dot operator.</span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>What                                         is an Iterator?<a name="q11"></a></strong></span></td>
</tr>
<tr valign="top">
<td height="81"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;">Some                                       of the collection classes provide  traversal                                       of their contents via a  java.util.Iterator                                       interface. This interface allows  you to                                       walk through a collection of  objects, operating                                       on each object in turn. Remember  when using                                       Iterators that they contain a  snapshot of                                       the collection at the time the  Iterator                                       was obtained; generally it is not  advisable                                       to modify the collection itself  while traversing                                       an Iterator.</span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"> <a name="q12"></a> </span></span></strong></span><span style="font-size:x-small;">State                                         the significance of public,  private, protected,                                         default modifiers both singly  and in combination                                         and state the effect of package  relationships                                         on declared items qualified by  these modifiers.</span></span></strong></span></td>
</tr>
<tr valign="top">
<td height="81"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><em><strong>public                                       : </strong></em>Public class is  visible                                       in other packages, field is  visible everywhere                                       (class must be public too)<br />
<em><strong>private :</strong></em> Private                                       variables or methods may be used  only by                                       an instance of the same class that  declares                                       the variable or method, A private  feature                                       may only be accessed by the class  that owns                                       the feature.<br />
<em><strong>protected :</strong></em> Is                                       available to all classes in the  same package                                       and also available to all  subclasses of                                       the class that owns the protected  feature.This                                       access is provided even to  subclasses that                                       reside in a different package from  the class                                       that owns the protected feature.<br />
<em><strong>default :</strong></em>What                                        you get by default ie, without any  access                                       modifier (ie, public private or  protected).It                                       means that it is visible to all  within a                                       particular package</span></span>.</td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><strong>What                                         is an abstract class?<a name="q13"></a></strong></span></span></td>
</tr>
<tr valign="top">
<td height="81"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><strong> </strong>Abstract class must be  extended/subclassed                                       (to be useful). It serves as a  template.                                       A class that is abstract may not  be instantiated                                       (ie, you may not call its  constructor),                                       abstract class may contain static  data.                                       Any class with an abstract method  is automatically                                       abstract itself, and must be  declared as                                       such.<br />
A class may be declared abstract  even if                                       it has no abstract methods. This  prevents                                       it from being instantiated.<strong> </strong></span></span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><strong>What                                         is static in java?<a name="q14"></a></strong></span></span></span></td>
</tr>
<tr valign="top">
<td height="81"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;">Static                                       means one per class, not one for  each object                                       no matter how many instance of a  class might                                       exist. This means that you can use  them                                       without creating an instance of a  class.Static                                       methods are implicitly final,  because overriding                                       is done based on the type of the  object,                                       and static methods are attached to  a class,                                       not an object. A static method in a  superclass                                       can be shadowed by another static  method                                       in a subclass, as long as the  original method                                       was not declared final. However,  you can&#8217;t                                       override a static method with a  nonstatic                                       method. In other words, you can&#8217;t  change                                       a static method into an instance  method                                       in a subclass.</span><strong> </strong></span></span></td>
</tr>
<tr valign="top">
<td height="18"></td>
<td>
<div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#990000;"><span style="font-size:xx-small;"><strong><br />
</strong></span></span></div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td width="3%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>Q:</strong></span></td>
<td width="97%"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><strong>What                                         is final?<a name="q15"></a></strong></span></span></span></span></td>
</tr>
<tr valign="top">
<td height="48"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:x-small;"><strong>A:</strong></span></td>
<td><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;"><span style="font-size:x-small;"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;">A                                       final class can&#8217;t be extended ie.,  final                                       class may not be subclassed. A  final method                                       can&#8217;t be overridden when its class  is inherited.                                       You can&#8217;t change value of a final  variable                                       (is a constant).</span></span></span></span></td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=66&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2010/09/28/java-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Servlet example</title>
		<link>http://javarocks.wordpress.com/2010/09/09/simple-servlet-example/</link>
		<comments>http://javarocks.wordpress.com/2010/09/09/simple-servlet-example/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 11:07:12 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=63</guid>
		<description><![CDATA[&#60;html&#62; &#60;head&#62; &#60;title&#62;The servlet example &#60;/title&#62; &#60;/head&#62; &#60;body&#62; &#60;h1&#62;A simple web application&#60;/h1&#62; &#60;form method="POST" action="WelcomeServlet"&#62; &#60;label for="name"&#62;Enter your name &#60;/label&#62; &#60;input type="text" id="name" name="name"/&#62;&#60;br&#62;&#60;br&#62; &#60;input type="submit" value="Submit Form"/&#62; &#60;input type="reset" value="Reset Form"/&#62; &#60;/form&#62; &#60;/body&#62; &#60;/html&#62;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=63&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<pre>&lt;html&gt;
	&lt;head&gt;
	&lt;title&gt;The servlet example &lt;/title&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;h1&gt;A simple web application&lt;/h1&gt;
		&lt;form method="POST" action="WelcomeServlet"&gt;
			&lt;label for="name"&gt;Enter your name &lt;/label&gt;
			&lt;input type="text" id="name" name="name"/&gt;&lt;br&gt;&lt;br&gt;
			&lt;input type="submit" value="Submit Form"/&gt;
			&lt;input type="reset" value="Reset Form"/&gt;
		&lt;/form&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=63&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2010/09/09/simple-servlet-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
		<item>
		<title>J2EE Web Application Structure</title>
		<link>http://javarocks.wordpress.com/2010/09/09/j2ee-web-application-structure/</link>
		<comments>http://javarocks.wordpress.com/2010/09/09/j2ee-web-application-structure/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 10:59:59 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=60</guid>
		<description><![CDATA[Web Applications use a standard directory structure defined in the Servlet specification. When developing web applications on J2EE platform, you must follow this structure so that application can be deployed in any J2EE compliant web server. A web application has the directory structureas shown in below figure. The root directory of the application is called [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=60&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Web Applications use a standard directory structure defined in the Servlet specification. When developing web applications on J2EE platform, you must follow this structure so that application can be deployed in any J2EE compliant web server.</p>
<p>A web application has the directory structureas shown in below figure.</p>
<p><img title="J2EE Web Application Directory Structure" src="http://www.jsptube.com/sites/default/files/figures/directory-structure.png" alt="J2EE Web Application Directory Structure" width="126" height="87" /></p>
<p>The root directory of the application is called the document root. Root directory is mapped to the context path. Root directory contains a directory named WEB-INF. Anything under the root directory excepting the WEB-INF directory is publically available, and can be accessed by URL from browser. WEB-INF directory is a private area of the web application, any files under WEB-INF directory cannot be accessed directly from browser by specifying the URL like http://somesite/WEB-INF/someresource.html. Web container will not serve the content of this directory. However the content of the WEB-INF directory is accessible by the classes within the application. So if there are any resources like JSPs or HTML document that you don’t wish to be accessible directly from web browser, you should place it under WEB-INF directory.</p>
<h3>WEB-INF directory structure</h3>
<p>WEB-INF directory contains</p>
<ul>
<li>WEB-INF/web.xml deployment descriptor</li>
<li>WEB-INF/classes directory</li>
<li>WEB-INF/lib directory</li>
</ul>
<h3>/WEB-INF/web.xml</h3>
<p>web.xml is called the web application deployment descriptor. This is a XML file that defines servlets, servlet mappings, listeners, filters, welcome files etc. Deployment descriptor is a heart of any J2EE web application, so every web application must have a web.xml deployment descriptor directly under WEB-INF folder.</p>
<h3>/WEB-INF/classes</h3>
<p>The classes directory is used to store compiled servlet and other classes of the application. If your classes are organized into packages, the directory structure must be reflected directly under WEB-INF/classes directory. The classes directory is automatically included in CLASSPATH.</p>
<h3>/WEB-INF/lib</h3>
<p>Lib directory is used to store the jar files. If application has any bundled jar files, or if application uses any third party libraries such as log4j, JDBC drivers which is packaged in jar file, than these jar files should be placed in lib directory.</p>
<p>All unpacked classes and resources in the /WEB-INF/classes directory, plus classes and resources in JAR files under the /WEB-INF/lib directory are included in classpath and made visible to the containing web application.<br />
<strong>Note</strong> Directory and file names are case sensitive.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=60&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2010/09/09/j2ee-web-application-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>

		<media:content url="http://www.jsptube.com/sites/default/files/figures/directory-structure.png" medium="image">
			<media:title type="html">J2EE Web Application Directory Structure</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing and configuring Java,Mysql,MysqlJ Connector in Windows</title>
		<link>http://javarocks.wordpress.com/2010/09/08/installing-and-configuring-javamysqlmysqlj-connector-in-windows/</link>
		<comments>http://javarocks.wordpress.com/2010/09/08/installing-and-configuring-javamysqlmysqlj-connector-in-windows/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 20:01:48 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=56</guid>
		<description><![CDATA[Download and install the binary file for JDK from www.sun.com. Create a system variable named path and append the address of bin directory to it. Download and install Mysql binary file. It will be automatically configured during installation. For succesfull connection between Java and MySQL, MySQL-J connector should be installed and configured. For that, do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=56&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Download and install the binary file for JDK from www.sun.com. Create a system variable named path and append the address of bin directory to it.</p>
<p>Download and install Mysql binary file. It will be automatically configured during installation.</p>
<p>For succesfull connection between Java and MySQL, MySQL-J connector should be installed and configured. For that, do the following steps.</p>
<p>Download MySQL-J connector from Mysql website. Unpack it. Select mysql connector .jar file. Copy and paste it to jdk/jre/lib/ext folder. You should also add the complete path to this JAR file in your CLASSPATH environment variable. In case if you don&#8217;t know how to do that, go to Start -&gt; Settings -&gt; Control Panel -&gt; System -&gt; Advanced <em>(tab)</em> -&gt; Environment Variables. Double-click &#8216;CLASSPATH&#8217; if it is already listed there or click &#8216;New&#8217; to create one with the name of &#8216;CLASSPATH&#8217;. If you already had a &#8216;CLASSPATH environment variable listed, simply type in (or paste) the complete path including file name in the window that opens up *at the end of* existing CLASSPATH values. If you are creating a new &#8216;CLASSPATH&#8217; environment variable then simple enter &#8216;.;&#8217; and then append the complete path to Connector/J&#8217;s JAR file.</p>
<p>Then run the following program to check the connection.</p>
<div id="_mcePaste">import java.sql.Connection;</div>
<div id="_mcePaste">import java.sql.DriverManager;</div>
<div id="_mcePaste">import java.sql.SQLException;</div>
<div id="_mcePaste">public class JdbcExample2 {</div>
<div id="_mcePaste">public static void main(String args[]) {</div>
<div id="_mcePaste">Connection con = null;</div>
<div id="_mcePaste">try {</div>
<div id="_mcePaste">Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;).newInstance();</div>
<div id="_mcePaste">con = DriverManager.getConnection(&#8220;jdbc:mysql://localhost:3306/test&#8221;,</div>
<div id="_mcePaste">&#8220;root&#8221;, &#8220;root&#8221;);</div>
<div id="_mcePaste">if(!con.isClosed())</div>
<div id="_mcePaste">System.out.println(&#8220;Successfully connected to &#8221; +</div>
<div id="_mcePaste">&#8220;MySQL server using TCP/IP&#8230;&#8221;);</div>
<div id="_mcePaste">} catch(Exception e) {</div>
<div id="_mcePaste">System.err.println(&#8220;Exception: &#8221; + e.getMessage());</div>
<div id="_mcePaste">} finally {</div>
<div id="_mcePaste">try {</div>
<div id="_mcePaste">if(con != null)</div>
<div id="_mcePaste">con.close();</div>
<div id="_mcePaste">} catch(SQLException e) {}</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">}</div>
<p>import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;<br />
public class JdbcExample2 {<br />
public static void main(String args[]) {    Connection con = null;<br />
try {      Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;).newInstance();      con = DriverManager.getConnection(&#8220;jdbc:mysql://localhost:3306/test&#8221;,        &#8221;root&#8221;, &#8220;root&#8221;);<br />
if(!con.isClosed())        System.out.println(&#8220;Successfully connected to &#8221; +          &#8221;MySQL server using TCP/IP&#8230;&#8221;);<br />
} catch(Exception e) {      System.err.println(&#8220;Exception: &#8221; + e.getMessage());    } finally {      try {        if(con != null)          con.close();      } catch(SQLException e) {}    }  }}</p>
<p><span style="font-family:Verdana, Tahoma;line-height:normal;font-size:16px;color:#444444;"></p>
<div class="note" style="font-family:Verdana, Tahoma, 'Lucida Console';font-size:16px;background-color:#f7f7f7;margin-left:10px;margin-right:10px;color:#222222;border-style:groove;border-width:2px;padding:10px;"><strong>Note:</strong> The CLASSPATH variable contains a list of semi-colon separated folders and JAR files where JVM will search for Java class files. You should always separate paths with semi-colon (;) so that JVM can understand where one path ends and next one begins. Also keep in mind that in CLASSPATH variable paths, the first path is always &#8216;.&#8217; (single dot) which means current folder, so that JVM starts the search for Java class files from the current folder.</div>
<div><img src="http://www.stardeveloper.com/images/articles/2003090201_15.gif" border="0" alt="Window - Environment Variables" width="367" height="166" /><br />
<span class="figText" style="font-family:Tahoma;font-size:11px;">Window &#8211; Environment Variables</span></div>
<div><img src="http://www.stardeveloper.com/images/articles/2003090201_16.gif" border="0" alt="Window - Edit System Variable" width="347" height="140" /><br />
<span class="figText" style="font-family:Tahoma;font-size:11px;">Window &#8211; Edit System Variable</span></div>
<p style="font-family:Verdana, Tahoma, Arial, sans-serif;font-size:16px;color:#111111;">If you&#8217;ve correctly added the path to Connector/J JDBC driver&#8217;s JAR file in your CLASSPATH environment variable then you are done with installing MySQL Connector/J JDBC driver.</p>
<div class="tip" style="font-family:Verdana, Tahoma, 'Lucida Console';font-size:16px;background-color:#f7f7f7;margin-left:10px;margin-right:10px;color:#222222;border-style:groove;border-width:2px;padding:10px;"><strong>Tip:</strong> When you make changes to any of your environment variables (like CLASSPATH), close and re-open any open command prompt windows so that they refresh their environment variable value&#8217;s cache.</div>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=56&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2010/09/08/installing-and-configuring-javamysqlmysqlj-connector-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>

		<media:content url="http://www.stardeveloper.com/images/articles/2003090201_15.gif" medium="image">
			<media:title type="html">Window - Environment Variables</media:title>
		</media:content>

		<media:content url="http://www.stardeveloper.com/images/articles/2003090201_16.gif" medium="image">
			<media:title type="html">Window - Edit System Variable</media:title>
		</media:content>
	</item>
		<item>
		<title>How to install and configure Apache Tomcat for JSP for Windows Operating System</title>
		<link>http://javarocks.wordpress.com/2010/09/08/how-to-install-and-configure-apache-tomcat-for-jsp-for-windows-operating-system/</link>
		<comments>http://javarocks.wordpress.com/2010/09/08/how-to-install-and-configure-apache-tomcat-for-jsp-for-windows-operating-system/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 17:26:52 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=53</guid>
		<description><![CDATA[Go to the site http://tomcat.apache.org/ Download and install the binary distribution for windows. After sucessfull installation of tomcat server, edit the file tomcat-users.xml in installed_directory/conf directory. Add the following lines. &#60;role rolename=&#8221;admin-gui&#8221;/&#62; &#60;role rolename=&#8221;manager-gui&#8221;/&#62; &#60;user username=&#8221;root&#8221; password=&#8221;root&#8221; roles=&#8221;admin-gui&#8221;/&#62; &#60;user username=&#8221;root&#8221; password=&#8221;root&#8221; roles=&#8221;manager-gui&#8221;/&#62; The username and passoword are arbitary. You can change these to suit you. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=53&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Go to the site <a href="http://tomcat.apache.org/">http://tomcat.apache.org/</a></p>
<p>Download and install the binary distribution for windows. After sucessfull installation of tomcat server, edit the file tomcat-users.xml in installed_directory/conf directory. Add the following lines.</p>
<div id="_mcePaste">&lt;role rolename=&#8221;admin-gui&#8221;/&gt;</div>
<div id="_mcePaste">&lt;role rolename=&#8221;manager-gui&#8221;/&gt;</div>
<p>&lt;user username=&#8221;root&#8221; password=&#8221;root&#8221; roles=&#8221;admin-gui&#8221;/&gt;</p>
<p>&lt;user username=&#8221;root&#8221; password=&#8221;root&#8221; roles=&#8221;manager-gui&#8221;/&gt;</p>
<p>The username and passoword are arbitary. You can change these to suit you.</p>
<p>Start the server. Open your browser. Type in http://localhost:8080 .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=53&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2010/09/08/how-to-install-and-configure-apache-tomcat-for-jsp-for-windows-operating-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Top Ten Errors Java Programmers Make</title>
		<link>http://javarocks.wordpress.com/2009/08/28/top-ten-errors-java-programmers-make/</link>
		<comments>http://javarocks.wordpress.com/2009/08/28/top-ten-errors-java-programmers-make/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 05:12:21 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/2009/08/28/top-ten-errors-java-programmers-make/</guid>
		<description><![CDATA[Whether you program regularly in Java, and know it like the back of your hand, or whether you&#8217;re new to the language or a casual programmer, you&#8217;ll make mistakes. It&#8217;s natural, it&#8217;s human, and guess what? You&#8217;ll more than likely make the same mistakes that others do, over and over again. Here&#8217;s my top ten [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=48&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whether you program regularly in Java, and know it like the back of your hand, or whether you&#8217;re new to the language or a casual programmer, you&#8217;ll make mistakes. It&#8217;s natural, it&#8217;s human, and guess what? You&#8217;ll more than likely make the same mistakes that others do, over and over again. Here&#8217;s my top ten list of errors that we all seem to make at one time or another,  how to spot them, and how to fix them.</p>
<h3>10. Accessing non-static member variables from static methods (such as main)</h3>
<p>Many programmers, particularly when first introduced to Java, have problems with accessing member variables from their <em>main</em> method. The method signature for main is marked static &#8211; meaning that we don&#8217;t need to create an instance of the class to invoke the main method. For example, a Java Virtual Machine (JVM) could call the class MyApplication like this :-</p>
<blockquote><p>MyApplication.main ( command_line_args );</p></blockquote>
<p>This means, however, that there isn&#8217;t an instance of MyApplication &#8211; it doesn&#8217;t have any member variables to access! Take for example the following application, which will generate a compiler error message.</p>
<pre>public class StaticDemo
{
        public String my_member_variable = "somedata";
        public static void main (String args[])
        {
		// Access a non-static member from static method
                System.out.println ("This generates a compiler error" +
			my_member_variable );
        }
}</pre>
<p>If you want to access its member variables from a non-static method (like <em>main</em>), you must create an instance of the object. Here&#8217;s a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.</p>
<pre>public class NonStaticDemo
{
        public String my_member_variable = "somedata";

        public static void main (String args[])
        {
                NonStaticDemo demo = new NonStaticDemo();

		// Access member variable of demo
                System.out.println ("This WON'T generate an error" +
                        demo.my_member_variable );
        }
}</pre>
<h3>9. Mistyping the name of a method when overriding</h3>
<p>Overriding allows programmers to replace a method&#8217;s implementation with new code. Overriding is a handy feature, and most OO programmers make heavy use of it. If you use the AWT 1.1 event handling model, you&#8217;ll often override listener implementations to provide custom functionality. One easy trap to fall into with overriding, is to mistype the method name. If you mistype the name, you&#8217;re no longer overriding a method &#8211; you&#8217;re creating an entirely new method, but with the same parameter and return type.</p>
<pre>public class MyWindowListener extends WindowAdapter {
	// This should be WindowClose<strong>d</strong>
	public void WindowClose(WindowEvent e) {
		// Exit when user closes window
		System.exit(0);
	}
});</pre>
<p>Compilers won&#8217;t pick up on this one, and the problem can be quite frustrating to detect. In the past, I&#8217;ve looked at a method, believed that it was being called, and taken ages to spot the problem. The symptom of this error will be that your code isn&#8217;t being called, or you think the method has skipped over its code. The only way to ever be certain is to add a println statement, to record a message in a log file, or to use good trace debugger (like Visual J++ or Borland JBuilder) and step through line by line. If your method still isn&#8217;t being called, then it&#8217;s likely you&#8217;ve mistyped the name.</p>
<h3>8. Comparison assignment (  = rather than == )</h3>
<p>This is an easy error to make. If you&#8217;re used other languages before, such as Pascal, you&#8217;ll realize just how poor a choice this was by the language&#8217;s designers. In Pascal, for example, we use the := operator for assignment, and leave = for comparison. This looks like a throwback to C/C++, from which Java draws its roots.</p>
<p>Fortunately, even if you don&#8217;t spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : &#8220;Can&#8217;t convert xxx to boolean&#8221;, where xxx is a Java type that you&#8217;re assigning instead of comparing.</p>
<h3>7. Comparing two objects ( == instead of .equals)</h3>
<p>When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object.</p>
<p>Here&#8217;s the correct way to compare two strings.</p>
<pre>String abc = "abc"; String def = "def";

// Bad way
if ( (abc + def) == "abcdef" )
{
    ......
}
// Good way
if ( (abc + def).equals("abcdef") )
{
   .....
}</pre>
<h3>6. Confusion over passing by value, and passing by reference</h3>
<p>This can be a frustrating problem to diagnose, because when you look at the code, you might be sure that its passing by reference, but find that its actually being passed by value. Java uses<strong>both</strong>, so you need to understand when you&#8217;re passing by value, and when you&#8217;re passing by reference.</p>
<p>When you pass a primitive data type, such as a char, int, float, or double, to a function then you are <strong>passing by value</strong>. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only. Once the function finishes, and control is returned to the returning function, the &#8220;real&#8221; variable will be untouched, and no changes will have been saved. If you need to modify a primitive data type, make it a return value for a function, or wrap it inside an object.</p>
<p>When you pass a Java object, such as an array, a vector, or a string, to a function then you are<strong>passing by reference</strong>. Yes &#8211; a String is actually an object, not a primitive data type.  So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object&#8217;s member variables will be permanent &#8211; which can be either good or bad, depending on whether this was what you intended.</p>
<p>On a side note, since String contains no methods to modify its contents, you might as well be passing by value.</p>
<h3>5. Writing blank exception handlers</h3>
<p>I know it&#8217;s very tempting to write blank exception handlers, and to just ignore errors. But if you run into problems, and haven&#8217;t written any error messages, it becomes almost impossible to find out the cause of the error. Even the simplest exception handler can be of benefit. For example, put a try { .. } catch Exception around your code, to catch ANY type of exception, and print out the message. You don&#8217;t need to write a custom handler for every exception (though this is still good programming practice). Don&#8217;t ever leave it blank, or you won&#8217;t know what&#8217;s happening.</p>
<p>For example</p>
<pre>public static void main(String args[])
{
    try {
	// Your code goes here..
    }
    catch (Exception e)
    {
	System.out.println ("Err - " + e );
    }
}</pre>
<h3>4. Forgetting that Java is zero-indexed</h3>
<p>If you&#8217;ve come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element&#8217;s index is actually 0. Confused? Let&#8217;s look at a quick example.</p>
<pre>// Create an array of three strings
String[] strArray = new String[3];

// First element's index is actually 0
strArray[0] = "First string";

// Second element's index is actually 1
strArray[1] = "Second string";

// Final element's index is actually 2
strArray[2] = "Third and final string";</pre>
<p>In this example, we have an array of three strings, but to access elements of the array we actually subtract one. Now, if we were to try and access strArray[3], we&#8217;d be accessing the fourth element. This will case an ArrayOutOfBoundsException to be thrown &#8211; the most obvious sign of forgetting the zero-indexing rule.</p>
<p>Other areas where zero-indexing can get you into trouble is with strings. Suppose you wanted to get a character at a particular offset within a string. Using the String.charAt(int) function you can look this information up &#8211; but under Java, the String class is also zero-indexed. That means than the first character is at offset 0, and second at offset 1. You can run into some very frustrating problems unless you are aware of this &#8211; particularly if you write applications with heavy string processing. You can be working on the wrong character, and also throw exceptions at run-time. Just like the ArrayOutOfBoundsException, there is a string equivalent. Accessing beyond the bounds of a String will cause a StringIndexOutOfBoundsException to be thrown, as demonstrated by this example.</p>
<pre>public class StrDemo
{
 public static void main (String args[])
 {
        String abc = "abc";

        System.out.println ("Char at offset 0 : " + abc.charAt(0) );
        System.out.println ("Char at offset 1 : " + abc.charAt(1) );
        System.out.println ("Char at offset 2 : " + abc.charAt(2) );

	// This line should throw a StringIndexOutOfBoundsException
        System.out.println ("Char at offset 3 : " + abc.charAt(3) );
 }
}</pre>
<p>Note too, that zero-indexing doesn&#8217;t just apply to arrays, or to Strings. Other parts of Java are also indexed, but not always consistently. The java.util.Date, and java.util.Calendar classes start their months with 0, but days start normally with 1. This problem is demonstrated by the following application.</p>
<pre>import java.util.Date;
import java.util.Calendar;

public class ZeroIndexedDate
{
        public static void main (String args[])
        {
                // Get today's date
                Date today = new Date();

		// Print return value of getMonth
		System.out.println ("Date.getMonth() returns : " +
			 today.getMonth());

		// Get today's date using a Calendar
		Calendar rightNow = Calendar.getInstance();

		// Print return value of get ( Calendar.MONTH )
		System.out.println ("Calendar.get (month) returns : " +
			rightNow.get ( Calendar.MONTH ));
        }
}</pre>
<p>Zero-indexing is only a problem if you don&#8217;t realize that its occurring. If you think you&#8217;re running into a problem, always consult your API documentation.</p>
<h3>3. Preventing concurrent access to shared variables by threads</h3>
<p>When writing multi-threaded applications, many programmers (myself included) often cut corners, and leave their applications and applets vulnerable to thread conflicts. When two or more threads access the same data concurrently, there exists the possibility (and Murphy&#8217;s law holding, the probability) that two threads will access or modify the same data at the same time. Don&#8217;t be fooled into thinking that such problems won&#8217;t occur on single-threaded processors. While accessing some data (performing a read), your thread may be suspended, and another thread scheduled. It writes its data, which is then overwritten when the first thread makes its changes.</p>
<p>Such problems are not just limited to multi-threaded applications or applets. If you write Java APIs, or JavaBeans, then your code may not be thread-safe. Even if you never write a single application that uses threads, people that use your code WILL. For the sanity of others, if not yourself, you should always take precautions to prevent concurrent access to shared data.</p>
<p>How can this problem be solved? The simplest method is to make your variables private (but you do that already,  right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.</p>
<pre>public class MyCounter
{
	private int count = 0; // count starts at zero

	public synchronized void setCount(int amount)
	{
		count = amount;
	}

	public synchronized int getCount()
	{
		return count;
	}
}</pre>
<h3>2. Capitalization errors</h3>
<p>This is one of the most frequent errors that we all make. It&#8217;s so simple to do, and sometimes one can look at an uncapitalized variable or method and still not spot the problem. I myself have often been puzzled by these errors, because I recognize that the method or variable does exist, but don&#8217;t spot the lack of capitalization.</p>
<p>While there&#8217;s no silver bullet for detecting this error, you can easily train yourself to make less of them. There&#8217;s a very simple trick you can learn :-</p>
<ul>
<li>all methods and member variables in the Java API begin with lowercase letters</li>
<li>all methods and member variables use capitalization where a new word begins e.g &#8211; getDoubleValue()</li>
</ul>
<p>If you use this pattern for all of your member variables and classes, and then make a conscious effort to get it right, you can gradually reduce the number of mistakes you&#8217;ll make. It may take a while, but it can save some serious head scratching in the future.</p>
<h2>(drum roll)</h2>
<h2>And the number one error that Java programmers make !!!!!</h2>
<h1>1. Null pointers!</h1>
<p>Null pointers are one of the most common errors that Java programmers make. Compilers can&#8217;t check this one for you &#8211; it will only surface at runtime, and if you don&#8217;t discover it, your users certainly will.</p>
<p>When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven&#8217;t initialized an object, or you haven&#8217;t checked the return value of a function.</p>
<p>Many functions return null to indicate an error condition &#8211; but unless you check your return values, you&#8217;ll never know what&#8217;s happening. Since the cause is an error condition, normal testing may not pick it up &#8211; which means that your users will end up discovering the problem for you. If the API function indicates that null may be returned, be sure to check this before using the object reference!</p>
<p>Another cause is where your initialization has been sloppy, or where it is conditional. For example, examine the following code, and see if you can spot the problem.</p>
<pre>public static void main(String args[])
{
	// Accept up to 3 parameters
	String[] list = new String[3];

	int index = 0;

	while ( (index &lt; args.length) &amp;&amp; ( index &lt; 3 ) )
	{
		list[index++] = args[index];
	}

	// Check all the parameters
	for (int i = 0; i &lt; list.length; i++)
	{
		if (list[i].equals "-help")
		{
			// .........
		}
		else
		if (list[i].equals "-cp")
		{
			// .........
		}
		// else .....
	}
}</pre>
<p>This code (while a contrived example), shows a common mistake. Under some circumstances, where the user enters three or more parameters, the code will run fine. If no parameters are entered, you&#8217;ll get a NullPointerException at runtime. Sometimes your variables (the array of strings) will be initialized, and other times they won&#8217;t. One easy solution is to check BEFORE you attempt to access a variable in an array that it is not equal to null.</p>
<h3>Summary</h3>
<p>These errors represent but some of the many that we all make. Though it is impossible to completely eliminate errors from the coding process, with care and practice you can avoid repeating the same ones. Rest assured, however, that all Java programmers encounter the same sorts of problems. It&#8217;s comforting to know, that while you work late into the night tracking down an error, someone, somewhere, sometime, will make the same mistake!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=48&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2009/08/28/top-ten-errors-java-programmers-make/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Sun Certification</title>
		<link>http://javarocks.wordpress.com/2009/08/27/java-certification-or-sun-certification/</link>
		<comments>http://javarocks.wordpress.com/2009/08/27/java-certification-or-sun-certification/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 17:32:13 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=44</guid>
		<description><![CDATA[Java Certification There are many myths about sun certification to various java courses. Here is  full details about sun certification. Sun&#8217;s certification program in Java technology is an industry recognized, worldwide program that focuses on critical job roles in software application development and enterprise architecture. Since these certifications focus on the technology, the knowledge and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=44&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="sharepage">
<h1>Java Certification</h1>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0" summary="layout">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><!-- END PAGETITLE ONE LINE --> <!--googleon: snippet--><span> </span></p>
<p><!-- BEGIN J1 OVERVIEW COMPONENT --> <!-- BEGIN J1 COMPONENT V.3 --><img style="float:left;margin:0 10px 0 0;" src="http://www.sun.com/training/images/Sun-JavaPath.gif" border="0" alt="" /></p>
<p>There are many myths about sun certification to various java courses. Here is  full details about sun certification.</p>
<div>Sun&#8217;s certification program in Java technology is an industry recognized, worldwide program that focuses on critical job roles in software application development and enterprise architecture. Since these certifications focus on the technology, the knowledge and skills learned while preparing for Sun&#8217;s certifications are transportable from one company to another.Sun&#8217;s philosophy is that certification is central to the learning process as it provides validation of skill sets for specific job roles. Sun certification also offers a natural progression to support your career goals.</p>
<ul>
<li>First, by becoming a Sun Certified Associate Sun verifies that you have a base set of knowledge that enables entry into a career in application development or software project management using Java technology.</li>
<li>Second, we train developers on a foundational set of skills, which can then be validated by becoming a Sun Certified Programmer.</li>
<li>Afterwards, you can pursue advanced or specialty training and certifications that help enable career growth into more specific job roles making you more valuable to an organization.</li>
</ul>
<p>Sun offers the following Java technology professional certifications:</p></div>
<p><span> </span><br />
- Sun Certified Java Associate (SCJA)<br />
- Sun Certified Java Programmer (SCJP)<br />
- Sun Certified Java Developer (SCJD)<br />
- Sun Certified Web Component Developer (SCWCD)<br />
- Sun Certified Business Component Developer (SCBCD)<br />
- Sun Certified Developer For Java Web Services (SCDJWS)<br />
- Sun Certified Mobile Application Developer (SCMAD)<br />
- Sun Certified Enterprise Architect (SCEA)</p>
<h1>Sun Certified Java Associate (SCJA)</h1>
<p>This certification provides an ideal entry into an application development or a software project management career using Java technologies. It validates basic knowledge of OO concepts, the Java programming language and general knowledge of Java platforms and technologies.</p>
<p>To achieve this certification, candidates must successfully complete one exam.</p>
<h1>Sun Certified Java Programmer (SCJP)</h1>
<p>This foundation certification is for programmers interested in demonstrating proficiency in the fundamentals of the Java programming language.</p>
<p>To achieve this certification, candidates must successfully complete one exam. It is not necessary to be a Sun Certified Java Associate prior to taking this exam.</p>
<div id="sharepage">
<h1>Sun Certified Java Developer (SCJD)</h1>
<p>This performance-based certification is for developers interested in demonstrating advanced proficiency in the Java programming language using the Java SE.To achieve this certification, candidates must successfully complete two elements: a programming assignment and an essay exam. Prior to attempting certification, candidates must be certified as a Sun Certified Programmer (SCJP), any edition. It is not necessary to be a Sun Certified Java Associate prior to taking this exam.</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0" summary="layout">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p><!-- END BREADCRUMB --> <!--googleon: index--> <!--googleoff: snippet--> <!-- BEGIN PAGETITLE ONE LINE --></p>
<h1>Sun Certified Web Component Developer (SCWCD)</h1>
<p>This certification is for developers specializing in the application of JavaServer Pages and servlet technologies used to present Web services and dynamic Web content.</p>
<p>To achieve this certification, candidates must successfully complete one exam. Prior to attempting certification, candidates must be certified as a Sun Certified Programmer (SCJP), any edition.</p>
<h1>Sun Certified Business Component Developer (SCBCD)</h1>
<p>This certification is for Enterprise JavaBeans (EJB) technology business component developers who are responsible for designing, developing, testing, deploying and integrating EJB applications.</p>
<p>To achieve certifications, candidates must successfully complete one exam. Prior to attempting certification, candidates must be certified as a Sun Certified Programmer (SCJP), any edition.</p>
<h1>Sun Certified Developer For Java Web Services (SCDJWS)</h1>
<p>This certification is for developers who create Web service for applications using Java technology components.</p>
<p>To achieve this certification, candidates must complete one exam. Prior to attempting certification, candidates must be certified as a Sun Certified Programmer (SCJP), any edition.</p>
<h1>Sun Certified Mobile Application Developer (SCMAD)</h1>
<p>This certification is for developers who create mobile applications using Java technologies for cell phones or &#8220;smart&#8221; devices.</p>
<p>To achieve this certification, candidates must succesfully complete one exam. Prior to attempting certification, candidates must be certified as a Sun Certified Programmer (SCJP), any edition.</p>
<h1>Sun Certified Enterprise Architect (SCEA)</h1>
<p>“The act of getting certified will make you a better architect.” (Humphrey Sheil, CTO, SCEA, and SCEA examiner)</p>
<p>This certification is for enterprise architects responsible for architecting and designing Java EE compliant applications with an emphasis on making the best use of Java EE features to create flexible, scalable, secure designs.</p>
<p>The SCEA certification “signifies that its holders can handle advanced design responsibilities and lead roles in creating applications. To succeed, SCEA candidates must demonstrate a deep understanding of appropriate uses of modern design architecture and current Java EE technologies for business applications.” (Ed Tittel and Dr. Bill Brogden)</p>
<p><strong>The Process</strong></p>
<p>To achieve this certification, candidates must successfully complete three elements: a knowledge-based multiple choice exam, an assignment and essay exam.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=44&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2009/08/27/java-certification-or-sun-certification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>

		<media:content url="http://www.sun.com/training/images/Sun-JavaPath.gif" medium="image" />
	</item>
		<item>
		<title>Difference between path and classpath system variables in Java</title>
		<link>http://javarocks.wordpress.com/2009/08/23/difference-between-path-and-classpath-system-variables-in-java/</link>
		<comments>http://javarocks.wordpress.com/2009/08/23/difference-between-path-and-classpath-system-variables-in-java/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 19:12:49 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=41</guid>
		<description><![CDATA[We keep all &#8220;executable files&#8221;(like .exe files) and &#8220;batch files&#8221;(like .bat) in path variable. And we keep all jar files and class files (eg: mysql-j connector) in classpath variables. So path is set according to the .exe files &#38; .bat files And classpath is set according to the .jar files &#38; .class files. Operating system [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=41&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We keep all &#8220;executable files&#8221;(like .exe files) and &#8220;batch files&#8221;(like .bat) in path variable. And we keep all jar files and class files (eg: mysql-j connector) in classpath variables.</p>
<p>So path is set according to the .exe files &amp; .bat files And classpath is set according to the .jar files &amp; .class files.</p>
<p>Operating system tries to find .exe and .bat files in path and JVM tries to find all classes in classpath.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=41&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2009/08/23/difference-between-path-and-classpath-system-variables-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Quick Reference</title>
		<link>http://javarocks.wordpress.com/2009/08/18/sql-quick-reference/</link>
		<comments>http://javarocks.wordpress.com/2009/08/18/sql-quick-reference/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 17:03:59 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=29</guid>
		<description><![CDATA[SQL Statement Syntax AND / OR SELECT column_name(s) FROM table_name WHERE condition AND&#124;OR condition ALTER TABLE ALTER TABLE table_name ADD column_name datatypeorALTER TABLE table_name DROP COLUMN column_name AS (alias) SELECT column_name AS column_alias FROM table_nameorSELECT column_name FROM table_name  AS table_alias BETWEEN SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2 CREATE DATABASE CREATE DATABASE [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=29&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th width="27%" align="left" valign="top"><span style="color:#000000;">SQL Statement</span></th>
<th width="73%" align="left" valign="top"><span style="color:#000000;">Syntax</span></th>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">AND / OR</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name<br />
WHERE condition<br />
AND|OR condition</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">ALTER TABLE</span></td>
<td align="left" valign="top"><span style="color:#000000;">ALTER TABLE table_name<br />
ADD column_name datatypeor</span><span style="color:#000000;">ALTER TABLE table_name<br />
DROP COLUMN column_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">AS (alias)</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name AS column_alias<br />
FROM table_nameor</span><span style="color:#000000;">SELECT column_name<br />
FROM table_name  AS table_alias</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">BETWEEN</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name<br />
WHERE column_name<br />
BETWEEN value1 AND value2</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">CREATE DATABASE</span></td>
<td align="left" valign="top"><span style="color:#000000;">CREATE DATABASE database_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">CREATE TABLE</span></td>
<td align="left" valign="top"><span style="color:#000000;">CREATE TABLE table_name<br />
(<br />
column_name1 data_type,<br />
column_name2 data_type,<br />
column_name2 data_type,<br />
&#8230;<br />
)</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">CREATE INDEX</span></td>
<td align="left" valign="top"><span style="color:#000000;">CREATE INDEX index_name<br />
ON table_name (column_name)or</span><span style="color:#000000;">CREATE UNIQUE INDEX index_name<br />
ON table_name (column_name)</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">CREATE VIEW</span></td>
<td align="left" valign="top"><span style="color:#000000;">CREATE VIEW view_name AS<br />
SELECT column_name(s)<br />
FROM table_name<br />
WHERE condition</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">DELETE</span></td>
<td align="left" valign="top"><span style="color:#000000;">DELETE FROM table_name<br />
WHERE some_column=some_valueor</span><span style="color:#000000;">DELETE FROM table_name<br />
(<strong>Note: </strong>Deletes the entire table!!)</span></p>
<p><span style="color:#000000;">DELETE * FROM table_name<br />
(<strong>Note: </strong>Deletes the entire table!!)</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">DROP DATABASE</span></td>
<td align="left" valign="top"><span style="color:#000000;">DROP DATABASE database_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">DROP INDEX</span></td>
<td align="left" valign="top"><span style="color:#000000;">DROP INDEX table_name.index_name (SQL  		Server)<br />
DROP INDEX index_name ON table_name (MS Access)<br />
DROP INDEX index_name (DB2/Oracle)<br />
ALTER TABLE table_name<br />
DROP INDEX index_name (MySQL)</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">DROP TABLE</span></td>
<td align="left" valign="top"><span style="color:#000000;">DROP TABLE table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">GROUP BY</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name,  		aggregate_function(column_name)<br />
FROM table_name<br />
WHERE column_name operator value<br />
GROUP BY column_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">HAVING</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name,  		aggregate_function(column_name)<br />
FROM table_name<br />
WHERE column_name operator value<br />
GROUP BY column_name<br />
HAVING aggregate_function(column_name) operator value</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">IN</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name<br />
WHERE column_name<br />
IN (value1,value2,..)</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">INSERT INTO</span></td>
<td align="left" valign="top"><span style="color:#000000;">INSERT INTO table_name<br />
VALUES (value1, value2, value3,&#8230;.)<em>or</em></span><span style="color:#000000;">INSERT INTO table_name<br />
(column1, column2, column3,&#8230;)<br />
VALUES (value1, value2, value3,&#8230;.)</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">INNER JOIN</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name1<br />
INNER JOIN table_name2<br />
ON table_name1.column_name=table_name2.column_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">LEFT JOIN</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name1<br />
LEFT JOIN table_name2<br />
ON table_name1.column_name=table_name2.column_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">RIGHT JOIN</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name1<br />
RIGHT JOIN table_name2<br />
ON table_name1.column_name=table_name2.column_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">FULL JOIN</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name1<br />
FULL JOIN table_name2<br />
ON table_name1.column_name=table_name2.column_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">LIKE</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name<br />
WHERE column_name 		LIKE pattern</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">ORDER BY</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name<br />
ORDER BY column_name [ASC|DESC]</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">SELECT</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">SELECT *</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT *<br />
FROM table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">SELECT DISTINCT</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT DISTINCT column_name(s)<br />
FROM table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">SELECT INTO</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT *<br />
INTO new_table_name [IN externaldatabase]<br />
FROM old_table_name<em>or</em></span><span style="color:#000000;">SELECT column_name(s)<br />
INTO new_table_name [IN externaldatabase]<br />
FROM old_table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">SELECT TOP</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT TOP number|percent column_name(s)<br />
FROM table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">TRUNCATE TABLE</span></td>
<td align="left" valign="top"><span style="color:#000000;">TRUNCATE TABLE table_name</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">UNION</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s) FROM table_name1<br />
UNION<br />
SELECT column_name(s) FROM table_name2</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">UNION ALL</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s) FROM table_name1<br />
UNION ALL<br />
SELECT column_name(s) FROM table_name2</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">UPDATE</span></td>
<td align="left" valign="top"><span style="color:#000000;">UPDATE table_name<br />
SET column1=value, column2=value,&#8230;<br />
WHERE some_column=some_value</span></td>
</tr>
<tr>
<td align="left" valign="top"><span style="color:#000000;">WHERE</span></td>
<td align="left" valign="top"><span style="color:#000000;">SELECT column_name(s)<br />
FROM table_name<br />
WHERE column_name operator value</span></td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=29&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2009/08/18/sql-quick-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Prepared Statements</title>
		<link>http://javarocks.wordpress.com/2009/08/18/using-prepared-statements/</link>
		<comments>http://javarocks.wordpress.com/2009/08/18/using-prepared-statements/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 16:53:48 +0000</pubDate>
		<dc:creator>ashokmohan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javarocks.wordpress.com/?p=24</guid>
		<description><![CDATA[To prevent SQL Injection Hacking with JDBC, you simply just need to use Prepared Statements, this is pretty easy to, just use a PreparedStatement object instead of a Statement Object, in your SQL replace your variables with ?&#8216;s, and use the setString, setInt, etc methods on the perpared statement object. Description of program: In this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=24&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>To prevent SQL Injection Hacking with JDBC, you simply just need to use Prepared Statements, this is pretty easy to, just use a PreparedStatement object instead of a Statement Object, in your SQL replace your variables with <code>?</code>&#8216;s, and use the <code>setString</code>, <code>setInt</code>, etc methods on the perpared statement object.</strong></p>
<p><span style="color:#333333;"><strong>Description of program:</strong></span></p>
<p><span style="color:#333333;">In this program we are going to insert data in the <span style="position:static;text-decoration:underline;"><span style="color:blue!important;font-weight:400;font-size:16px;position:static;"><span style="font-family:serif;font-weight:400;font-size:16px;position:static;">database</span></span></span> by using the <strong>setObject</strong> method of <strong><em>PreparedStatement</em></strong> interface. Before going into the details of the program we should firstly need to establish the connection with <strong>MySQL </strong>database by the help of <strong>JDBC </strong>driver. After establishing the connection now we will  insert the data in <strong> setObject</strong> method. If the data gets added in the database table then it will display a message &#8220;<strong><em>Record is added in the table.</em></strong>&#8221; otherwise it will show &#8220;<strong><em>SQL statement is not executed!</em></strong>&#8220;.</span></p>
<p><span style="color:#333333;"><strong>Description of code:</strong></span></p>
<p><span style="color:#333333;"><strong>prepareStatement(String sql):<br />
</strong>This method returns the <strong><em>PreparedStatement</em></strong> object for sending the parameterized <strong>SQL</strong> statement to the database that contains the pre-compiled SQL statement. Here the pre- compiled means once the statement has been compiled then it will not compile the same thing again. It takes the string type arguments which contains one or more &#8216;<strong>?</strong>&#8216; parameter placeholders. </span></p>
<p><span style="color:#333333;"><strong>setObject(int par_index, object obj):<br />
</strong>It is used for setting the values of parameterized index by using the given object in this method. It takes two arguments to given below:<br />
<strong>par_index:</strong> It specifies the parameter like: the first is 1, second is 2, &#8230;&#8230;<br />
<strong>object obj:</strong> It contains the parameter values to given by the users.</span></p>
<p><span style="color:#333333;"><strong>Here is the code of program:</strong></span></p>
<p><!-- start source code --><code> <span style="color:#7f0055;"><strong>import </strong></span><span style="color:#000000;">java.sql.*;</span></code></p>
<p><span style="color:#7f0055;"><strong>public class </strong></span><span style="color:#000000;">PreparedStatementSetObject</span><span style="color:#000000;">{</span><br />
<span style="color:#ffffff;"> </span><span style="color:#7f0055;"><strong>public static </strong></span><span style="color:#7f0055;"><strong>void </strong></span><span style="color:#000000;">main</span><span style="color:#000000;">(</span><span style="color:#000000;">String</span><span style="color:#000000;">[] </span><span style="color:#000000;">args</span><span style="color:#000000;">) {</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">System.out.println</span><span style="color:#000000;">(</span><span style="color:#2a00ff;">&#8220;Prepared Statement Set Array Example!&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">Connection con = </span><span style="color:#7f0055;"><strong>null</strong></span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#7f0055;"><strong>try</strong></span><span style="color:#000000;">{</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">Class.forName</span><span style="color:#000000;">(</span><span style="color:#2a00ff;">&#8220;com.mysql.jdbc.Driver&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">con = DriverManager.getConnection<br />
</span><span style="color:#000000;">(</span><span style="color:#2a00ff;">&#8220;jdbc:mysql://localhost:3306/jdbctutorial&#8221;</span><span style="color:#000000;">,</span><span style="color:#2a00ff;">&#8220;root&#8221;</span><span style="color:#000000;">,</span><span style="color:#2a00ff;">&#8220;root&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#7f0055;"><strong>try</strong></span><span style="color:#000000;">{</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">PreparedStatement prest = con.prepareStatement</span><span style="color:#000000;">(</span><span style="color:#2a00ff;">&#8220;insert into emp_sal values(?,?)&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">prest.setObject</span><span style="color:#000000;">(</span><span style="color:#990000;">1</span><span style="color:#000000;">,</span><span style="color:#2a00ff;">&#8220;Sushil&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">prest.setObject</span><span style="color:#000000;">(</span><span style="color:#990000;">2</span><span style="color:#000000;">,</span><span style="color:#990000;">15000</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#7f0055;"><strong>int </strong></span><span style="color:#000000;">n = prest.executeUpdate</span><span style="color:#000000;">()</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">System.out.println</span><span style="color:#000000;">(</span><span style="color:#000000;">n + </span><span style="color:#2a00ff;">&#8220; Record is added in the table.&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">con.close</span><span style="color:#000000;">()</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">}</span><br />
<span style="color:#ffffff;"> </span><span style="color:#7f0055;"><strong>catch </strong></span><span style="color:#000000;">(</span><span style="color:#000000;">SQLException s</span><span style="color:#000000;">){</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">System.out.println</span><span style="color:#000000;">(</span><span style="color:#2a00ff;">&#8220;SQL statement is not executed!&#8221;</span><span style="color:#000000;">)</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">}</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">}</span><br />
<span style="color:#ffffff;"> </span><span style="color:#7f0055;"><strong>catch </strong></span><span style="color:#000000;">(</span><span style="color:#000000;">Exception e</span><span style="color:#000000;">){</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">e.printStackTrace</span><span style="color:#000000;">()</span><span style="color:#000000;">;</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">}</span><br />
<span style="color:#ffffff;"> </span><span style="color:#000000;">}</span><br />
<span style="color:#000000;">}</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javarocks.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javarocks.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javarocks.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javarocks.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javarocks.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javarocks.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javarocks.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javarocks.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javarocks.wordpress.com&amp;blog=9045972&amp;post=24&amp;subd=javarocks&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javarocks.wordpress.com/2009/08/18/using-prepared-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7b89ff5f53f8671eca139c990ecae0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ashokmohan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
