<?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/"
	>

<channel>
	<title>TechieDan &#187; java</title>
	<atom:link href="http://techiedan.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://techiedan.com</link>
	<description>Your Search for The Tech Stuffs</description>
	<lastBuildDate>Thu, 09 Feb 2012 02:59:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Java &#8211; Compare Strings</title>
		<link>http://techiedan.com/2011/06/07/java-compare-strings/</link>
		<comments>http://techiedan.com/2011/06/07/java-compare-strings/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 03:58:45 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[StringUtils]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=1126</guid>
		<description><![CDATA[Comparing Strings in Java has evolved from the character comparisons to String comparisons to StringUtils comparison. Using the StringUtils to compare Strings is so much safer and faster to code.]]></description>
			<content:encoded><![CDATA[<p>During the old Java days, the String object was a object to store a string of characters. Those days to <strong>compare Strings in Java</strong>, one would have to break down the characters in the String and compare them character by character.</p>
<p>Of course fast forward to the time now, one can just use the String methods to accomplish this. All thanks to the guys behind Java. Now how do we compare it now in Java? We would use Java 6 for this.</p>
<p><img class="alignnone size-full wp-image-1134" title="Why Choose Java Language" src="http://techiedan.com/wp-content/uploads/2011/06/why-choose-java-language.jpg" alt="Why Choose Java Language" width="480" height="272" /></p>
<p>The common way people use to compare Strings is the</p>
<p><strong>String.equals();</strong> or the <strong>String.equalsIgnoreCase();</strong></p>
<pre class="brush: java; title: ; notranslate">
package com.Test;

public class TestString {

  public static void main(String... args) {

  // The 2 strings that we will test
  String testA = &quot;Welcome&quot;;
  String testB = &quot;Bye&quot;;

  // The additional String which is set to null
  String testC = null;

  if (testA.equals(testB))
    System.out.println(&quot;It is the same&quot;);
  else
    System.out.println(&quot;It is different&quot;);

  // Test it when testC is assigned to testA

  testA = testC;
  if (testA.equals(testB))
    System.out.println(&quot;Not same&quot;);

  System.exit(0);
  }

}
</pre>
<p>The above is the example of how to compare two Strings using equals. If you were to run the above code, a <strong>runtime error would occur</strong>upon running this application. How could this happen?</p>
<p>Reason is due to this syntax!</p>
<pre class="brush: java; title: ; notranslate">

testA = testC;
if (testA.equals(testB))
  System.out.println(&quot;Not same&quot;);
</pre>
<p>testA was null during the comparison. Due to this, a null pointer exception would be thrown. Before this, this was how it was checked when TechieDan was doing coding many years back.</p>
<pre class="brush: java; title: ; notranslate">

if (testA != null &amp;&amp; testA.equals(testB))
  System.out.println(&quot;Not same&quot;);
</pre>
<p>By doing so, we have <strong>eliminated the problem regarding the null pointer exception</strong>. Somehow Java has evolved and instead of writing long codes to solve this issue, so why not we try importing a library to help with the solution.</p>
<p>We could use <strong>Commons Lang 2.6</strong> (<em>as of time of writing</em>) which we could download at this page.<br />
<a title="Commons Lang download page" href="http://commons.apache.org/lang/download_lang.cgi" target="_blank">Commons Lang Download Page</a></p>
<p>Of course by including this lib into a project, one can now look at the wonders of comparison between Strings.</p>
<p>Now one can just write something like this.</p>
<pre class="brush: java; title: ; notranslate">

if (StringUtils.equals(testA, testB))
  System.out.println(&quot;Not same&quot;);
</pre>
<p>It is that simple. By importing the library to one&#8217;s project, it <strong>negates off the null part</strong> and<strong> will not throw a null pointer exception</strong> if it was caught. If one is developing for a big project, this should be the standard of doing <strong>String comparisons</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2011/06/07/java-compare-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More AutoBoxing in Java</title>
		<link>http://techiedan.com/2011/03/03/more-autoboxing-in-java/</link>
		<comments>http://techiedan.com/2011/03/03/more-autoboxing-in-java/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 06:46:47 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[autoboxing]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=1046</guid>
		<description><![CDATA[Some tips on Autoboxing to be applied in Java and for your SCJP 6 exams. The flexibility of the Java language has made programming easy and in some ways less complicated for the beginners.]]></description>
			<content:encoded><![CDATA[<p>Previously when we touched on <a title="AutoBoxing in Java 5" href="http://techiedan.com/2009/10/20/autoboxing-java-5/">AutoBoxing in Java</a>, we only had a glimpse of what Java 5 onwards could do. If you are studying for <strong>SCJP 6</strong> (<em>the latest SCJP as of date of print</em>), this will definitely help yourself to be prepared for the Exam. Now let’s have a look at some of the examples.</p>
<p><img class="alignnone size-full wp-image-1055" title="Autoboxing SCJP Java 6 tips" src="http://techiedan.com/wp-content/uploads/2011/03/autoboxing-SCJP-tips.jpg" alt="Autoboxing SCJP Java 6 tips" width="312" height="309" /></p>
<p>It is definitely correct if one does a <strong>comparison of numeric values</strong> like the following example.</p>
<pre class="brush: java; title: ; notranslate">
Integer first = 1;
int one = 1;

if (one == first)
  System.out.println(&quot;Same value&quot;);
</pre>
<p>Now what about if I were to do it this way?</p>
<pre class="brush: java; title: ; notranslate">
Integer First = 1;
int one = first;

System.out.println(&quot;Value of one is: &quot; + one);
</pre>
<p>So now we know that <strong>Integer and int can co-relate</strong> with each another ever since AutoBoxing was introduced into Java 5. Now here&#8217;s a question. Which of these is illegal?</p>
<pre class="brush: java; title: ; notranslate">
Integer a = 01;
Integer string = null;
Integer lock = 2.4;
Integer enum = 1;
</pre>
<p>The answer to this is a little bit tricky.</p>
<p>First there are only 2 right answers. The answers for this little quiz is Number 1 and 2 is legal. Yes, and this will be the outcome if they were both printed seperately.</p>
<pre class="brush: plain; title: ; notranslate">
Integer a is 1
Integer string is null
</pre>
<p>Number 3 and 4 are both deemed illegal and would not even be able to compile due to the <strong>value 2.4 is a double</strong> that cannot be casted to Integer. For Number 4, <strong>enum is a reserved word</strong>. Some of us might even get confused as to why number 2 is right? Shouldn&#8217;t string be a reserved word?</p>
<p>Of course, <strong><span style="color: #3366ff;">String</span> is a reserved word</strong>, while <strong><span style="color: #339966;">string </span>is not a reserved word</strong>. One is uppercase, one is lowercase. Java is indeed more flexible compared to the Java 1.4 days.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2011/03/03/more-autoboxing-in-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hibernate Error : exception setting property value</title>
		<link>http://techiedan.com/2009/12/17/hibernate-error-exception-setting-property-value/</link>
		<comments>http://techiedan.com/2009/12/17/hibernate-error-exception-setting-property-value/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 07:25:38 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=709</guid>
		<description><![CDATA[<p>Been playing around with <a title="Hibernate Mapping Site" href="http://www.hibernate.org" target="_blank">Hibernate</a> and mapping classes with Java. A reason why Hibernate is useful is so to facilitate users to stop writing pure SQL for queries and reduce code redundancy. A slight note, Hibernate also works well with the <strong>.NET platform</strong>.</p>
<p></p>
<p>Though there was this error which TechieDan experienced</p>
<p><em>org.springframework.orm.hibernate3.HibernateSystemException: [...]]]></description>
			<content:encoded><![CDATA[<p>Been playing around with <a title="Hibernate Mapping Site" href="http://www.hibernate.org" target="_blank">Hibernate</a> and mapping classes with Java. A reason why Hibernate is useful is so to facilitate users to stop writing pure SQL for queries and reduce code redundancy. A slight note, Hibernate also works well with the <strong>.NET platform</strong>.</p>
<p><img class="alignnone size-full wp-image-712" title="Hibernate Mapping Error" src="http://techiedan.com/wp-content/uploads/2009/12/error-hibernate.jpg" alt="Hibernate Mapping Error" width="305" height="293" /></p>
<p>Though there was this error which TechieDan experienced</p>
<blockquote><p><span style="color: #ff0000;"><em>org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tm.ccpm.biz.domain.product.ProductSubCategory.setIdelivery;</em></span></p></blockquote>
<p>Surprisingly the mistake wasn&#8217;t software based. After looking through Hibernate.org websites and other sites for help, it was because of a simple mistake. While <strong>creating the field of IDELIVERY</strong> into the table, the default value was <span style="color: #0000ff;"><strong>null</strong></span>, and considering that the <strong>IDELIVERY column is integer</strong>, it should be defaulted to a default value. So since the column was created earlier with a <strong>null value</strong>, all that was needed to be done is to update the data in the table to repair this error.</p>
<p>Here&#8217;s what I did and it finally is running once again.</p>
<blockquote><p>update TABLENAME set IDELIVERY = 0;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/12/17/hibernate-error-exception-setting-property-value/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Multiple Values Form:Select in Spring Java</title>
		<link>http://techiedan.com/2009/11/17/multiple-values-form-select-spring-java/</link>
		<comments>http://techiedan.com/2009/11/17/multiple-values-form-select-spring-java/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 09:03:34 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Spring 2.5]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=663</guid>
		<description><![CDATA[<p>Have been searching how to do multiple values in Spring.</p>
<p><strong>What is Spring?</strong></p>
<p><a title="Spring Java" href="http://www.springsource.org/" target="_blank"></a></p>
<p>There are no complications when displaying only a single id or a value while using spring and form taglib by doing this.</p>
<p>&#60;form:select path=&#8221;prospect.wholeSaleId&#8221; items=&#8221;${List}&#8221;
itemLabel=&#8221;wholeSaleId&#8221; itemValue=&#8221;wholeSaleId&#8221;&#62;</p>
<p>Now itemLabel would display the wholeSaleId value. The problem now is how to display let&#8217;s say [...]]]></description>
			<content:encoded><![CDATA[<p>Have been searching how to do multiple values in Spring.</p>
<p><strong>What is Spring?</strong></p>
<p><a title="Spring Java" href="http://www.springsource.org/" target="_blank"><img class="alignnone size-full wp-image-672" title="Spring Java" src="http://techiedan.com/wp-content/uploads/2009/11/spring-java.jpg" alt="Spring Java" width="400" height="174" /></a></p>
<p>There are no complications when displaying only a single id or a value while using spring and form taglib by doing this.</p>
<blockquote><p>&lt;form:select path=&#8221;prospect.wholeSaleId&#8221; items=&#8221;${List}&#8221;<br />
itemLabel=&#8221;wholeSaleId&#8221; itemValue=&#8221;wholeSaleId&#8221;&gt;</p></blockquote>
<p>Now itemLabel would display the wholeSaleId value. The problem now is how to display let&#8217;s say wholeSaleId &#8211; CustomerName in the itemLabel. One workaround is to use the &lt;c:forEach&gt; core taglib.</p>
<blockquote><p>&lt;form:select path=&#8221;prospect.wholeSaleId&#8221;&gt;<br />
&lt;c:forEach items=&#8221;${List}&#8221; var=&#8221;prospect&#8221;&gt;<br />
&lt;form:option value=&#8221;${prospect.wholeSaleId}&#8221;&gt;&lt;c:out value=&#8221;${prospect.wholeSaleId}&#8221;/&gt; &#8211; &lt;c:out value=&#8221;${prospect.companyName}&#8221;/&gt;&lt;/form:option&gt;<br />
&lt;/c:forEach&gt;<br />
&lt;/form:select&gt;</p></blockquote>
<p>Now by doing so, you are now able to display two value. The HTML equivalent of such will now display like this. (<em>Assuming it has only 3 values</em>)</p>
<blockquote><p>&lt;select name=&#8221;wholeSaleId&#8221;&gt;<br />
&lt;option value=&#8221;wholeSaleIdValue1&#8243;&gt;wholeSaleIdValue1 &#8211; companyName1&lt;/option&gt;<br />
&lt;option value=&#8221;wholeSaleIdValue2&#8243;&gt;wholeSaleIdValue2 &#8211; companyName2&lt;/option&gt;<br />
&lt;option value=&#8221;wholeSaleIdValue3&#8243;&gt;wholeSaleIdValue3 &#8211; companyName3&lt;/option&gt;<br />
&lt;/select&gt;</p></blockquote>
<p>So there you have it. A workaround for the form tag in Spring Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/11/17/multiple-values-form-select-spring-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox 3.6 Update Your Java</title>
		<link>http://techiedan.com/2009/10/22/firefox36-update-java/</link>
		<comments>http://techiedan.com/2009/10/22/firefox36-update-java/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 02:58:44 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=596</guid>
		<description><![CDATA[<p>Good news to Firefox browser users. <strong>Firefox 3.6 will be out some time in November 2009</strong>. Using Firefox really helps one to debug and with all the additional plugins and add-ons one can get, Firefox 3.6 is going to be a blast. Developers would love it, Web surfers would love it (<em>if it uses even [...]]]></description>
			<content:encoded><![CDATA[<p>Good news to Firefox browser users. <strong>Firefox 3.6 will be out some time in November 2009</strong>. Using Firefox really helps one to debug and with all the additional plugins and add-ons one can get, Firefox 3.6 is going to be a blast. Developers would love it, Web surfers would love it (<em>if it uses even lesser memory</em>). Though one critical news is that web surfers, please please update your Firefox with the newest Java Update. That&#8217;s because starting with <strong>Firefox 3.6</strong>, Java-based applications will NOT work unless one is running <strong>Java version 6 Update 10</strong> or newer.</p>
<p><img class="alignnone size-full wp-image-597" title="FireFox Eating IE" src="http://techiedan.com/wp-content/uploads/2009/10/firefox.jpg" alt="FireFox Eating IE" width="517" height="500" /></p>
<p>Of course if you decided to not to install it, there&#8217;s no harm done. It just won&#8217;t display. Though, why not just get the updated Java version and be hassle free. Here are some steps to follow.</p>
<ul>
<li><a title="Java" href="http://www.java.com/"><strong>Update your Java</strong></a><strong> before updating to Firefox 3.6 and later versions</strong>. By updating your Java to the latest version, you will also enable support for the new <a title="Java Newest Update" href="http://www.java.com/en/download/help/features_java6update10.xml">Java plug-in</a>. This plug-in not only runs Java applications faster in your web browser, but it also adds some cool new features, such as the ability to click and drag certain Java applications from inside your web browser to your desktop!<br />
OR</li>
<li>Stay with your current version of Firefox (3.5 or older). Newer versions of Java will still work with versions of Firefox older than 3.6.</li>
</ul>
<p>This news is in reference to <strong>Sun Java</strong>&#8216;s website taken <a title="Firefox New Java Plugin" href="http://www.java.com/en/download/faq/firefox_newplugin.xml" target="_blank">HERE</a>. Of course if you don&#8217;t know what version you&#8217;re using, check it by going to <a title="Installed Java version" href="http://www.java.com/en/download/installed.jsp" target="_blank">THIS SITE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/10/22/firefox36-update-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Autoboxing in Java 5</title>
		<link>http://techiedan.com/2009/10/20/autoboxing-java-5/</link>
		<comments>http://techiedan.com/2009/10/20/autoboxing-java-5/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 04:00:11 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[autoboxing]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdk 5]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=564</guid>
		<description><![CDATA[<p>Surprisingly after Sun Microsystems included the <strong>JDK 5</strong> and now it&#8217;s already JDK 6. JDK 7 is currently in closed beta mode and available for testing which shortly would be announced to be available sometime next year with a different syntax in certain codes.</p>
<p>Did some code sampling and simple display to show what has changed [...]]]></description>
			<content:encoded><![CDATA[<p>Surprisingly after Sun Microsystems included the <strong>JDK 5</strong> and now it&#8217;s already JDK 6. JDK 7 is currently in closed beta mode and available for testing which shortly would be announced to be available sometime next year with a different syntax in certain codes.</p>
<p>Did some code sampling and simple display to show what has changed from <strong>Java 1.4 to Java 5</strong>. The changes were major. From here I am going to explain is <strong>Integer and int</strong> data type the same? This is what we call the concept of <span style="color: #0000ff;"><strong>AUTOBOXING</strong></span>.</p>
<p><img class="alignnone size-full wp-image-580" title="AutoBoxing Java" src="http://techiedan.com/wp-content/uploads/2009/10/boxes.jpg" alt="AutoBoxing Java" width="510" height="358" /></p>
<p>Some basic Integer and int Autoboxing comparison done.</p>
<pre class="brush: java; title: ; notranslate">

public class TestInt {

public static void main(String[] args) {

Integer e = 1;
int f = 1;
//Delclare variables

if (e == f)
System.out.println(&quot;gila same&quot;);
else
System.out.println(&quot;The value is Not the same&quot;);

System.exit(0); //Exit System

}

}
</pre>
<p>If you are doing this code, try to copy this onto your IDE and compile it. Most probably you will get the ClassCastException or just a display saying &#8220;<span style="color: #0000ff;"><em>The value is not the same</em></span>&#8221; if you&#8217;re running this code on <strong>JDK 1.4 or lower</strong>. The amazing feat by <strong>Java 5 and above</strong> is that now Java would know that though Integer and int are two different variable types, it will try to <strong>assimilate both to appear the same</strong>.</p>
<p>The resulting result is it will compare both the different data types and presto, Line 10 will display &#8220;<span style="color: #0000ff;"><em>Gila Same</em></span>&#8220;.</p>
<p><em>Additional Notes : There are many more things Java has changed since JDK 1.4. More articles and examples will be out soon for this programming language.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/10/20/autoboxing-java-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set Up JDK in Eclipse</title>
		<link>http://techiedan.com/2009/10/19/set-up-jdk-in-eclipse/</link>
		<comments>http://techiedan.com/2009/10/19/set-up-jdk-in-eclipse/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 07:00:04 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JRE]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=554</guid>
		<description><![CDATA[<p>Java enthusiasts and coders and programmers alike, how many of you are using Eclipse as your IDE to do your codes. For those in the Java field but still trying to find a good IDE, I would recommend Eclipse. Just so happens that Eclipse codename their newest version with Galileo. Instead of versifying their release, [...]]]></description>
			<content:encoded><![CDATA[<p>Java enthusiasts and coders and programmers alike, how many of you are using Eclipse as your IDE to do your codes. For those in the Java field but still trying to find a good IDE, I would recommend Eclipse. Just so happens that Eclipse codename their newest version with Galileo. Instead of versifying their release, it&#8217;s now codenamed.</p>
<p>Here&#8217;s the part of a Welcome Screen once Eclipse is freshly installed.</p>
<p><img class="alignnone size-full wp-image-555" title="Eclipse Galileo Java" src="http://techiedan.com/wp-content/uploads/2009/10/eclipse-java.jpg" alt="Eclipse Galileo Java" width="694" height="476" /></p>
<p>As a Techie, TechieDan will show how to setup your Eclipse to run with your JDK. By default your IDE will try to run with your JRE, but by doing so you will be limited with the stuffs you can do without the whole JDK package.</p>
<p>How to setup your JDK in Eclipse IDE.</p>
<p><img class="alignnone size-full wp-image-557" title="Eclipse Menu Preferences" src="http://techiedan.com/wp-content/uploads/2009/10/eclipse-preferences.jpg" alt="Eclipse Menu Preferences" width="524" height="353" /></p>
<p><img title="Eclipse JRE settings" src="http://techiedan.com/wp-content/uploads/2009/10/eclipse-jres.jpg" alt="Eclipse JRE settings" width="564" height="467" /></p>
<p><img title="Include JDK 6 Eclipse" src="http://techiedan.com/wp-content/uploads/2009/10/eclipse-jre-include.jpg" alt="Include JDK 6 Eclipse" width="524" height="530" /></p>
<blockquote>
<ol>
<li>From the above screen, once Eclipse is started up, go to <strong>Windows Option &gt; Preferences</strong>.</li>
<li>Look for <strong>Java &gt; Installed JREs</strong>.</li>
<li>Click on <strong>Add &gt; Next (Standard VM)</strong>.</li>
<li>Then Locate Directory of your installed JDK. Then clicked finish.</li>
<li>Finally the screen will return back to the selection of JREs, now <strong>select your JDK</strong> option.</li>
</ol>
</blockquote>
<p>As can be seen from above, TechieDan is using JDK 6 to compile and run the Java programs.</p>
<p><span style="text-decoration: underline;"><strong>Why use Eclipse?</strong></span></p>
<ul>
<li>It&#8217;s free</li>
<li>It&#8217;s open source &#8211; additional programmers from all walk of life.</li>
<li>It integrates with lots of other plugin</li>
<li>Other than Java, there&#8217;s also an Eclipse IDE for C and PHP</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Now that I have setup my Eclipse, what else should I do? </strong></span></p>
<p>Well, this is where you should start learning how to write and begin writing a simple Hello World java program.</p>
<p><span style="text-decoration: underline;"><strong>Mentioning about Eclipse, where to get this marvelous IDE?</strong></span></p>
<p>The only place to get it all is at Eclipse&#8217;s main website. To download the IDE go to <strong><a title="Eclipse Download Page" href="http://www.eclipse.org/downloads/" target="_blank">THIS LINK</a></strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/10/19/set-up-jdk-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Java Why PreparedStament not Statement</title>
		<link>http://techiedan.com/2009/03/17/java-why-preparedstament-not-statement/</link>
		<comments>http://techiedan.com/2009/03/17/java-why-preparedstament-not-statement/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 01:45:04 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=382</guid>
		<description><![CDATA[a programmer uses PreparedStatement instead of Statement when doing SQL queries in my projects. I found out that I can indelibly hacked into the system when I use SQL injection]]></description>
			<content:encoded><![CDATA[<p>This is a story of why is it that me, a programmer uses <strong>PreparedStatement </strong>instead of <strong>Statement</strong> when doing SQL queries in my projects.</p>
<p>After what seemed to be a so called secure connection to my database and login system, written by a so called 3rd party, I found out that I can indelibly hack into the system when I use <strong>SQL injection</strong>. Huh? What&#8217;s this? You see, all I need to know at times is your username and I can find ways to login.</p>
<p>But that&#8217;s just logging in, what about dropping your table. Here&#8217;s an example of why</p>
<blockquote>
<pre class="jive-pre"><code class="jive-code jive-java"><span style="color: navy;"><strong>public</strong></span> List processUser(String username, String password)
   <span style="color: navy;"><strong>throws</strong></span> SQLException
<span style="color: navy;">{</span>
   String query = <span style="color: red;">"SELECT * FROM userTbl WHERE id = '"</span> + username + <span style="color: red;">
"' and pass= '"</span> + password +</code><code class="jive-code jive-java"><span style="color: red;"> "'"</span></code><code class="jive-code jive-java">;
   ResultSet rs = this.connection.executeQuery(query);
   <span style="color: darkgreen;">// ... process results ...</span>
<span style="color: navy;">}</span>
</code></pre>
</blockquote>
<p>The above seems very innocently innocent. Now imagining a login page. The user enters something weird. For example in password field he/she does this.</p>
<blockquote><p><span style="color: #3366ff;">abc&#8217; or a = &#8216;a</span></p></blockquote>
<p>Now how would it look like.</p>
<blockquote>
<pre class="jive-pre"><code class="jive-code jive-java">String query = <span style="color: red;">"SELECT * FROM userTbl WHERE id = '"</span> + username +
<span style="color: red;">"' and pass= '"</span> + </code><span style="color: #3366ff;">abc' or a = 'a </span><code class="jive-code jive-java">+</code><code class="jive-code jive-java"><span style="color: red;"> "'"</span></code><code class="jive-code jive-java">;

</code></pre>
</blockquote>
<p>Now can you finally see the dangerousness of using Statement. The difference in using PreparedStatement I can now control what the user enters. To see some of my previous SQL queries using PreparedStatement refer <a title="SQL PreparedStatement" href="http://techiedan.com/2008/03/15/writing-sql-statement-with-loop-objects/" target="_blank">this previous post about SQL</a>.</p>
<p>So always be aware of the security of your codes. Hope this bring some enlightenment to the programmers out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2009/03/17/java-why-preparedstament-not-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up your JDK JAVA_HOME</title>
		<link>http://techiedan.com/2008/10/30/setting-up-your-jdk-java-home/</link>
		<comments>http://techiedan.com/2008/10/30/setting-up-your-jdk-java-home/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 00:20:14 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JDK]]></category>

		<guid isPermaLink="false">http://techiedan.com/?p=168</guid>
		<description><![CDATA[<p></p>
<p>Setting up your Java environment to work on is as easy as how it seems to be. With Sun now offering executable JDK program, nothing much needs to be done.</p>
<p>As of date, current JDK is the <a title="Java 6 Download" href="http://java.sun.com/javase/downloads/" target="_blank">JDK 6.0 kit</a> which was said to be powerful that the previous versions beforehand. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin-left: 5px; margin-right: 5px;" title="Sun Microsystem" src="http://img296.imageshack.us/img296/5360/sunlp1.jpg" alt="Sun Java" width="89" height="44" /></p>
<p>Setting up your Java environment to work on is as easy as how it seems to be. With Sun now offering executable JDK program, nothing much needs to be done.</p>
<p>As of date, current JDK is the <a title="Java 6 Download" href="http://java.sun.com/javase/downloads/" target="_blank">JDK 6.0 kit</a> which was said to be powerful that the previous versions beforehand. Download and then install and voila, you&#8217;re good to run. All you need is to go into the bin folder of the JDK and run the javac and the java commands. This time I won&#8217;t be using an IDE though to explain t</p>
<p>he procedure.</p>
<p>If you wanna set up your environment variables on Windows, here&#8217;s how you do it on Windows XP.</p>
<blockquote style="background-color:#F0E68C"><p>Right Click My Computer &gt; Properties &gt; Advanced &gt; Environment Variables.</p>
<p>Under User Variable for Users &gt; New. Type the following.</p>
<p>Variable Name : JAVA_HOME<br />
Variable Value : [Location of JDK folder] <em>ex: D:\JDK6.0</em></p></blockquote>
<p>After this you may now freely use your JDK to compile and run your code anywhere on the PC environment. I will touch on the compilation part using pure JDK later instead of an IDE in the coming parts.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2008/10/30/setting-up-your-jdk-java-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing SQL statement with Loop Objects</title>
		<link>http://techiedan.com/2008/03/15/writing-sql-statement-with-loop-objects/</link>
		<comments>http://techiedan.com/2008/03/15/writing-sql-statement-with-loop-objects/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 16:19:36 +0000</pubDate>
		<dc:creator>techieDan</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techiedan.com/2008/03/15/writing-sql-statement-with-loop-objects/</guid>
		<description><![CDATA[<p>Coding have never been the same!!! Some bad habits when writing codes which are redundant</p>
String[] special = {"a1","a2","a3","a4"};  

Connection con = null;  

PreparedStatement stmt = null;  

PreparedStatement stmt2 = null;  

ResultSet rs = null;  

ResultSet rs2 = null;  

Class.forName ("com.mysql.jdbc.Driver")  

conn = DriverManager.getConnection (url, userName, password);  

String [...]]]></description>
			<content:encoded><![CDATA[<p>Coding have never been the same!!! Some bad habits when writing codes which are redundant</p>
<pre width="50%">String[] special = {"a1","a2","a3","a4"};  

Connection con = null;  

PreparedStatement stmt = null;  

PreparedStatement stmt2 = null;  

ResultSet rs = null;  

ResultSet rs2 = null;  

Class.forName ("com.mysql.jdbc.Driver")  

conn = DriverManager.getConnection (url, userName, password);  

String SQL_QUERY = " SELECT count(*) FROM tblABC WHERE " +
" name_tennis LIKE = ? ";  

String SQL_QUERY2 = " SELECT count(*) FROM tblABC WHERE " +
" name_swimwear LIKE = ? ";  

stmt = con.prepareStatement(SQL_QUERY);  

stmt2 = con.prepareStatement(SQL_QUERY2);  

for (int i=0;i&lt;special[i].length;i++) {<special.length;i++)></special.length;i++)>  

      stmt.setString(1,special[i]);  

      rs = stmt.executeQuery();  

      if (rs.next()) {  

         /* More work here */  

      }  

}  

for (int i=0;i<special.length;i++)></special.length;i++)>i&lt;special[i].length;i++) {  

stmt2.setString(1,special[i]);  

      rs2 = stmt2.executeQuery();  

      if (rs2.next()) {  

         /* More work here */  

      }  

}</pre>
<p>The above is a very bad example of coding. It might work, and run smoothly but it&#8217;s really bad coding. What one should do is to not to let the code be redundant. For example, put both statements into one the loop.</p>
<pre width="50%">
for (int i=0;i&lt;special[i].length;i++) {  

      stmt.setString(1,special[i]);  

      rs = stmt.executeQuery();  

      if (rs.next()) {  

         /* More work here */  

      }      stmt2.setString(1,special[i]);  

      rs2 = stmt2.executeQuery();  

      if (rs2.next()) {  

         /* More work here */  

      }  

}</pre>
<p>What&#8217;s the use of this? Well, iif you have an object or rather a Bean to set into, you don&#8217;t have to loop and reloop. All can be done in the same loop. Well, hope this brings about some bad habits of coding java.</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedan.com/2008/03/15/writing-sql-statement-with-loop-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

