<?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>Another Josescalia's Web Blog</title>
	<atom:link href="http://josescalia.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://josescalia.wordpress.com</link>
	<description>Just another Josescalia web blog</description>
	<lastBuildDate>Sat, 21 Jan 2012 16:31:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='josescalia.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/d62fdc9336bea0ffec60d492b66c27bb?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Another Josescalia's Web Blog</title>
		<link>http://josescalia.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://josescalia.wordpress.com/osd.xml" title="Another Josescalia&#039;s Web Blog" />
	<atom:link rel='hub' href='http://josescalia.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using TestNG on Spring Framework and Hibernate Test Case</title>
		<link>http://josescalia.wordpress.com/2012/01/21/using-testng-on-spring-framework-and-hibernate-test-case/</link>
		<comments>http://josescalia.wordpress.com/2012/01/21/using-testng-on-spring-framework-and-hibernate-test-case/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 16:31:44 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=232</guid>
		<description><![CDATA[Dear readers, at the time I wrote this article, I just have 2 months of being an employee at the IT Consultant Company in Jakarta, Indonesia. But that&#8217;s not what I want to share in this article. In this company, I was expected to follow the java development stack which is applied in this company. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=232&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><a href="http://josescalia.files.wordpress.com/2012/01/spring-hibernate.png"><img class="alignleft  wp-image-234" title="spring-hibernate" src="http://josescalia.files.wordpress.com/2012/01/spring-hibernate.png?w=271&#038;h=222" alt="" width="271" height="222" /></a>Dear readers, at the time I wrote this article, I just have 2 months of being an employee at the IT Consultant Company in Jakarta, Indonesia. But that&#8217;s not what I want to share in this article. In this company, I was expected to follow the java development stack which is applied in this company. The Spring Framework and Hibernate are include.</p>
<p style="text-align:justify;">I&#8217;ve been 6 years in Java programming language, but I admit, I never involve Hibernate framework as an <a title="Object Relational Mapping" href="http://en.wikipedia.org/wiki/Object-Relational_Mapping" target="_blank">ORM(Object Relational Mapping)</a> method on my projects development stack. While Spring Framework, I&#8217;ve been using it since 2 years ago. This condition force me to do a little adaptation of this Hibernate Framework.</p>
<p style="text-align:justify;">I often met some difficulties which is stress me so much, when the codes of the dao layer using a <a title="Hibernate Criteria" href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html" target="_blank">hibernate criteria</a>. For a few developers who always using hibernate framework, it should be easier to use hibernate criteria, but for me, it really stress me so much.</p>
<p style="text-align:justify;">To find a method on a dao layer work or not, sometimes it wouldn&#8217;t so effective to test it by deploying whole application just only to test one method. And I decide to use <a title="Unit test" href="http://en.wikipedia.org/wiki/Unit_testing" target="_blank">unit-test</a> when testing dao layer methods, so I don&#8217;t need to deploy whole application.</p>
<p style="text-align:justify;">Okay, below is the step to create a unit-test in order to test the methods on dao layer which created using Spring Framework and hibernate:</p>
<ol>
<li>Create a hibernate configuration file, Spring Context file, and all those supported files, and put them onto test/resources folder just like the picture below:<a href="http://josescalia.files.wordpress.com/2012/01/folderstrukturtestdaospring.png"><img class="aligncenter size-full wp-image-233" title="FolderStrukturTestDaoSpring" src="http://josescalia.files.wordpress.com/2012/01/folderstrukturtestdaospring.png" alt="" width="356" height="390" /></a></li>
<li>Create a file called TestDao, and put it onto test/java folder. The codes of the files is below:</li>
</ol>
<p><pre class="brush: java;">
package com.mojo.maven.test;

import com.mojo.maven.dao.NewsCategoryDao;
import com.mojo.maven.dao.NewsDao;
import com.mojo.maven.model.News;
import com.mojo.maven.model.NewsCategory;
import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.context.ManagedSessionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

@ContextConfiguration(locations={&quot;classpath*:maven1ApplicationContext-test.xml&quot;})
public class TestDao extends AbstractTestNGSpringContextTests{
    private Logger logger = Logger.getLogger(TestDao.class);

    @Autowired
    public SessionFactory sessionFactory;
    private Session session;

    @Autowired
    private NewsDao newsDao;

    @Autowired
    private NewsCategoryDao newsCategoryDao;

    /**
     * Inisialisasi hibernate context sebelum test
     */
    @BeforeMethod
    void init() {
        logger.debug(&quot;init session factory&quot;);
        session = sessionFactory.openSession();
        ManagedSessionContext.bind(session);
    }

    /**
     * cleanup hibernate context setelah test
     */
    @AfterMethod
    void destroy() {
        logger.debug(&quot;destroy session factory&quot;);
        session.close();
        ManagedSessionContext.unbind(sessionFactory);
    }

    @Test
    public void testGetNews(){
        News news = newsDao.getById(1);
        logger.info(&quot;News ID : &quot; + news.getId());
        logger.info(&quot;News Title : &quot; + news.getNewsTitle());
        logger.info(&quot;News URL : &quot; + news.getNewsUrl());
        logger.info(&quot;News Category : &quot; + news.getNewsCategory().getCategoryName());
        logger.info(&quot;News Category Description : &quot; + news.getNewsCategory().getCategoryDescription());
    }
}
</pre></p>
<p style="text-align:justify;">What we have to pay attention on the class are, the class have an annotation <strong>@ContextConfiguration</strong> and extends <strong>AbstractTestNGSpringContextTests </strong>class which is provide as a base class to use it as a test class for <a title="TestNG" href="http://testng.org/doc/index.html" target="_blank">TestNG Framework</a>. Also on the annotation <strong>@ContextConfiguration  </strong>defined the location of the Spring Context, so the compiler can find a Spring Context file when the execution is triggered.</p>
<p style="text-align:justify;">The next thing which have to note are 2 methods which is defined on the class, those are <strong>void init()</strong> method and <strong>void destroy()</strong> method<strong>.</strong> void init() method, given an annotation <strong>@BeforeMethod </strong>which have a function as an hibernate context initializations before all other the test method executed. While <strong>void destroy()</strong> method given an annotation <strong>@AfterMethod </strong>which have a function to close a hibernate session after all test method executed.</p>
<p style="text-align:justify;">Well, that&#8217;s all that I can share for this time. If you feel the codes need more improvement, so go head, to make it perfect.</p>
<p style="text-align:justify;">I&#8217;ll hope it usefull.</p>
<p style="text-align:justify;">Josescalia</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=232&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2012/01/21/using-testng-on-spring-framework-and-hibernate-test-case/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2012/01/spring-hibernate.png" medium="image">
			<media:title type="html">spring-hibernate</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2012/01/folderstrukturtestdaospring.png" medium="image">
			<media:title type="html">FolderStrukturTestDaoSpring</media:title>
		</media:content>
	</item>
		<item>
		<title>The quick brown fox jump over the lazy dog</title>
		<link>http://josescalia.wordpress.com/2011/07/10/the-quick-brown-fox-jump-over-the-lazy-dog/</link>
		<comments>http://josescalia.wordpress.com/2011/07/10/the-quick-brown-fox-jump-over-the-lazy-dog/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 03:34:37 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=208</guid>
		<description><![CDATA[One day, I read, that this sentence &#8220;the quick brown fox jump over the lazy dog&#8221; contains all the character of the alphabet,  just because I&#8217;m so curious,  I thought to create a simple java application that checks whether the sentence is actually using all the letters in the alphabet or not. The pseudo code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=208&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><img class="alignright" title="The quick brown fox jumps over the lazy dog" src="http://josescalia.files.wordpress.com/2011/07/foxdog.jpg?w=125&#038;h=107" alt="The Quick Brown Fox" width="125" height="107" /></p>
<p style="text-align:justify;">One day, I read, that this sentence <strong>&#8220;the quick brown fox jump over the lazy dog&#8221; </strong>contains all the character of the alphabet,  just because I&#8217;m so curious,  I thought to create a simple java application that checks whether the sentence is actually using all the letters in the alphabet or not.</p>
<p style="text-align:justify;">The pseudo code of the application will look like this:</p>
<ol>
<li>Declare the string.</li>
<li>Remove all spaces between the words from the sentence.</li>
<li>Remove duplicate character.</li>
<li>Convert the string into Character Arrays.</li>
<li>Sort the Character Arrays.</li>
<li>Loop the Character Array and print out to console.</li>
</ol>
<p>First, I need to create a function that can remove duplicate character from a given parameter and the return of the function have to be a string. Ok, here&#8217;s the code:</p>
<p><pre class="brush: java;">
    public static String removeDuplicates(String s) {
        StringBuilder noDupes = new StringBuilder();
        for (int i = 0; i &lt; s.length(); i++) {
            String si = s.substring(i, i + 1);
            if (noDupes.indexOf(si) == -1) {
                noDupes.append(si);
            }
        }
        return noDupes.toString();
    }
</pre></p>
<p>The function above using <em>StringBuilder</em> object as a container to process removing duplicate character, and the function will return the string formed by <em>StringBuilder </em>object. And then, I will use this function in the application. Ok, here&#8217;s the code:</p>
<p><pre class="brush: java;">
import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * User: Josescalia
 * Date: 7/8/11
 * Time: 8:24 PM
 * To change this template use File | Settings | File Templates.
 */
public class ArrayTest {
    public static void main(String[] args) {
        //the string declaration
        String sStr = &quot;the quick brown fox jumps over the lazy dog&quot;;
        //remove the spaces
        sStr = sStr.replace(&quot; &quot;, &quot;&quot;);
        //remove the duplicate character using the function
        sStr = removeDuplicates(sStr);
        //Convert string into Character Array
        char[] a = sStr.toCharArray();
        //Sort the Array
        Arrays.sort(a);
        //let's loop and print out...is is correct, using all the character of the alphabet ????
        for (int i = 0; i &lt; a.length; i++) {
            char c = a[i];
            System.out.print(c);
        }
        //it's true :P
    }

    public static String removeDuplicates(String s) {
        StringBuilder noDupes = new StringBuilder();
        for (int i = 0; i &lt; s.length(); i++) {
            String si = s.substring(i, i + 1);
            if (noDupes.indexOf(si) == -1) {
                noDupes.append(si);
            }
        }
        return noDupes.toString();
    }
}

</pre></p>
<p>Well, that&#8217;s all. Feel free to use and explore for your creations and needs.</p>
<p>I Hope that&#8217;s usefull</p>
<p>Thanks</p>
<p>Josescalia</p>
<p><em><br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=208&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2011/07/10/the-quick-brown-fox-jump-over-the-lazy-dog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2011/07/foxdog.jpg?w=209" medium="image">
			<media:title type="html">The quick brown fox jumps over the lazy dog</media:title>
		</media:content>
	</item>
		<item>
		<title>Squid Proxy, and Adzapper in Windows</title>
		<link>http://josescalia.wordpress.com/2010/10/18/squid-proxy-and-adzapper-in-windows/</link>
		<comments>http://josescalia.wordpress.com/2010/10/18/squid-proxy-and-adzapper-in-windows/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 05:29:33 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=194</guid>
		<description><![CDATA[Browsing website on the internet with high speed data access is a separate pleasure for some people including me. To open a site with no waiting time to load the page of a website is always a dream. But sometimes we’re getting bad-mood if we face a situation where the website that we would like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=194&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Browsing website on the internet with high speed data access is a separate pleasure for some people including me. To open a site with no waiting time to load the page of a website is always a dream. But sometimes we’re getting bad-mood if we face a situation where the website that we would like to open are taking too long to load, because it have to wait each elements on the website to download to our computer. Images, swift files and any other elements.</p>
<p style="text-align:justify;">A web page made up-over elements such as images, text, swift files, and others. When we want to open a web page, elements are downloaded to our computer and placed in the temporary folder of the browser we use. We can enjoy a web page perfectly after all the elements that make up the page is finished to download.</p>
<p style="text-align:justify;">We may have a habit to visit the same website every day, especially right now, the social community era, facebook, twitter, myspace, we visit these websites just to make status, commenting a status and other activities. The same images, swift files, will be downloaded every time we visit those websites. This is actually a routine that we can make a strategy about.<br />
Proxy is a tool that we can use to create a strategy for this routine. The proxy has the ability to store images taken from a website that we have accessed before, so the browser no longer need to download the same images from its origin. Proxies are smart enough to recognize the latest content from a website that we access, so proxy will download the latest content and storing it into a place commonly called cache.<br />
Advertising, sometimes we are very disturbed by the ads that float on a websites that we might not want to see it, and the ads usually created using the large size of images. We also can use a proxy to block ads from a website. In addition, the proxy can also be used to block sites.</p>
<p style="text-align:justify;">On a computer network in a company, proxies are necessary nowadays, at least use to save bandwidth and to limit the access to few websites that considered can make the employees forget about work.<br />
The computer network administrators usually install a proxy in linux machine, and for those of you who want to install a proxy on the linux machine, please look for it on Google, there’s a lot of articles around proxy and linux machine. This time we will try to install a proxy into Windows. OK, let’s live it.</p>
<p style="text-align:justify;"><span style="text-decoration:underline;"><strong>Installing Squid Proxy</strong></span></p>
<p>1.    Download squid proxy from this link <a href="http://squid.acmeconsulting.it/download/squid-2.6.STABLE23-bin.zip" target="_blank">http://squid.acmeconsulting.it/download/squid-2.6.STABLE23-bin.zip</a>.<br />
2.    Then extract it on to C:\<br />
3.    And then rename the squid.conf.default file on the etc folder  to squid.conf<br />
4.    Add this line http_access allow localhost exactly under the line http_access allow localnet<br />
5.    Then open the windows console and got to C:\Squid\sbin\, and the type:   squid.exe  -z command just like picture below:</p>
<p style="text-align:justify;"><img class="aligncenter" title="Squid Console 1" src="http://josescalia.files.wordpress.com/2010/10/squidconsole1.png?w=643&#038;h=221" alt="" width="643" height="221" />6.    And then run squid as a windows service by typing this command on the console: squid.exe -i. And then check if the squid are installed as a window service like picture below:</p>
<p style="text-align:center;"><img class="aligncenter" title="Squid console 2" src="http://josescalia.files.wordpress.com/2010/10/squidconsole2.png?w=654&#038;h=324" alt="" width="654" height="324" />7.    And then start the Squid Service.</p>
<p style="text-align:justify;">The next step is configuring the browser in order to use the squid as web proxy, the steps are:<br />
1.    On firefox, simply click tools and then click option, there have to be a option window appear, and in the Advanced menu, click network tab and then click setting button just like the picture below:</p>
<p style="text-align:justify;"><img class="aligncenter" title="Squid console 3" src="http://josescalia.files.wordpress.com/2010/10/squidconsole3.png?w=400&#038;h=376" alt="" width="400" height="376" /><br />
2.    And the on the Connection Setting window that appear after the setting button clicked, modify the connection setting just like this picture:</p>
<p style="text-align:justify;"><img class="aligncenter" title="Squid Console 4" src="http://josescalia.files.wordpress.com/2010/10/squidconsole4.png?w=450&#038;h=478" alt="" width="450" height="478" /><br />
3.    And then browse just like we usually do, for the first time the browsing activity will look like usual,  because the squid proxy will store the contents of the web onto the cache, and later then the browser will fetch the static content from the squid cache.</p>
<p style="text-align:justify;"><span style="text-decoration:underline;"><strong>Installing Adzap</strong></span><br />
To block the advertisement on the web, we need a squid plug in, which is adzapper. The problem is adzapper is a perl script that only can be execute by using perl environment. So definitely we need to install perl on our windows system. I choose Strawberry Perl as a perl platform to be installed on my windows machine. Strawberry perl can be fetch for download from this url <a href="http://strawberry-perl.googlecode.com/files/strawberry-perl-5.12.1.0.msi" target="_blank">http://strawberry-perl.googlecode.com/files/strawberry-perl-5.12.1.0.msi</a><br />
After finished download the strawberry perl, then please install the strawberry pearl on your own windows machine. I have installed Strawberry Perl on<strong> C:\Web\ </strong>on my windows machine. Please pay an attention that all setting of adzapper must match to the location of your Perl installation.<br />
And the next step is download the adzapper script from this URL: <a href="http://adzapper.sourceforge.net/scripts/squid_redirect" target="_blank">http://adzapper.sourceforge.net/scripts/squid_redirect</a>, open the link on your browser, and after all the text/script is appeared, save the script to the <strong>C:\squid\etc\</strong> folder and name it as squid-redirect.pl.<br />
And the next step is configuring this adzapper plug in into the squid the we have installed before. Open the squid.conf file, this file is located on <strong>C:\Squid\etc\</strong> folder and then add this line on the end of row of the file</p>
<p style="text-align:justify;"><strong>redirect_program C:/Web/strawberry/perl/bin/perl.exe c:/squid/etc/squid_redirect.pl</strong></p>
<p class="MsoNormal" style="text-align:justify;">Please make an attention that my perl installation located on <strong>C:\Web\</strong> folder, please adjust the setting to the path of your own perl installation.<br />
And after that, restart the proxy squid by using a window service just like the picture before, or maybe by using the command line by typing squid.exe –k reconfigure. And we have finished the adzapper script installation on squid. Now it’s time to check that the adzapper is working properly or not. Open the browser and then open the web site that you knew it have full of ads. The adzapper will block the ads juts like this picture below, and if it does, then the adzapper is working properly.<br />
<strong><img class="aligncenter" title="Squid Console 5" src="http://josescalia.files.wordpress.com/2010/10/adzapper.png?w=640&#038;h=398" alt="" width="640" height="398" /><br />
</strong></p>
<p style="text-align:justify;">Actually there are a lot of things that we can do with squid and adzap to fill up our needs about the web-caching problems, please visit the official site of squid on <a href="http://squid-cache.org" target="_blank">http://squid-cache.org</a> and adzapper <a href="http://adzapper.sourceforge.net/" target="_blank">http://adzapper.sourceforge.net/</a> to have a guide to maximize the both function.</p>
<p style="text-align:right;">Thanks</p>
<p style="text-align:right;">I Hope this will helpfull</p>
<p style="text-align:right;">&nbsp;</p>
<p style="text-align:right;">Josescalia</p>
<div id="_mcePaste" class="mcePaste" style="position:absolute;left:-10000px;top:254px;width:1px;height:1px;overflow:hidden;">
<p><!--[if gte mso 9]&gt;  Normal 0     false false false  EN-US X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:&quot;Table Normal&quot;; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:&quot;&quot;; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin:0cm; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:&quot;Times New Roman&quot;; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:&quot;Times New Roman&quot;; 	mso-bidi-theme-font:minor-bidi;} --> <!--[endif]--></p>
<p class="MsoNormal" style="text-align:justify;text-indent:42.55pt;"><strong><span style="text-decoration:underline;">Installing Squid Proxy</span></strong></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=194&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2010/10/18/squid-proxy-and-adzapper-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/10/squidconsole1.png?w=300" medium="image">
			<media:title type="html">Squid Console 1</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/10/squidconsole2.png?w=300" medium="image">
			<media:title type="html">Squid console 2</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/10/squidconsole3.png?w=300" medium="image">
			<media:title type="html">Squid console 3</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/10/squidconsole4.png?w=282" medium="image">
			<media:title type="html">Squid Console 4</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/10/adzapper.png?w=300" medium="image">
			<media:title type="html">Squid Console 5</media:title>
		</media:content>
	</item>
		<item>
		<title>An Easy Way to Create JSP’s and MySQL Web Application</title>
		<link>http://josescalia.wordpress.com/2010/02/14/an-easy-way-to-create-jsp%e2%80%99s-and-mysql-web-application/</link>
		<comments>http://josescalia.wordpress.com/2010/02/14/an-easy-way-to-create-jsp%e2%80%99s-and-mysql-web-application/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 06:34:55 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=179</guid>
		<description><![CDATA[Dear readers, this time I would like to share about how to create a JSP’s and MySQL web application. This time we will create it using easy way, means that we wouldn’t create this web application by coding java classes that we might needed to support this application. We only create JSP, yes only JSP, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=179&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">
<p style="text-align:justify;">Dear readers, this time I would like to share about how to create a JSP’s and MySQL web application. This time we will create it using easy way, means that we wouldn’t create this web application by coding java classes that we might needed to support this application. We only create JSP, yes only JSP, and of course few configuration that I hope easy enough too.<br />
Before we start, let’s prepare a database and a table that will be one of our material of this creation. Let’s create a database and name it as “test_jsp” and for the table, the structure of the table is looked like this sketch.<br />
<a href="http://josescalia.files.wordpress.com/2010/02/tablestructure.png"><img class="aligncenter size-full wp-image-180" title="TableStructure" src="http://josescalia.files.wordpress.com/2010/02/tablestructure.png" alt="" width="469" height="95" /></a></p>
<p style="text-align:justify;">or we can copy and paste sql query below:</p>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>create database test_jsp;
use test_jsp;
CREATE TABLE `identitas` (
  `NO` int(10) NOT NULL AUTO_INCREMENT,
  `NAMA` varchar(100) NOT NULL,
  `ALAMAT` varchar(255) DEFAULT NULL,
  `NO_TELP` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`NO`));
</code></pre>
<p style="text-align:justify;">The above Sql Query is a query to create a database named as test_jsp, and creating a table named as identitas with the following field described above on the image. The please fill up the table with few necessary data, in order to make the table containing data like the picture below. <a href="http://josescalia.files.wordpress.com/2010/02/isitable.png"><img class="aligncenter size-full wp-image-182" title="isiTable" src="http://josescalia.files.wordpress.com/2010/02/isitable.png" alt="" width="407" height="120" /></a></p>
<p style="text-align:justify;">By that, one of our material for this application is created.</p>
<p style="text-align:justify;">To do this development, actually we need or we will use a library, this library has an ability to support the creation of a web application only using jsp. The needed library is Jakarta Taglibs library.</p>
<p style="text-align:justify;">Jakarta Taglibs is one of the open source project of Jakarta Tag Libraries which supporting a creation of a web application using JSP and without coding java classes. With the Taglibs concept means that will use this library supported API by calling it using the JSP’s tags. Since this web application using a database, so we need a library called <strong>DBTags </strong>(database tags), so please download the library here <a href="http://jakarta.apache.org/site/downloads/downloads_taglibs.html">http://jakarta.apache.org/site/downloads/downloads_taglibs.html</a>, and we will need other library which have a function as a MySQL database driver which is called as mysql-connector-java.jar, please also download this library here <a href="http://dev.mysql.com/downloads/connector/j/">http://dev.mysql.com/downloads/connector/j/</a></p>
<p style="text-align:justify;">After finished downloading those libraries, then please extract the both files. And the next step is preparing a web application on an Application Server or Servlet Container, for this exercise we using Tomcat as a Servlet Container.</p>
<ol>
<li>Create a folder on a WebApps folder      on tomcat installation directory. Let’s give a name “MySimpleJSP”. This folder      will be a folder path on our web application.</li>
<li>Inside the folder is      MySimpleJSP again, we make two more folders named <strong>WEB-INF</strong> and<strong> libs</strong><strong>.</strong></li>
<li>Copy <strong>mysql-connector-java.5.1.6.jar </strong>file (I use the connector 5.1.6      here) from the mysql connector library, and <strong>taglibs-dbtags.jar</strong> files from libraries Jakarta Tablibs which      we downloaded earlier into the libs folder.</li>
<li>And also copy the <strong>taglibs-dbtags.tld </strong>file from Jakarta Taglibs library that      we have extracted onto <strong>WEB-INF </strong>folder<strong>.</strong></li>
<li>Create a file called      web.xml and then save the file also in the WEB-INF folder, while the      contents of the web.xml file write the following directions:</li>
</ol>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           version="2.5"&gt;

      &lt;jsp-config&gt;
           &lt;taglib&gt;
               &lt;taglib-uri&gt;http://jakarta.apache.org/taglibs/dbtags&lt;/taglib-uri&gt;
               &lt;taglib-location&gt;/WEB-INF/taglibs-dbtags.tld&lt;/taglib-location&gt;
           &lt;/taglib&gt;
       &lt;/jsp-config&gt;
&lt;/web-app&gt;
</code></pre>
<p style="text-align:justify;">Until here, we have completed preparations for web-applications for our experiment this time. And the next step is to simply make jsp files that we need to be able to access the MySQL database we have made earlier, all jsp files which later we will create will be placed in MySimpleJSP folder or parallel with WEB-INF folder and the libs folder. Let’s create a jsp file.</p>
<p style="text-align:justify;">The first JSP file we will create is <strong>get_identity.jsp</strong>, this file is a jsp file in charge of taking the data in the tables located on the <strong>identitas</strong> table on <strong>test_jsp</strong> database. Let&#8217;s look at the codes below <strong>get_identity.jsp</strong> file:</p>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
&lt;%@taglib uri="http://jakarta.apache.org/taglibs/dbtags" prefix="sql" %&gt;
&lt;html&gt;
&lt;head&gt;&lt;title&gt;My Simple JSP MYSQL Page&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;%-- Step 1) create a database connection --%&gt;
&lt;sql:connection id="connect"&gt;
    &lt;sql:url&gt;jdbc:mysql://localhost/test_jsp&lt;/sql:url&gt;
    &lt;sql:driver&gt;com.mysql.jdbc.Driver&lt;/sql:driver&gt;
    &lt;sql:userId&gt;root&lt;/sql:userId&gt;
    &lt;sql:password&gt;admin99&lt;/sql:password&gt;
&lt;/sql:connection&gt;
&lt;%--End Creating database Connection--%&gt;

&lt;%-- Step 2) Create a SQL query --%&gt;
&lt;sql:statement id="statement" conn="connect"&gt;
    &lt;sql:query&gt;
        SELECT * FROM identitas
    &lt;/sql:query&gt;

    &lt;table border="1"&gt;
        &lt;tr&gt;
            &lt;th&gt;NO&lt;/th&gt;
            &lt;th&gt;NAMA&lt;/th&gt;
            &lt;th&gt;ALAMAT&lt;/th&gt;
            &lt;th&gt;NO TELP&lt;/th&gt;
        &lt;/tr&gt;
            &lt;%--Step 2.1) Loop the result--%&gt;
        &lt;sql:resultSet id="data"&gt;
            &lt;tr&gt;
                &lt;td&gt;&lt;sql:getColumn position="1"/&gt; &lt;/td&gt;
                &lt;td&gt;&lt;sql:getColumn position="2"/&gt; &lt;/td&gt;
                &lt;td&gt;&lt;sql:getColumn position="3"/&gt; &lt;/td&gt;
                &lt;td&gt;&lt;sql:getColumn position="4"/&gt; &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/sql:resultSet&gt;
    &lt;/table&gt;
&lt;/sql:statement&gt;

&lt;%--Step 3) Close Database Connection--%&gt;
&lt;sql:closeConnection conn="connect"/&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>Let’s make an attention the JSP’s code above:</p>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
&lt;%@taglib uri="http://jakarta.apache.org/taglibs/dbtags" prefix="sql" %&gt;
</code></pre>
<p>On the second line we make a declaration tag that we shall use in this jsp file. Uri must be in line with <strong>taglib-uri</strong> which we declared in the <strong>web.xml</strong> file before. And if this web application run, the <strong>web.xml </strong>file have a responsibilities to find tags reference with <strong>sql </strong>prefix on <strong>taglibs-dbtags.tld </strong>file.</p>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;%-- Step 1) create a database connection --%&gt;
&lt;sql:connection id="connect"&gt;
    &lt;sql:url&gt;jdbc:mysql://localhost/test_jsp&lt;/sql:url&gt;
    &lt;sql:driver&gt;com.mysql.jdbc.Driver&lt;/sql:driver&gt;
    &lt;sql:userId&gt;root&lt;/sql:userId&gt;
    &lt;sql:password&gt;admin99&lt;/sql:password&gt;
&lt;/sql:connection&gt;
&lt;%--End Creating database Connection--%&gt;
</code></pre>
<p style="text-align:justify;"><span class="longtext">While the above code block, we make declarations tags to connect to the mysql database that we created earlier</span>.<span class="longtext">Please make attention each line above, the database is <strong>test_jsp</strong> then the driver is <strong>com.mysql.jdbc.Driver,</strong> and <strong>userid</strong> to connect to the mysql database is the <strong>root</strong>, and password to connect to the mysql database is <strong>admin9</strong></span><strong>9. </strong>My mysql database username is <strong>root</strong> and password is <strong>admin99</strong>, please adjust your database with the settings of each. Please make more attention in the code above, all of this configuration should be in block <strong>sql: connection</strong><strong> </strong></p>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;%-- Step 2) Create a SQL query --%&gt;
&lt;sql:statement id="statement" conn="connect"&gt;
    &lt;sql:query&gt;
        SELECT * FROM identitas
    &lt;/sql:query&gt;

    &lt;table border="1"&gt;
        &lt;tr&gt;
            &lt;th&gt;NO&lt;/th&gt;
            &lt;th&gt;NAMA&lt;/th&gt;
            &lt;th&gt;ALAMAT&lt;/th&gt;
            &lt;th&gt;NO TELP&lt;/th&gt;
        &lt;/tr&gt;
            &lt;%--Step 2.1) Loop the result--%&gt;
        &lt;sql:resultSet id="data"&gt;
            &lt;tr&gt;
                &lt;td&gt;&lt;sql:getColumn position="1"/&gt; &lt;/td&gt;
                &lt;td&gt;&lt;sql:getColumn position="2"/&gt; &lt;/td&gt;
                &lt;td&gt;&lt;sql:getColumn position="3"/&gt; &lt;/td&gt;
                &lt;td&gt;&lt;sql:getColumn position="4"/&gt; &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/sql:resultSet&gt;
    &lt;/table&gt;
&lt;/sql:statement&gt;
</code></pre>
<p>Then look at the rows of the following code, we create a block of tag <strong>sql:statement.</strong> Where in this block we write the block tag <strong>sql:query</strong> and tag <strong>sql:ResultSet</strong>, and in the block <strong>sql:ResultSet</strong>, we extract the data from the database to be displayed to the web page using tag <strong>sql:getColumn</strong>. If we try to understand the tags, the description may look like this: tag <strong>sql:query </strong>is a tag to write sql query which will be executed by the application. Then tag <strong>sql:ResultSet</strong> is a tag where the captured data from the database placed in the form to an array collection. And the last is the tag <strong>sql:getColumn</strong> is a way to extract the collection array and then sorted based on the basic view of our application web pages.</p>
<pre style="border:1px dashed #999999;overflow:auto;background-color:#eeeeee;color:black;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;%--Step 3) Close Database Connection--%&gt;
&lt;sql:closeConnection conn="connect"/&gt;
</code></pre>
<p class="MsoNormal" style="text-align:justify;"><span class="shorttext">And finally the last in this code is, that we then terminate the connection to our MySQL database</span>.</p>
<p class="MsoNormal" style="text-align:justify;">Then after that, we can test this MySimpleJSP application by running our Tomcat and then call the <strong>get_identity.jsp</strong> files on your favorite browser pointed to the address: <a href="http://localhost:8000/MySimpleJSP/get_identity.jsp">http://localhost:8000/MySimpleJSP/get_identity.jsp</a> (I have configured tomcat to port 8000, please replace with the appropriate port in your tomcat configuration). If successful, it should display the web page is like this</p>
<p><span class="shorttext"><a href="http://josescalia.files.wordpress.com/2010/02/hasil.png"><img class="aligncenter size-full wp-image-183" title="Hasil" src="http://josescalia.files.wordpress.com/2010/02/hasil.png" alt="" width="681" height="404" /></a></span></p>
<p><span class="longtext">With the appearance of the data into a web page of our JSP application</span>, then we can describe that this exercise is successful done. For further step you can create more jsp pages, such as a jsp file to insert the data into the table, etc.</p>
<p style="text-align:right;"><span style="font-size:small;line-height:115%;font-family:&amp;">I Hope this usefull.</span></p>
<p style="text-align:right;">
<p style="text-align:right;"><span style="font-size:small;line-height:115%;font-family:&amp;">Thanks</span></p>
<p style="text-align:right;"><span style="font-size:small;line-height:115%;font-family:&amp;">Josescalia<br />
</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/179/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=179&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2010/02/14/an-easy-way-to-create-jsp%e2%80%99s-and-mysql-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/02/tablestructure.png" medium="image">
			<media:title type="html">TableStructure</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/02/isitable.png" medium="image">
			<media:title type="html">isiTable</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2010/02/hasil.png" medium="image">
			<media:title type="html">Hasil</media:title>
		</media:content>
	</item>
		<item>
		<title>Error Page Customizing on Java Web Application</title>
		<link>http://josescalia.wordpress.com/2009/11/29/error-page-customizing-on-java-web-application/</link>
		<comments>http://josescalia.wordpress.com/2009/11/29/error-page-customizing-on-java-web-application/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 16:06:51 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=169</guid>
		<description><![CDATA[Have we ever seen this web page: Or this one: This web page is standard error page produced by Apache Tomcat when our web application have some errors. These error occurred because the logic of our application had a mistake or user do some mistaken when requesting via HTTP browser. We can change these pages [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=169&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have we ever seen this web page:</p>
<p style="text-align:center;"><a href="http://josescalia.files.wordpress.com/2009/11/tomcat404.png"><img class="size-full wp-image-170 aligncenter" title="Tomcat404" src="http://josescalia.files.wordpress.com/2009/11/tomcat404.png" alt="tomcat 404" width="452" height="183" /></a></p>
<p>Or this one:</p>
<p style="text-align:center;"><a href="http://josescalia.files.wordpress.com/2009/11/tomcat500.png"><img class="size-full wp-image-171 aligncenter" title="Tomcat500" src="http://josescalia.files.wordpress.com/2009/11/tomcat500.png" alt="" width="497" height="201" /></a></p>
<p>This web page is standard error page produced by Apache Tomcat when our web application have some errors. These error occurred because the logic of our application had a mistake or user do some mistaken when requesting via HTTP browser.</p>
<p>We can change these pages into our custom page but have same function just like the page above. The advantages is we can redesign the page just like we  desired to. And other function is we could hide some error points, so the user can’t find out what’s the problem behind.</p>
<p>Before that, we can divide type of error that probably occurred on our web application. 1<sup>st, </sup> caused by user fault such as accesing file that’s not exist on the server, and the 2<sup>nd</sup> caused by error logic on our web application.</p>
<p>Let’s try to customize the error page that could be happen like above.</p>
<p><strong>1. Creating error page caused by user:</strong></p>
<p>When creating this type of error page, we can create it by adding some lines on deployment descriptor (web.xml) like this:</p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>    &lt;error-page&gt;
        &lt;error-code&gt;404&lt;/error-code&gt;
        &lt;location&gt;/404.jsp&lt;/location&gt;
    &lt;/error-page&gt;
</code></pre>
<p>On the source above, we can see clearly, if <strong>File Not Found Error</strong> occurred when user requesting via HTTP browser and the web application will automatically redirect to a 404.jsp file, and of course we have created this file before and customed like this one:</p>
<p><a href="http://josescalia.files.wordpress.com/2009/11/custom-tomcat404.png"><img class="aligncenter size-full wp-image-172" title="Custom-Tomcat404" src="http://josescalia.files.wordpress.com/2009/11/custom-tomcat404.png" alt="" width="618" height="402" /></a></p>
<p><strong>2.  Creating Error Page caused by Programming mistakes:</strong></p>
<p>While configuring the error page caused by our programming mistakes, we can do it by adding these lines on deployment descriptor:</p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>    &lt;error-page&gt;
        &lt;exception-type&gt;java.lang.NullPointerException&lt;/exception-type&gt;
        &lt;location&gt;/errorpage.jsp&lt;/location&gt;
    &lt;/error-page&gt;

    &lt;error-page&gt;
        &lt;exception-type&gt;java.lang.NumberFormatException&lt;/exception-type&gt;
        &lt;location&gt;/errorpage.jsp&lt;/location&gt;
    &lt;/error-page&gt;

</code></pre>
<p>On the example source, we can see that the error can be define one by one, such as <strong>Null Pointer Exception Error</strong>, nor <strong>Number Format Exception Error</strong><em>.</em></p>
<p>On the sampe source too, we can only create one jsp page to accommodate and informing the <em>stacktrace</em> that occurred caused by our programming mistakesl.</p>
<p>The source code of this jsp file is:</p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>&lt;%@ page import="java.io.ByteArrayOutputStream" %&gt;
&lt;%@ page import="java.io.PrintStream" %&gt;
&lt;%--
  User: Muhammad Yusuf
  Date: Aug 30, 2005
  Time: 5:56:29 PM
--%&gt;
&lt;%@ page isErrorPage="true" %&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;JSP Error Page&lt;/title&gt;
    &lt;meta http-equiv="Pragma" content="no-cache"&gt;
    &lt;style type="text/css"&gt;
        body {
            background-color: #cccccc;
            font-family: verdana, sans-serif, monospace;
            font-size: medium;
        }
    &lt;/style&gt;
&lt;/head&gt;

&lt;body bgcolor=#ffffff&gt;
&lt;font face="Verdana"&gt;
    &lt;center&gt;
        &lt;h2&gt;&lt;font color=#DB1260&gt;Error Page&lt;/font&gt;&lt;/h2&gt;
    &lt;/center&gt;
    &lt;p&gt; An exception was thrown: &lt;b&gt; &lt;%=exception %&gt;
        &lt;p&gt; With the following stack trace:
&lt;pre&gt;

&lt;%
    ByteArrayOutputStream ostr = new ByteArrayOutputStream();
    exception.printStackTrace(new PrintStream(ostr));
    out.print(ostr);
%&gt;
&lt;/pre&gt;
        &lt;br&gt;&lt;a class="Verdana" href="#"&gt;Back To Main&lt;/a&gt;

        &lt;p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>On this source code, the occurred exception can be defined by using this tag <strong><em>&lt;%=exception%&gt;</em> </strong>and the stack-trace that probably occurred can be print-out to the page like this:</p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>&lt;%
    ByteArrayOutputStream ostr = new ByteArrayOutputStream();
    exception.printStackTrace(new PrintStream(ostr));
    out.print(ostr);
%&gt;
</code></pre>
<p>And here’s the final result of the 2<sup>nd</sup> error page caused by our programming mistaken.</p>
<p style="text-align:center;"><a href="http://josescalia.files.wordpress.com/2009/11/custom-tomcat500.png"><img class="aligncenter size-full wp-image-173" title="Custom-Tomcat500" src="http://josescalia.files.wordpress.com/2009/11/custom-tomcat500.png" alt="" width="583" height="334" /></a></p>
<p>Or like this:</p>
<p style="text-align:center;"><a href="http://josescalia.files.wordpress.com/2009/11/custom-tomcat500-2.png"><img class="aligncenter size-full wp-image-174" title="Custom-Tomcat500-2" src="http://josescalia.files.wordpress.com/2009/11/custom-tomcat500-2.png" alt="" width="587" height="359" /></a></p>
<p style="text-align:right;">
<p style="text-align:right;">Hope this will helpfull</p>
<p style="text-align:right;">Menteng, 29 November 2009.</p>
<p style="text-align:right;">
<p style="text-align:right;"><strong>josescalia</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=169&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2009/11/29/error-page-customizing-on-java-web-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/11/tomcat404.png" medium="image">
			<media:title type="html">Tomcat404</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/11/tomcat500.png" medium="image">
			<media:title type="html">Tomcat500</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/11/custom-tomcat404.png" medium="image">
			<media:title type="html">Custom-Tomcat404</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/11/custom-tomcat500.png" medium="image">
			<media:title type="html">Custom-Tomcat500</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/11/custom-tomcat500-2.png" medium="image">
			<media:title type="html">Custom-Tomcat500-2</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Java Download Application</title>
		<link>http://josescalia.wordpress.com/2009/05/04/creating-java-download-application/</link>
		<comments>http://josescalia.wordpress.com/2009/05/04/creating-java-download-application/#comments</comments>
		<pubDate>Mon, 04 May 2009 02:07:37 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=161</guid>
		<description><![CDATA[On internet activity, we often do download or upload. Download is an internet activity which takes a file from remote computer to our local computer. Basically, when we download a file from a remote computer or a server, actually our computer reading byte by byte of a file that we want to download. And after [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=161&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">On internet activity, we often do download or upload. Download is an internet activity which takes a file from remote computer to our local computer.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Basically, when we download a file from a remote computer or a server, actually our computer reading byte by byte of a file that we want to download. And after all the byte read then the computer will pack it onto a file that contains perfectly same with the file that we like to download.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">With this concept, let’s try to make a little experiment and this experiments will implement all the steps above, we can complete this experiment with another steps that we can gather base on our knowledge that we can find out from the above download process concept.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Let’s try to arrange the steps:</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">URL 	identification.</span></span></p>
</li>
</ol>
<p style="margin-left:.5in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:'Courier New', monospace;"><span style="font-size:small;"><span style="font-family:Tahoma, sans-serif;">To download a file, we need a valid URL address for sure, and the path location of a file that we want to download. Example: </span><span style="color:#0000ff;"><span style="text-decoration:underline;"><a href="http://www.wayofmuslim.com/ebook-islam/AlQuranDigital.zip"><span style="font-family:Tahoma, sans-serif;">http://www.wayofmuslim.com/ebook-islam/AlQuranDigital.zip</span></a></span></span>.<span style="font-family:Tahoma, sans-serif;"> this have a meaning that we want to download a file named </span><span style="font-family:Tahoma, sans-serif;"><strong>AlQuranDigital.zip</strong></span><span style="font-family:Tahoma, sans-serif;"> from a remote computer </span><span style="font-family:Tahoma, sans-serif;"><strong>wayofmuslim.com</strong></span><span style="font-family:Tahoma, sans-serif;"> and the path location of this file at </span><span style="font-family:Tahoma, sans-serif;"><strong>ebook-islam/</strong></span><span style="font-family:Tahoma, sans-serif;"> </span></span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">The 	size of file.</span></span></p>
</li>
</ol>
<p style="margin-left:.5in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Each file that we want to download, have to find out the size of it. The purpose of this are we will be able to compare the bytes length that already read and stored in our local computer with the file that exist on remote computer, so we can find out whether the byte we have downloaded is corrupted or not before we can pack it up onto a file.</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">The 	content type of file.</span></span></p>
</li>
</ol>
<p style="margin-left:.5in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">This is optional, we can use this concept or not, it’s an option. But knowing the content type of a file in internet technology is the basic knowledge.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">With those concept actually we can create our own application that have ability to download a file from a remote computer, yes we can, because the download concept is that simple.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Now let’s proof it by arrange a scenario based on the concept above to create our own Java Download Application. The scenario is:</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Identifying </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>URL.</strong></span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Checking whether the supplied URL valid or not, we will use URL class that exist on Java.</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Valid </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>URL.</strong></span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">If the URL is valid, then go straight to create a HTTP Connection to check whether our computer is connected to the internet or not. And if the URL is not valid then just exit the application and show some screens out telling that the connection is not available.</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Identifying 	the Content Type</span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">If the Http Connection</span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><em> </em></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">status is good, meaning that the host or remote computer can be contacted, the next step is identifying the content type of a file that we would like to download. In this try-it-out let’s just limit it, if the content type of a file is </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>text/html, </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">then we don’t have to download it. Why? The </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>Http Status 404 (</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><em><strong>File</strong></em></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong> Not Found)</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> can be occurred on a file that we want to download, and we don’t need this html page to download to our computer rite?</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Identifying 	the byte length (Content Length).</span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Just because we will to read byte by byte of file that we want to download, so it’s very important to store information of a byte length of the file that we want to download into a variable. And for the next usage this information can be some useful things in order to compare the byte length of downloaded byte with the length of byte that exist on remote computer, to find out whether the downloaded file corrupted or not.</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Reading 	byte by byte. </span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">This is the essential things on our try-it-out. Our application should have an ability to read byte by byte of the file that we want to download and the result of the bytes reading will put on a variable which have byte data-type. The way of bytes reading is using the looping from 0 to the content length that we have store it into a variable before.</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Comparing 	local file to a remote file.</span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">The next step is comparing the length of bytes that already read with the length of byte that stored before on a variable. If the both are not same that’s mean the downloaded file is corrupted and this byte will not be packed onto a file.</span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Pack 	the read bytes. </span></span></p>
</li>
</ol>
<p style="margin-left:.25in;margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">After we knew exactly that the length of read bytes is similar to byte length of remote   computer, so it’s time to pack it up onto a file. Let’s just make it easier by naming the file exactly same with the name of file that exist on remote computer.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Using the above scenario, let’s try to code just like the source code below:</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>package org.mojo.download.agent;

import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLConnection;

/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: May 2, 2009
 * Time: 11:39:49 AM
 * To change this template use File | Settings | File Templates.
 */
public class SingleDownloadAgent {

    public static void main(String[] args) {
        if (args.length == 0) {
            System.out.println("Usage : java SingleDownloadAgent &lt;URL&gt;" );
            return;
        } else {
            SingleDownloadAgent agent = new SingleDownloadAgent();
            try {
                doDownload(args[0]);
            } catch (IOException e) {
                System.err.println("Exception e");
            }
        }
    }
    public static void doDownload(String sURL) throws IOException {
       URL u = null;
        //try URL
        try {
            u = new URL(sURL);
        } catch (MalformedURLException ex) {
            System.err.println("Malformed URL : " + ex);
            return;
        }
        catch (IOException ex) {
            System.err.println("An Error Occured : " + ex);
            return;
        }
       //reading Connection
        URLConnection uc = null;
        try {
            uc = u.openConnection();
            //identifying connection
            uc.connect();
        } catch (IOException e) {
            System.out.println("Cannot Connect: Please Check Connection");
            return;
        }

        String contentType = uc.getContentType();
        System.out.println("contentType :" + contentType);

        int contentLength = uc.getContentLength();
        if (contentType.startsWith("text/html") || contentLength == -1) {
            throw new IOException("This is html file.");
        }

        //collecting byte in var data
        InputStream raw = uc.getInputStream();
        InputStream in = new BufferedInputStream(raw);
        byte[] data = new byte[contentLength];
        int bytesRead = 0;
        int offset = 0;
        while (offset &lt; contentLength) {
            bytesRead = in.read(data, offset, data.length - offset);
            if (bytesRead == -1) break;
            offset += bytesRead;
        }
        in.close();

        //file corrupted
        if (offset != contentLength) {
            throw new IOException("Only read " + offset + " bytes; Expected " + contentLength + " bytes ? File Corrupted…");
        }

        //writing byte data to a file
        String filename = u.getFile();
        filename = filename.substring(filename.lastIndexOf('/') + 1);
        FileOutputStream fout = new FileOutputStream(filename);
        fout.write(data);
        fout.flush();
        fout.close();

    }
}</code></pre>
<p><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">On the above source-code we have two methods, which is the main method and the </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>doDownload</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> method with s</span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>URL </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">string as it’s parameter. Let’s discuss it line by line the above source-code:</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">As usual, at the beginning of the code we declare the package where this class is located and the declaration of imported class that we will need later. And then on the main method we check whether the URL parameter supplied when this class is called. Indeed, this application designed has to supply the URL parameter when this application called.</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>package org.mojo.download.agent;

import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLConnection;

/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: May 2, 2009
 * Time: 11:39:49 AM
 * To change this template use File | Settings | File Templates.
 */
public class SingleDownloadAgent {

    public static void main(String[] args) {
        if (args.length == 0) {
            System.out.println("Usage : java SingleDownloadAgent &lt;URL&gt;" );
            return;
        } else {
            try {
                doDownload(args[0]);
            } catch (IOException e) {
                System.err.println("Exception e");
            }
        }
    }
………
</code></pre>
<p><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">On this main method, showed that if the URL parameter is not supplied then this application will print out the message of application usage and then directly quit. And if the URL parameter supplied then the application will continuing call the </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>doDownload</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> method with </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>args[0]</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> as it’s parameter.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Now let’s take a look at the second method which is </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>doDownload</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> methods:</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>   ………
   public static void doDownload(String sURL) throws IOException {
       URL u = null;
        //try URL
        try {
            u = new URL(sURL);
        } catch (MalformedURLException ex) {
            System.err.println("Malformed URL : " + ex);
            return;
        }
        catch (IOException ex) {
            System.err.println("An Error Occured : " + ex);
            return;
        }
    ………
</code></pre>
<p><span style="font-family:Tahoma;">On these lines we run out first scenario which is validating the URL, and we put it on a try-catch block. Why we put it on try-catch block? Because we want to know if the error occurred, where it will be happen.</span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>…………
        //reading Connection
        URLConnection uc = null;
        try {
            uc = u.openConnection();
            //identifying connection
            uc.connect();
        } catch (IOException e) {
            System.out.println("Cannot Connect: Please Check Connection");
            return;
        }

        String contentType = uc.getContentType();
        System.out.println("contentType :" + contentType);

        int contentLength = uc.getContentLength();
        if (contentType.startsWith("text/html") || contentLength == -1) {
            throw new IOException("This is html file.");
        }
…………
</code></pre>
<p><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">And after that, on the lines above code we check the connection to host or remote computer by put it once again on try-catch block, and then the next line we find out the content type of the file that we want to download and put the information on a string variable called </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>contentType. </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">And then we check the content length that we want to download and put in on a integer type variable. And the next lines is continue by the branching to make a decision if the content typeof the file is </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>type/html</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> type, then just quit the application.</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>    …………
        //collecting byte in var data
        InputStream raw = uc.getInputStream();
        InputStream in = new BufferedInputStream(raw);
        byte[] data = new byte[contentLength];
        int bytesRead = 0;
        int offset = 0;
        while (offset &lt; contentLength) {
            bytesRead = in.read(data, offset, data.length - offset);
            if (bytesRead == -1) break;
            offset += bytesRead;
        }
        in.close();

        //file corrupted
        if (offset != contentLength) {
            throw new IOException("Only read " + offset + " bytes; Expected " + contentLength + " bytes ? File Corrupted…");
        }
    …………
</code></pre>
<p><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">On the lines above, we can see the reading of byte by byte do by our application, using the open up the output-stream and then read the output stream by looping byte and using the content length as it limitation, and then put it the read result into a </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>data</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> variable that have byte data-type</span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>. </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">And after the read process is finished the output-stream is closed and then we create a statement to compare the length of read bytes that stored on </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>offset</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> variable with the </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>contentLength </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">variable</span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>. </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> </span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>…………
        //writing byte data to a file
        String filename = u.getFile();
        filename = filename.substring(filename.lastIndexOf('/') + 1);
        FileOutputStream fout = new FileOutputStream(filename);
        fout.write(data);
        fout.flush();
        fout.close();

    }
…………

</code></pre>
<p><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">And this is the last codes that we have created, on this codes we pack up the bytes that we have read and stored into a </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>data</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> variable before, into a file. To naming the file, we just named as a same filename that we want to download.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">That’s it, our try-it-out for this time. There’s still a lot that we can explore more from this little experiments, such as we can build a GUI as its interface, or adding some progress bar animation, etc. Please explore more of this concept to creating more perfect things.</span></span></p>
<p style="margin-bottom:0;" align="JUSTIFY"> </p>
<p style="margin-bottom:0;" align="JUSTIFY"> </p>
<p style="margin-bottom:0;" align="RIGHT"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Hope it will be useful.</span></span></p>
<p style="margin-bottom:0;" align="RIGHT"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">Menteng, March 3</span></span><sup><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;">rd</span></span></sup><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"> 2009</span></span></p>
<p style="margin-bottom:0;" align="RIGHT"> </p>
<p style="margin-bottom:0;" align="RIGHT"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:small;"><strong>Josescalia.</strong></span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=161&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2009/05/04/creating-java-download-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Spring Framework on Creating DAO Layer</title>
		<link>http://josescalia.wordpress.com/2009/04/07/using-spring-framework-on-creating-dao-layer/</link>
		<comments>http://josescalia.wordpress.com/2009/04/07/using-spring-framework-on-creating-dao-layer/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 02:10:21 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=154</guid>
		<description><![CDATA[On J2EE or J2SE project development, sometimes there’s one block which have a function to manage everything related with the database, result fetching of supplied queries was managed on this block. With this type of design, we’re easier to track if there’s an error on our java application. For Java Developer which familiar to use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=154&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><a href="http://www.springsource.org/"><img class="alignleft" title="Spring Logo" src="http://opensource.atlassian.com/confluence/spring/download/attachments/1872/logo.jpg" alt="" width="288" height="186" /></a>On J2EE or J2SE project development, sometimes there’s one block which have a function to manage everything related with the database, result fetching of supplied queries was managed on this block. With this type of design, we’re easier to track if there’s an error on our java application.<br />
For Java Developer which familiar to use database as a part of the application, doesn’t have any difficulty to create a block which have a function as a database access, and then place the block inside the architecture of the application.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">When creating this database access block, there’s some way that we can use, one of them is using </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong><a href="http://www.springsource.org/">Spring Framework</a>. </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Yes, now we will try to use Spring Framework to access database, by creating database access or more familiar as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>DAO Layer. </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> And for this try-it-out we will use MySQL Database (Again….? Oh God&#8230;). First thing we have to do to try-this-out is create a table on a database on <a href="http://www.mysql.com/">MySQL Database</a> and complete this table with the data needed. We will name this table as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>web_account</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> and containing about 10 or 20 data inside. For the field of this table, let’s just create with our desire. Or maybe we can copy-paste this below SQL Code:</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>CREATE TABLE `web_account` (
  `USERNAME` varchar(30) NOT NULL DEFAULT '',
  `PASSWORD` varchar(30) NOT NULL DEFAULT '',
  `CREATE_TIME` datetime DEFAULT NULL,
  `CREATE_USER` varchar(30) DEFAULT NULL,
  `UPDATE_TIME` datetime DEFAULT NULL,
  `UPDATE_USER` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`USERNAME`)
);

INSERT INTO `web_account` VALUES ('admin','adminya33','2009-03-15 08:32:21','admin','2009-03-15 08:32:21','admin'),('andre','andre456','2009-03-15 08:34:53','admin','2009-03-15 08:34:53','admin'),('fitri','fitri54','2009-03-15 08:33:22','admin','2009-03-15 08:33:22','admin'),('ganteng','ganteng99','2009-03-15 08:34:21','admin','2009-03-15 08:34:21','admin'),('gerry','gerry87','2009-03-15 08:33:41','admin','2009-03-15 08:33:41','admin'),('gue','guelagi','2009-03-15 08:33:56','admin','2009-03-15 08:33:56','admin'),('hebat','hebatlah','2009-03-15 08:34:36','admin','2009-03-15 08:34:36','admin'),('heru','heur334','2009-03-15 08:32:54','admin','2009-03-15 08:32:54','admin'),('joe','joe77','2009-03-15 08:32:39','admin','2009-03-15 08:32:39','admin'),('kasep','sekap25','2009-03-15 08:33:08','admin','2009-03-15 08:33:08','admin'),('linux','linux09','2009-03-15 08:35:22','admin','2009-03-15 08:35:22','admin'),('mojo','monk123','2009-03-15 08:31:50','admin','2009-03-15 08:31:50','admin');
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">From the structure of the table above, we have to create a Java Class which has class properties that can represent the fields of the table above. The purpose of this class creation is this class will be the container of the data table. On usage of java code, this class will be an object variable that can be accessed as Array of Object or Single Object.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">We will create this class by using simple POJO (Plain Old Java Object), below is the source code of this class:<br />
</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>package org.mojo.spring.entity;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: Mar 15, 2009
 * Time: 8:45:10 AM
 * To change this template use File | Settings | File Templates.
 */
public class WebAccount {
    private String userName;
    private String password;
    private Date createDate;
    private String createUser;
    private Date updateDate;
    private String updateUser;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    public String toString() {
        return "WebAccount{" +
                "userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", createDate=" + createDate +
                ", createUser='" + createUser + '\'' +
                ", updateDate=" + updateDate +
                ", updateUser='" + updateUser + '\'' +
                '}';
    }
}
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">And now we are ready to create a </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>DAO Layer</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> using </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>Spring Framework, </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">don’t forget to download the needed libraries such as Spring Library, MySQL Connector library, and </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>common-logging </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">library, because these libraries is needed to follow this try-it-out. The common-logging library has to include too in this try-it-out, because the Spring Framework have a very high dependencies to this library. And the MySQL Connector library is needed too, because we use MySQL Database on this try-it-out (Again… :P).</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">For the DAO Layer that we will create below, we just limit it on </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>fetching how many rows data on the table (SELECT COUNT(1) ) </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">and </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>fetching all data</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> (</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>SELECT</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>*</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">) only. The others method such as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>insert, update, or delete,</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> we can add it later. For the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>select count(1) </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> method the run-down scenario is: this method will have a return data type as integer, while the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>select *</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> method will have a return data type as a list. Let’s see below source code:<br />
</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>package org.mojo.spring.dao.JdbcDao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.mojo.spring.entity.WebAccount;

import javax.sql.DataSource;
import java.util.List;
import java.util.ArrayList;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.ResultSet;

/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: Mar 15, 2009
 * Time: 8:46:57 AM
 * To change this template use File | Settings | File Templates.
 */
public class WebAccountJDBCDAO extends JdbcDaoSupport {
    private DataSource ds;
    private JdbcTemplate tpl;

    public int getNumOfWebAccount() {
        logger.info("getNumOfWebAccount");
        int iRes = 0;
        ds = getDataSource();
        tpl = new JdbcTemplate(ds);
        String sQuery = "SELECT COUNT(1) from web_account";
        try {
            iRes = tpl.queryForInt(sQuery);
            logger.info("Result of getNumOfWebAccount : " + iRes);
        } catch (Exception e) {
            logger.info("Exception in getNumOfWebAccount()" + e.getMessage());
        }
        return iRes;
    }

    public List&lt;WebAccount&gt; getWebAccountList(boolean flagLimit, int limit) {
        final List&lt;WebAccount&gt; result = new ArrayList();
        final int iLimit = limit;
        ds = getDataSource();
        JdbcTemplate tpl = new JdbcTemplate(ds);
        String sQuery = "SELECT * FROM rss_feeder";

         if (flagLimit) {
            sQuery += " LIMIT ?";
        }

        class PreparedStatementHandler implements PreparedStatementSetter {
            public void setValues(PreparedStatement ps) throws SQLException {
                int n = 0;
                ps.setInt(++n, iLimit);
            }
        }

        class ServiceHandler implements RowCallbackHandler {
            public void processRow(ResultSet rs) throws SQLException {
                WebAccount wa = new WebAccount();
                wa.setUserName(rs.getString("WEB_ACCOUNT"));
                wa.setPassword(rs.getString("PASSWORD"));
                wa.setCreateDate(rs.getDate("CREATE_DATE"));
                wa.setCreateUser(rs.getString("CREATE_USER"));
                wa.setUpdateDate(rs.getDate("UPDATE_DATE"));
                wa.setUpdateUser(rs.getString("UPDATE_USER"));
                result.add(wa);
            }
        }

        if (flagLimit) {
            tpl.query(sQuery, new PreparedStatementHandler(), new ServiceHandler());
        } else {
            tpl.query(sQuery, new ServiceHandler());
        }
        return result;
    }
}
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Let’s discuss above codes. On the top of the source code, there’s a declaration where this class is located, and the next lines, we just import the needed class of Spring Framework library and other Java default library.<br />
</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>package org.mojo.spring.dao.JdbcDao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.mojo.spring.entity.WebAccount;

import javax.sql.DataSource;
import java.util.List;
import java.util.ArrayList;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.ResultSet;
………
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">We have named this class as</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong> WebAccountJDBDDAO </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">class</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>, </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">marked by the class declaration on the next line after comment lines (I’m Using IntelliJidea as my favorite IDE). After the class declaration, we create 2 variables, </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>ds </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>DataSource</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> type and </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>tpl </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>JdbcTemplate</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> type.<br />
</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>………
public class WebAccountJDBCDAO extends JdbcDaoSupport {
    private DataSource ds;
    private JdbcTemplate tpl;
………
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>DataSources </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">is a type of object that we picked up from </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>javax.sql</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> package, while the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>JdbcTemplate </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">is a type of object that we picked up form Spring package, located on</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><em> </em></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>org.springframework.jdbc.core.JdbcTemplate. </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">And then, let’s take look one by one the methods that exist on the codes.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>Method getNumOfWebAccount:</strong></span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>……
 public int getNumOfWebAccount() {
        logger.info("getNumOfWebAccount");
        int iRes = 0;
        ds = getDataSource();
        tpl = new JdbcTemplate(ds);
        String sQuery = "SELECT COUNT(1) from web_account";
        try {
            iRes = tpl.queryForInt(sQuery);
            logger.info("Result of getNumOfWebAccount : " + iRes);
        } catch (Exception e) {
            logger.info("Exception in getNumOfWebAccount()" + e.getMessage());
        }
        return iRes;
    }
……
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">On this method we can see, the query that will be execute is only simple query which is “</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>select count(1) from web_account</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">”. If we execute this query on MySQL Console, the result of this query is the number of how much rows are exists on </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>web_account</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> table. On this method we put the result of the query into a variable iRes, this iRes variable has a integer as it’s data type. If we want to arrange the steps of this method, the steps will be seen as: </span></span></p>
<ol>
<li>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Create 	integer type variable and name it as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>iRes</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">. </span></span></p>
</li>
<li>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Initialize 	the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>ds</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> variable by calling </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>getDataSource</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> interface. </span></span></p>
</li>
<li>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Create 	new </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>JdbcTemplate</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> object and the parameter is ds. </span></span></p>
</li>
<li>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Create 	a String variable, named as sQuery and directly fill the string by 	the MySQL query.</span></span></p>
</li>
<li>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Execute 	the query on try-catch block and then put the result of the query 	into </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>iRes </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">variable.</span></span></p>
</li>
<li>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Crate 	a return statement of the methods.</span></span></p>
</li>
</ol>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">While the lines containing </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>logger</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">, is our way to mark the process flow, so if there’s any error occurred on the codes we can trace it easily.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">And then let’s discuss</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> the 2</span></span><sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">nd</span></span></sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> method which is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>getWebAccountList </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">method</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>. </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">On</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong> </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">this method, we create 2 inner class, the purpose of this inner class creation is to make our codes look more orderly:<br />
</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>…….
       class PreparedStatementHandler implements PreparedStatementSetter {
            public void setValues(PreparedStatement ps) throws SQLException {
                int n = 0;
                ps.setInt(++n, iLimit);
            }
        }

     class ServiceHandler implements RowCallbackHandler {
            public void processRow(ResultSet rs) throws SQLException {
                WebAccount wa = new WebAccount();
                wa.setUserName(rs.getString("USERNAME"));
                wa.setPassword(rs.getString("PASSWORD"));
                wa.setCreateDate(rs.getDate("CREATE_TIME"));
                wa.setCreateUser(rs.getString("CREATE_USER"));
                wa.setUpdateDate(rs.getDate("UPDATE_TIME"));
                wa.setUpdateUser(rs.getString("UPDATE_USER"));
                result.add(wa);
            }
        }
…….
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">If we take a look on the codes of both inner classes, each of this inner class handled two important functions. The function on the first inner class handled </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>PrepareStatement</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">, this class implements </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>PrepareStatementSetter</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> belongs to </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>Spring Framework</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">. And the 2</span></span><sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">nd</span></span></sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> inner class handled the localization of query result onto WebAccount object variable, this inner class implements </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>RowcallbackHandler</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><em> </em></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">belongs to</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><em> </em></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>Spring Framework </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">also.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">On the 1</span></span><sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">st</span></span></sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> inner class we override </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>setValues</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> methods that owned by the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>PreparedStatementHandler</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> class as a requirement of implementation. And the 2</span></span><sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">nd</span></span></sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> class we also have to override </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>processRow </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">method</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong> </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">as a requirement of </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>RowCallBackHandler </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">class implementation</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>.</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> And then let’s take a look at the main code of the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>getWebAccountList </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">method that we’ve already created before.</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>……
 public List&lt;WebAccount&gt; getWebAccountList(boolean flagLimit, int limit) {
        final List&lt;WebAccount&gt; result = new ArrayList();
        final int iLimit = limit;
        ds = getDataSource();
        JdbcTemplate tpl = new JdbcTemplate(ds);
        String sQuery = "SELECT * FROM rss_feeder";

         if (flagLimit) {
            sQuery += " LIMIT ?";
        }
……..
……..
……..
        if (flagLimit) {
            tpl.query(sQuery, new PreparedStatementHandler(), new ServiceHandler());
        } else {
            tpl.query(sQuery, new ServiceHandler());
        }
        return result;
    }
……
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">On the main code of the above method we have return value as a list and 2 parameters which is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>flagLimit</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>boolean</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> type and </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>limit</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>integer </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">type. The steps of this method arrangement is same with the first method that we have created before on </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>getNumOfWebAccount </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">method, just because that we have 2 parameters on this method, so let’s create a little programming logic here, which is on branching lines. On the branching lines we create a logic if the value on </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>flagLimit</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>true</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> then the query will be added by </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>“LIMIT ?” </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">so the query will be </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>“SELECT * FROM web_account limit ?”,</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> and if the value of </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>flagLimit</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>false</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> then the query</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><em> </em></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">will not be change,  but it still same just like the first initialization.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">The dots that exist in the middle of the main codes are the codes of inner classes that we have discussed before. And then we have arrived to the code where the lines of query execute. In this lines there’s also a branch that will decide whether the code will use the inner </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>PreparedStatementHandler</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> class of not, the decision of this usage is depends on </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>flagLimit </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">variable value, go head, do your  own analyze the branching codes. And the end of this method is the existence of the return statement declared as a list that represented by the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>result</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> variable. That’s it, that’s how we use Spring Framework on creating DAO Layer. And the next step are we will try to use the DAO Layer in the Java Consol Application. </span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">In order to use this DAO Layer, we have to make a </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>Spring Framework</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> configuration file</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>.</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> Ok, let’s just create this file, let’s name it as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>“applicationContext.xml” </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">file,</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong> </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">just like another article posted before which using Spring Framework also. We will place this configuration file on a </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>config</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> folder which is a line with the </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>src</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> folder on this try-it out project. Below is the source code of Spring Configuration file.</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt;
&lt;beans&gt;
    &lt;!--Data Source--&gt;
    &lt;bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
        &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
        &lt;property name="url" value="jdbc:mysql://localhost/java_spring"/&gt;
        &lt;property name="username" value="root"/&gt;
        &lt;property name="password" value="root99"/&gt;
    &lt;/bean&gt;

    &lt;bean id="webAccountDAO" class="org.mojo.spring.dao.JdbcDao.WebAccountJdbcDAO"&gt;
        &lt;property name="dataSource" ref="ds"/&gt;
    &lt;/bean&gt;
&lt;/beans&gt;
</code></pre>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Let’s take a look of this configuration file, the first bean that we have to create is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>ds, </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">this bean is a bean which have a function to access MySQL Database, this bean use the class that belongs to </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>Spring Framework</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> which is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>DriverManagerDataSource </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">class</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>. </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> And then, just because this is the Spring access block to connect to database, so we have to supply the property that related with the connection to database creation, such as </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>username, url, password, dan driverClassName</strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> of the database that we will use and it’s property given is depends on the setting of our MySQL database settings. </span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">And then the 2</span></span><sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">nd</span></span></sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> bean is a bean that will represent DAO Layer that we have created above. The property that has to be filled up by this bean is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>dataSource </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">property</span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>, </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">while the reference of this bean property is </span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>ds </strong></span></span><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">bean that we have cerated before.</span></span></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">And the usage of this DAO Layer on Java Console Application, shown as the codes below:<br />
</span></span></p>
<pre style="border:1px dashed #999999;overflow:auto;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;color:#000000;background-color:#eeeeee;font-size:12px;line-height:14px;width:100%;padding:5px;"><code>package org.mojo.spring.application;

import org.mojo.spring.dao.JdbcDao.WebAccountJdbcDAO;
import org.mojo.spring.entity.WebAccount;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: Mar 15, 2009
 * Time: 11:05:55 AM
 * To change this template use File | Settings | File Templates.
 */
public class SpringReadDatabase {

    private WebAccountJdbcDAO dao = null;
    public static void main(String[] args) {
        //call SpringConfiguration File
        ApplicationContext ctx = new FileSystemXmlApplicationContext("config/applicationContext.xml");
        SpringReadDatabase app = new SpringReadDatabase();

        //call Desired bean
        app.dao = (WebAccountJdbcDAO) ctx.getBean("webAccountDAO");

        //declare Variable
        WebAccount[] waList = null;

        //getNumOfWebAccount
        int i = app.dao.getNumOfWebAccount();
        System.out.println("Num Rows : " + i);

        //getWebAccountList
        List&lt;WebAccount&gt; list = app.dao.getWebAccountList(false,0);

        //convert List to ObjectArray
        if (list.size() &gt; 0) {
            waList = new WebAccount[list.size()];
            for (short j = 0; j &lt; list.size(); j++) {
                waList[j] = list.get(j);
            }
        }

        //iterate ObjectArray to PrintOut to console
        for (int j = 0; j &lt; waList.length; j++) {
            WebAccount webAccount = waList[j];
            System.out.println("Name : " + webAccount.getUserName());
            System.out.println("Password : " + webAccount.getPassword());
            System.out.println("FullWebAccount : " + webAccount);
        }

    }

    public void setDao(WebAccountJdbcDAO dao) {
        this.dao = dao;
    }
}
</code></pre>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;" align="justify"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">That’s it, that’s how we use the DAO Layer that we have created before by using Spring Framework in Java Console Application. To discuss this java console application, please do your own analyzing in order to get more understanding of the codes that we have created. </span></span></p>
<p style="margin-bottom:0;" align="justify"> </p>
<p style="margin-bottom:0;" align="right"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">I hope this will helpful.</span></span></p>
<p style="margin-bottom:0;" align="right"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">Menteng, March 15</span></span><sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;">th</span></span></sup><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"> 2009</span></span></p>
<p style="margin-bottom:0;" align="right"> </p>
<p style="margin-bottom:0;" align="right"><span style="font-family:Tahoma,sans-serif;"><span style="font-size:small;"><strong>josescalia</strong></span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=154&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2009/04/07/using-spring-framework-on-creating-dao-layer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://opensource.atlassian.com/confluence/spring/download/attachments/1872/logo.jpg" medium="image">
			<media:title type="html">Spring Logo</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing Property File Using Spring Framework</title>
		<link>http://josescalia.wordpress.com/2009/03/10/accessing-property-file-using-spring-framework/</link>
		<comments>http://josescalia.wordpress.com/2009/03/10/accessing-property-file-using-spring-framework/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 02:07:19 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[daily]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=144</guid>
		<description><![CDATA[On the previous post in this blog using Indonesian language, we tried to use property file to access database in order to avoid hardcode mechanism, and the accessing of the property file by using a class named ConfigProperties, now we will try to access property file without using those class but we will try to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=144&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On the previous post in this <em>blog</em> using Indonesian language, we tried to use property file to access database in order to avoid hardcode mechanism, and the accessing of the property file by using a class named <strong>ConfigProperties, </strong>now we will try to access property file without using those class but we will try to use <strong><a href="http://www.springsource.org/">Spring Framework</a></strong> to access property file<strong>.</strong></p>
<p class="MsoNormal"><span>As we knew, the existence of <strong>Spring Framework</strong> on <strong>Java </strong>technology is really-really help us the <strong>Java</strong> Developer, the modularity of this framework has made the enterprise java project development is easier to rebuild or modify.</span></p>
<p class="MsoNormal"><span>We will not discuss much more about the <strong>Spring Framework</strong> here, we only will try to use the Spring Framework one of this framework feature to access property file. And of course the values of the property file to be used on our application chain later.</span></p>
<p class="MsoNormal"><span>Let’s go directly to try this out. On <strong>Spring Framework,</strong> the usage of <strong>bean</strong> became a must, that’s why we will create an object as a representation of a bean, the scenario that we will make is every item that exist on property file will become a property of the object that that we have created. Let’s make the property file just like below:</span></p>
<p class="MsoNormal"><strong><span>application.properties </span></strong><span>file:</span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>application.name=mojo
application.password=mojo123
application.url=http://localhost:8080/test_doang/test.jsp
</code></pre>
<p>We will put this file on <strong>config</strong> folder, a line with the <strong>src </strong>folder, just like below picture shown:</p>
<p class="MsoNormal" style="text-align:left;"><span><img class="aligncenter size-full wp-image-145" title="foldermacam2spring" src="http://josescalia.files.wordpress.com/2009/03/foldermacam2spring.jpg" alt="foldermacam2spring" width="655" height="313" /></span></p>
<p class="MsoNormal"><span>With the item of the property file, we will create a simple object of <strong>Java pojo </strong>which will represent each item that exist on the property file above. The source code of this object is below:</span></p>
<p class="MsoNormal"><strong><span>PropertyHolder.java </span></strong><span>file:</span></p>
<p class="MsoNormal"><strong></strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>package org.mojo.spring.entity;
/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: Mar 9, 2009
 * Time: 7:04:46 PM
 * To change this template use File | Settings | File Templates.
 */
public class PropertyHolder {
    private String name;
    private String password;
    private String url;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String toString() {
        return "PropertyHolder{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", url='" + url + '\'' +
                '}';
    }
}
</code></pre>
<p></strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">On above source code, we create a file named </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>PropertyHolder.java</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">. On this file we only create 3 property of the object, because there’s only 3 item on the property file. On the usage, each property of this object will hold values that exist on the property file.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">In order to make each item on the property file can be inject into each object property, we have to define the object on </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>Spring</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"> configuration file, so when the application run, this configuration will be called at first line and finally each item on the </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>property </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">file can be injected into each property of the </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>PropertyHolder</strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"> object that we have created before. Below is the definition of the object that we define as a bean on </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>spring </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">configuration file, this file will also put on same folder with the property file location which is on </span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>config </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">folder.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>applicationContext-app.xml </strong></span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;">file</span></span><span style="font-family:Tahoma, sans-serif;"><span style="font-size:x-small;"><strong>:</strong></span></span></p>
<p> </p>
<p><strong> </strong></p>
<p class="MsoNormal"> </p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt;
&lt;beans&gt;

    &lt;bean id="propertyConfigurer"          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
    &lt;property name="location" value="config/application.properties"/&gt;
   &lt;/bean&gt;

       &lt;!-- Local Data Holder --&gt;
    &lt;bean id="propertyHolder" class="org.mojo.spring.entity.PropertyHolder"&gt;
        &lt;property name="name" value="${application.name}"/&gt;
        &lt;property name="password" value="${application.password}"/&gt;
        &lt;property name="url" value="${application.url}"/&gt;
    &lt;/bean&gt;
&lt;/beans&gt;
</code></pre>
<p>Basically, when an application that using Spring Framework start running, then all the bean that already configured on Spring configuration file will also called one by one, even maybe one bean will depends on another bean. On the defined bean above, we can see that we have defined two beans there, the first bean have an id called “propertyConfigurer”, this bean have a function to give information to the Spring Framework the location of the property file. While the other bean given an id as “propertyHolder”, this bean is a map of the object that we have created before. Let’s make an attention to the defined class of the second bean, and then each property that defined on the block of this defined bean, this is how we map each item of the property file to each property on the object.</p>
<p class="MsoNormal"><span>Actually, this is the main focus of our try-it-out today, here’s how we access each items on the property file using <strong>Spring Framework. </strong>And if when we want to use the value of the property file items, all we need is just called the <strong>PropertyHolder</strong> object only, a line before we set the <strong>PropertyHolder</strong> object for sure. The usage example is just like below:</span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>package org.mojo.spring.application;

import org.mojo.spring.entity.PropertyHolder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 * User: Mojo
 * Date: Mar 9, 2009
 * Time: 7:06:35 PM
 * To change this template use File | Settings | File Templates.
 */
public class TestReadProperty {
    private PropertyHolder holder =null;

    public void setHolder(PropertyHolder holder) {
        this.holder = holder;
    }

    public static void main(String[] args) {
        ApplicationContext context    = new FileSystemXmlApplicationContext("config/applicationContext-app.xml");
        TestReadProperty app = new TestReadProperty();
        app.setHolder((PropertyHolder) context.getBean("propertyHolder"));

        System.out.println("Name : " + app.holder.getName());
        System.out.println("Password : " + app.holder.getPassword());
        System.out.println("Url : " + app.holder.getUrl());
        System.out.println("full : " + app.holder);
    }
}
</code></pre>
<p>On the source code of usage example above, we can describe it just like this:</p>
<p class="MsoNormal"><span>At first <strong>PropertyHolder</strong> object defined as a private variable named as <strong>holder. </strong>Then there’s a method which have a function as a setter of the <strong>holder</strong> object. And then on the main method of this sample program, we have defined an <strong>ApplicationContext</strong> as an object, this context called the Spring Framework configuration file, and then we have to define this program as an object too, in order to make all the property of the object can be called on the main method.</span></p>
<p class="MsoNormal"><span>The next step is, set the <strong>PropertyHolder</strong> object by calling setter method of the <strong>PropertyHolder </strong>that we have made before on this example program. When this method called, then automatically Spring Framework will fill up the property of <strong>PropertyHolder</strong> object with the value of each item that exists on the property file. And the last step is we tried to print-out the value of object property that owned by <strong>PropertyHolder</strong> class to console. And don’t forget to import all the necessary class and library that needed by this example application on the top line of this example program as we seen above.</span></p>
<p class="MsoNormal"><span>That’s it, our try-it-out today, a little try-out that using one the feature of <strong>Spring Framework</strong> that has a lot and useful feature that we can use on our development project. And if you want to try-it too, don’t forget to download the library of Spring Framework and other libraries that become dependency libraries for the Spring Framework it self</span></p>
<p class="MsoNormal"><span>Have a nice try ….!!!</span></p>
<p class="MsoNormal" align="right"><span> </span></p>
<p class="MsoNormal" align="right"><span> </span></p>
<p class="MsoNormal" align="right"><span>I Hope this will helpfull</span></p>
<p class="MsoNormal" align="right"><strong><span>Menteng</span></strong><span>, March 10, 2009</span></p>
<p class="MsoNormal" align="right"><span> </span></p>
<p class="MsoNormal" align="right"><strong><span>Josescalia</span></strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=144&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2009/03/10/accessing-property-file-using-spring-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/03/foldermacam2spring.jpg" medium="image">
			<media:title type="html">foldermacam2spring</media:title>
		</media:content>
	</item>
		<item>
		<title>My First Flex Project</title>
		<link>http://josescalia.wordpress.com/2009/03/09/my-first-flex-project/</link>
		<comments>http://josescalia.wordpress.com/2009/03/09/my-first-flex-project/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 05:54:49 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[activity]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=137</guid>
		<description><![CDATA[Two weeks ago, Vises, my work mate is busy creating something. I made an attention of what he busy for, and I found that he is recreating an absence application that I have made 6 months ago. I have created this absence application using Java Swing as a client and J2EE with Spring Framework as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=137&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoBodyText">Two weeks ago, <strong>Vises, </strong>my work mate is busy creating something. I made an attention of what he busy for, and I found that he is recreating an absence application that I have made 6 months ago. I have created this absence application using <strong><a href="http://en.wikipedia.org/wiki/Swing_(Java)">Java Swing</a></strong> as a client and <a href="http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition"><strong>J2EE </strong></a>with<strong> </strong><a href="http://www.springsource.org/"><strong>Spring Framework</strong></a><strong> </strong>as its server. I made this application because the <strong>HRD</strong> and <strong>Finance </strong>division of my office wanted me to create an application that able to log staff absences, so the finance division can pay the meal allowance for the staff based on its log every day.</p>
<p class="MsoNormal">The unique thing of this friend activity is, he tried to rebuild this absence application by using<strong> </strong><a href="http://www.adobe.com/products/flex/"><strong>Adobe Flex</strong></a>. Well, I was interested with this Adobe Flex, my interest is more to Adobe Flex ability to create a pretty <a href="http://en.wikipedia.org/wiki/Graphical_user_interface"><strong>GUI </strong></a>design. By using <strong><a href="http://www.adobe.com/products/flex/features/flex_builder/">Adobe Flex Builder</a></strong>, the making of design a GUI application is just simple drag and drop. It looks like creating a GUI application in Java by using the <strong><a href="http://www.netbeans.org/">Netbeans </a></strong>and its <strong><a href="http://www.netbeans.org/files/documents/4/475/matisse.html">Matisse Builder</a></strong> plug in. Actually there’s a little disappoint of mine, when I’m using Netbeans to create a Java GUI application. Sometimes the release build of my Java GUI application is not appropriate with the design of development. After seeing this Adobe Flex, I thought I should change my presentation layer of an application especially Desktop Application by using this Adobe Flex.</p>
<p class="MsoBodyText">For about one weeks and three days, I search reference and then try to use this Adobe Flex as a presentation layer of my created application. And indeed, I have found that I easier to use Adobe Flex as a presentation layer of my application. And its looks like that I will decide to use Adobe Flex as a presentation layer of applications that I will create in the future.</p>
<p class="MsoBodyText"><strong>Adobe Flex</strong> supported 3 Remote Application methods, which is:</p>
<p class="MsoBodyText"><em><span><span>1.<span>    </span></span></span></em><em>RPC Method (Remote Procedure Call).</em></p>
<p class="MsoBodyText"><span><span>2.<span>    </span></span></span><em>HTTP Service Method</em> (read Web Application return using XML format).</p>
<p class="MsoBodyText"><span><span>3.<span>    </span></span></span><em>Web Service Method</em>.</p>
<p class="MsoBodyText">From those methods, the most preferred method of mine is the second method which is <strong>HTTP Service </strong>method. <strong>Adobe Flex</strong> can read a Web Application XML formatted return value, and then the value can be inserted into components that exist on <strong>Adobe Flex </strong>framework.</p>
<p class="MsoBodyText">And I thought, because I have searched for about one week and three days about this Adobe Flex, it has to be at least one application that I can make using this Adobe Flex framework. Hmmm…&#8230; I thought what simple application that I can make with my limited knowledge of this Adobe Flex Framework. I got an idea; I will create a simple RSS Reader application. Why should RSS Reader? I thought a RSS reader is XML formatted, so it will be easier to make, because I don’t have to design the XML format for my first simple Flex application.</p>
<p class="MsoBodyText">And after one day in front of my laptop try to create this application, finally my First Adobe Flex project created. Here are screenshot of my Flex RSS Reader Application.</p>
<p class="MsoBodyText">Picture-1:</p>
<p class="MsoBodyText" style="text-align:center;"><img class="aligncenter size-full wp-image-138" title="rssreader-tab1" src="http://josescalia.files.wordpress.com/2009/03/rssreader-tab1.jpg" alt="rssreader-tab1" width="645" height="360" />Picture-2:</p>
<p class="MsoBodyText" style="text-align:center;"><img class="aligncenter size-full wp-image-139" title="rssreader-tab2" src="http://josescalia.files.wordpress.com/2009/03/rssreader-tab2.jpg" alt="rssreader-tab2" width="645" height="360" /></p>
<p class="MsoBodyText">Let me try to describe here about the concept of my flex RSS Reader application. This RSS Reader application has 2 tabs. The first tab is RSS Reader, this is the main function of this application as it’s seen on picture-1, while the 2nd tab contains an form that have functions that can manage RSS link to be added, updated, or deleted by using this tab as it’s seen on picture -2.</p>
<p class="MsoBodyText">On screenshot of picture-1, we can see there’s a combo box that user can choose, from what resource of the news that he would like to read. When user clicks one of the sources from the combo box, this application will try to request RSS Feeder to a link that became a value data on the combo box. After all the result of the request done, this application will automatically load the result of news items to Data Grid component on RSS List Panel, and when one of the news item on Data Grid component clicked by the user, this application will also automatically load the short description of the news to Text Area component on the Description panel. When user interest to read the full article of the news that selected, user can click <strong>Read This</strong> button. When this button clicked, then the default browser of user’s computer will show and directly open the page containing the news that he would love to read.</p>
<p class="MsoBodyText">While on the screenshot of picture-2, is a view of <strong>RSS Entry</strong> tab, which on this tab, user can manage the sources of the RSS Reader on this application. When user wants to add a new source of RSS Feeder, he just needs to enter each text boxes on <strong>Add RSS Entry Panel </strong>and then click Add button. And when he needs to update or delete one of sources that already loaded on <strong>Data Grid</strong> on the <strong>Listed RSS Entry </strong>panel, all he needs is just click the item on the Data Grid and the application will automatically fill up the text boxes on the <strong>Edit RSS Entry</strong> panel, and then he click the update or delete button depends on what he want to do with the source item. And then we also can see on the both picture there’s an <strong>Exit</strong> button on the right top of the form. The function of this button is to close this Flex RSS Reader application.</p>
<p class="MsoBodyText">This simple Flex <strong>RSS Reader </strong>application actually has a <strong><em>Back-End Application </em></strong>that I have created using <strong><a href="http://www.php.net/">PHP </a></strong>and <strong><a href="http://www.mysql.com/">MySQL Database</a></strong>. The <strong><em>Back-End Application </em></strong>will produce a web page XML Formatted result containing a list of RSS Reader sources that stored on MySQL Database table. Just because I don’t understand yet about how to use the property file on Flex Development, I do hardcode to write a link of this<em> </em><strong>RSS Reader<em> Back-End Application. </em></strong><span> </span>The Link of this <strong>RSS Reader<em> Back-End Application </em></strong>is: <a href="http://localhost/flex_xml_lab/rss/rss_feeder.php">http://localhost/flex_xml_lab/rss/rss_feeder.php</a>. If you are interested of this application, then you also have to create this <strong>RSS Reader <em>Back-End Application, </em></strong>and the link<strong><em> </em></strong>must be same with above Back-End Link that I have hardcode on this application.</p>
<p class="MsoBodyText">And the XML formatted result that produced by the <strong><em>Back-End Application </em></strong>must have a pattern below:</p>
<p> </p>
<p><code></p>
<pre>&lt;rss_list&gt;
     &lt;RSS&gt;
        &lt;RSS_ID&gt;1&lt;/RSS_ID&gt;
        &lt;label&gt;Detik&lt;/label&gt;
        &lt;data&gt;http://rss.detik.com/index.php/detikcom&lt;/data&gt;
     &lt;/RSS&gt;
     &lt;RSS&gt;
         &lt;RSS_ID&gt;2&lt;/RSS_ID&gt;
         &lt;label&gt;Detik Inet (local sample)&lt;/label&gt;
         &lt;data&gt;http://localhost/flex_xml_lab/rss/rss_detikinet.xml&lt;/data&gt;
     &lt;/RSS&gt;
     &lt;RSS&gt;
        &lt;RSS_ID&gt;3&lt;/RSS_ID&gt;
        &lt;label&gt;Google News (local sample)&lt;/label&gt;
        &lt;data&gt;http://localhost/flex_xml_lab/rss/rss_google.xml&lt;/data&gt;
     &lt;/RSS&gt;
     &lt;RSS&gt;
        &lt;RSS_ID&gt;10&lt;/RSS_ID&gt;
        &lt;label&gt;Detik Inet&lt;/label&gt;
        &lt;data&gt;http://www.detikinet.com/feed&lt;/data&gt;
     &lt;/RSS&gt;
     &lt;RSS&gt;
         &lt;RSS_ID&gt;11&lt;/RSS_ID&gt;
         &lt;label&gt;Antara Terkini&lt;/label&gt;
         &lt;data&gt;http://www.antara.co.id/rss/news.xml&lt;/data&gt;
     &lt;/RSS&gt;
     &lt;RSS&gt;
         &lt;RSS_ID&gt;12&lt;/RSS_ID&gt;
         &lt;label&gt;Antara Sains Dan Teknologi&lt;/label&gt;
         &lt;data&gt;http://www.antara.co.id/rss/tek.xml&lt;/data&gt;
      &lt;/RSS&gt;
&lt;/rss_list&gt;</pre>
<p></code></p>
<p> </p>
<p>On the Back-End Application, I made a table on MySQL Database named <strong>flex_project </strong>and the table name is <strong>rss_feeder</strong>, and the detail of the table shown below:</p>
<p class="MsoBodyText"><img class="aligncenter size-full wp-image-140" title="desc_rss_feeder" src="http://josescalia.files.wordpress.com/2009/03/desc_rss_feeder.jpg" alt="desc_rss_feeder" width="485" height="146" /></p>
<p class="MsoBodyText">Or you also can make the table with this MySQL Syntax:</p>
<p> </p>
<p><code></p>
<pre>CREATE TABLE `rss_feeder` (
  `RSS_ID` int(100) NOT NULL AUTO_INCREMENT,
  `RSS_NAME` varchar(100) NOT NULL,
  `RSS_LINK` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`RSS_ID`)
);</pre>
<p></code></p>
<p> </p>
<p>And then, to create a Back-End Application using php, I have created a simple <strong>PHP CRUD </strong>(Create, Read, Update, and Delete) application to do select, insert, update, and delete database operation on to the table. I simplified this Back-End Application by creating only one php file. And the interaction between the database and php file can be recognized by a parameter named <strong>action </strong>for each database operation<strong>.</strong> I choose HTTP GET methods for interaction between a PHP and Flex RSS Reader Application, so the each database operation on the php file can be executed by detail below:</p>
<p class="MsoBodyText"><span><span>·<span>      </span></span></span>Action <strong>Read</strong> rss_feeder</p>
<p class="MsoBodyText"><a href="http://localhost/flex_xml_lab/rss/rss_feeder.php?action=read">http://localhost/flex_xml_lab/rss/rss_feeder.php?action=read</a></p>
<p class="MsoBodyText"><span><span>·<span>      </span></span></span>Action <strong>Insert</strong> rss_feeder</p>
<p class="MsoBodyText"><a href="http://localhost/flex_xml_lab/rss/rss_feeder.php?action=add&amp;rss_name=%5bname_of_rss_source%5d&amp;rss_link=%5blink_of_rss%5d">http://localhost/flex_xml_lab/rss/rss_feeder.php?action=add&amp;rss_name=[name_of_rss_source]&amp;rss_link=[link_of_rss]</a></p>
<p class="MsoBodyText"><span><span>·<span>      </span></span></span>Action Edit rss_reader</p>
<p class="Quotations"><a href="http://localhost/flex_xml_lab/rss/rss_feeder.php?action=add&amp;rss_id=%5bid_of_rss%5d&amp;rss_name=%5bname_of_rss_source%5d&amp;rss_link=%5blink_of_rss%5d">http://localhost/flex_xml_lab/rss/rss_feeder.php?action=add&amp;rss_id=[id_of_rss]&amp;rss_name=[name_of_rss_source]&amp;rss_link=[link_of_rss]</a></p>
<p class="MsoBodyText"><span><span>·<span>      </span></span></span>Action Delete rss_reader</p>
<p class="Quotations"><a href="http://localhost/flex_xml_lab/rss/rss_feeder.php?action=delete&amp;rss_id=%5bid_of_rss%5d">http://localhost/flex_xml_lab/rss/rss_feeder.php?action=delete&amp;rss_id=[id_of_rss]</a></p>
<p class="MsoBodyText">To accommodate above methods, then I created one php file only, and the source of the php file is below:</p>
<p> </p>
<p><code></p>
<pre>&lt;?php
//define database paramater
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "9mtouche9" );
define( "DATABASE_NAME", "flex_project" );
$conn = mysql_connect(DATABASE_SERVER,DATABASE_USERNAME, DATABASE_PASSWORD);
mysql_select_db( DATABASE_NAME );
//define HTTP GET paramater
$action = $_GET['action'];
$return="";
//action read
if($action=="read"){
    $query = "select * from rss_feeder";
    $res = mysql_query($query);
    //return list of rss link
    $return = "&lt;rss_list&gt;";
         while ($result = mysql_fetch_object($res)) {
                   $return .="&lt;RSS&gt;
              &lt;RSS_ID&gt;$result-&gt;RSS_ID&lt;/RSS_ID&gt;
              &lt;label&gt;$result-&gt;RSS_NAME&lt;/label&gt;
              &lt;data&gt;$result-&gt;RSS_LINK&lt;/data&gt;
              &lt;/RSS&gt;";
         }
    $return .= "&lt;/rss_list&gt;";
    mysql_close();
}
//action add
if($action=="add"){
    $rss_name = $_GET['rss_name'];
    $rss_link = $_GET['rss_link'];
    $query = "insert into rss_feeder(RSS_NAME,RSS_LINK) values('$rss_name','$rss_link')";
    $res = mysql_query($query);
    //$result = mysql_fetch_row($res);
    //return list of rss link
    $return = "&lt;action_result&gt;";
       if($res){
         $return .= "true";
       }else{
         $return .= "false";
       }
    $return .= "&lt;/action_result&gt;";
}
//action edit
if($action=="edit"){
    $rss_id = $_GET['rss_id'];
    $rss_name = $_GET['rss_name'];
    $rss_link = $_GET['rss_link'];
    $query = "update rss_feeder set RSS_NAME='$rss_name', RSS_LINK='$rss_link' where RSS_ID='$rss_id'";
    $res = mysql_query($query);
    //$result = mysql_fetch_row($res);
    //return list of rss link
    $return = "&lt;action_result&gt;";
       if($res){
         $return .= "true";
       }else{
         $return .= "false";
       }
    $return .= "&lt;/action_result&gt;";
}
//action delete
if($action=="delete"){
    $rss_id = $_GET['rss_id'];
    $query = "delete from rss_feeder where RSS_ID='$rss_id'";
    $res = mysql_query($query);
    //$result = mysql_fetch_row($res);
    //return list of rss link
    $return = "&lt;action_result&gt;";
       if($res){
         $return .= "true";
       }else{
         $return .= "false";
       }
    $return .= "&lt;/action_result&gt;";
}
//print out result
print($return);
?&gt;</pre>
<p></code></p>
<p> </p>
<p> </p>
<p class="MsoBodyText">On the script, indeed there’s another action instead <strong>read</strong>, another action also return XML formatted result, just because the return of another action is boolean type, so let’s just ignore it.</p>
<p class="MsoBodyText">That’s it, a short description of this simple RSS Reader application that I have made by using Adobe Flex. I’m quite satisfied, because this Adobe Flex is so easy to design and to create a GUI application. And for the result the output of the GUI is prettier than Java Swing Application. And for the release build, Adobe Flex Builder has also owned it by using wizard, it’s really simple at least for me.</p>
<p class="MsoBodyText">And for you, who wants to learn or maybe modified and learning together with me, below is the sources link of My First Flex Project</p>
<p class="MsoBodyText"><span><span>1.<span>    </span></span></span><strong><em><a href="http://www.geocities.com/josescalia/project-files/RSSReader.zip">RSS Reader </a></em></strong><em><a href="http://www.geocities.com/josescalia/project-files/RSSReader.zip">Source</a></em><a href="http://www.geocities.com/josescalia/project-files/RSSReader.zip"> </a><em><a href="http://www.geocities.com/josescalia/project-files/RSSReader.zip">(Zip File)</a></em></p>
<p class="MsoBodyText"><em><span><span>2.<span>    </span></span></span></em><strong><em><a href="http://www.geocities.com/josescalia/project-files/rss_feeder.php">PHP </a></em></strong><em><a href="http://www.geocities.com/josescalia/project-files/rss_feeder.php">Back-End Application</a></em></p>
<p class="MsoBodyText"><em><span><span>3.<span>    </span></span></span></em><strong><em><a href="http://www.geocities.com/josescalia/project-files/flex_project.sql.txt">MySQL</a></em></strong><em><a href="http://www.geocities.com/josescalia/project-files/flex_project.sql.txt"> source file</a>.</em></p>
<p class="MsoBodyText">And Please feel free to rebuild and modify with your own need and desired, and don’t forget to give back your comment through this post.</p>
<p class="MsoBodyText"> </p>
<p class="MsoBodyText" align="right">Menteng, March 7<sup>th</sup> 2009.</p>
<p class="MsoBodyText" align="right">I hope this will helpful</p>
<p class="MsoBodyText" align="right"> </p>
<p style="text-align:right;"><span><strong>Josescalia</strong></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=137&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2009/03/09/my-first-flex-project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/03/rssreader-tab1.jpg" medium="image">
			<media:title type="html">rssreader-tab1</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/03/rssreader-tab2.jpg" medium="image">
			<media:title type="html">rssreader-tab2</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/03/desc_rss_feeder.jpg" medium="image">
			<media:title type="html">desc_rss_feeder</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing Ms Access Database with Java</title>
		<link>http://josescalia.wordpress.com/2009/02/09/accessing-ms-access-database-with-java/</link>
		<comments>http://josescalia.wordpress.com/2009/02/09/accessing-ms-access-database-with-java/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 13:18:54 +0000</pubDate>
		<dc:creator>josescalia</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://josescalia.wordpress.com/?p=128</guid>
		<description><![CDATA[Microsoft Access is a software database which still has been used until now. This database is very light, so this is an advantage for it’s user to chose this type of database in order to save the data. Microsoft Access is also come with a lot and usable feature. Starting from creating table, form, queries, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=128&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">is a software </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>database </em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">which still has been used until now. This </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>database </em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">is very light, so this is an advantage for it’s user to chose this type of database in order to save the data. </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">is also come with a lot and usable feature. Starting from creating table, form, queries, report, and even the macros, everything became simple when we want a do it on </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access</strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">, and its typically often that this </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">is used by everyone to make a database application where the data will be save on its self.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">We will not discuss a lot about what </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access</strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> can do here. On this time we will try to accessing a database that created using </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">with our beloved programming language which is </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Java</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Now, let’s arrange a scenario to discuss this topic:</span></span></p>
<ol>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Create 	a database file named </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Java_MsAccess </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">using </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft 	Access.</strong></em></span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Create 	a table on that database which contains fields:</span></span></p>
</li>
</ol>
<ul>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Field 	name: </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>CustomerID</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">, 	type </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Number</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> (</span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>single</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">).</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Field 	name: </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>CustomerName</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">, 	type </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Text</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> (50).</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Field 	name: </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>CustomerAddress</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">, 	type </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Text</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> (250).</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Field 	name: </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>CustomerPhone</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">, 	type </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Text</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> (20).</span></span></p>
</li>
</ul>
<ol>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Fill 	up the table with necessary data.</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Create 	a DSN </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Data 	source </em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">DSN 	for this database.</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Create 	a Java Application for accessing this database using the Data 	source.</span></span></p>
</li>
</ol>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">For the step 1 until the step 4, we will attach a screen shot only here, because I believe that we can do these steps without written reference here.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Okay, for the 1</span></span><sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">st</span></span></sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> step, below is the screen capture:</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana;"><img class="aligncenter size-full wp-image-129" title="createmsaccessdb" src="http://josescalia.files.wordpress.com/2009/02/createmsaccessdb.jpg" alt="createmsaccessdb" width="682" height="507" /></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And for the 2</span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">nd</span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> step, below is screen capture:</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><img class="aligncenter size-full wp-image-129" title="createmsaccessdb" src="http://josescalia.files.wordpress.com/2009/02/createmsaccessdb.jpg" alt="createmsaccessdb" width="682" height="507" /></span></span></p>
<p align="JUSTIFY"> </p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And for the step 3</span></span><sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">rd</span></span></sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">, this is how we do it:</span></span></p>
<p style="text-align:center;" align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><img class="aligncenter size-full wp-image-131" title="fillupmsaccesstable" src="http://josescalia.files.wordpress.com/2009/02/fillupmsaccesstable.jpg" alt="fillupmsaccesstable" width="606" height="426" /></span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And for the step 4</span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">th, </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">okay for this step we will explain a little bit, so we can understand how to create a data source on windows platform for this database.</span></span></p>
<ul>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Click 	start </span></span><span style="font-family:Wingdings;"><span style="font-size:small;"></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Control 	Panel</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Wingdings;"><span style="font-size:small;"></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Administrative</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Tools</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Wingdings;"><span style="font-size:small;"></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Data</strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>Sources(ODBC)</strong></span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And 	then on </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>ODBC </strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Database </em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Administrator 	window, click Add button and then choose Driver do </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft 	Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">(*.mdb), 	and then click finish button.</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And 	then on </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>ODBC </strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft 	Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Setup 	window, give a name for this database </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Java</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">MsAccess, 	and then choose the database file by clicking select button, and 	find the database file that we have crated before. This is the image 	looks like:</span></span></p>
</li>
</ul>
<p style="text-align:center;" align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><img class="aligncenter size-full wp-image-132" title="createodbcdsn" src="http://josescalia.files.wordpress.com/2009/02/createodbcdsn.jpg" alt="createodbcdsn" width="692" height="562" /></span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And the DSN data source named by </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Java</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">MsAccess created successfully. Now we arrive to the step that we are cannot be patient to wait which is creating the Java application. Okay, here’s the process flow of our Java Application looks like:</span></span></p>
<ol>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Choose 	and initialize the driver for this ODBC data source.</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Create 	a database connection to this </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>ODBC </strong></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">data 	source.</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Create 	a Statement for the </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>SQL 	Queries</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">.</span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Pick 	up the result of </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Query 	Statement</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> executiom onto </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>ResultSet</em></span></span></p>
</li>
<li>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Printout 	the </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>ResultSet</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">.</span></span></p>
</li>
</ol>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">From these scenarios, let’s implement it on to Java Code. Take a look this Java source code below:</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>package org.mojo.blog.Java_depth.aboutMsOffice;

import Java.sql.*;

/**
* Created by IntelliJ IDEA.&lt;br&gt;
* User: Mojo&lt;br&gt;
* Date: 08 Feb 09&lt;br&gt;
* Time: 22:30:08&lt;p&gt;
*/
public class MsAccessJava {
private static String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
private static String url = "jdbc:odbc:JavaMsAccess";
 public static void main(String[] args) {
     String sql ="SELECT * from tblCustomer";
       try {
          Class.forName(driverName);
          Connection conn = DriverManager.getConnection(url);
          System.out.println("Connection Established..");
          Statement stmt = conn.createStatement();
          ResultSet rs = stmt.executeQuery(sql);
          while (rs.next()){
             System.out.println("+------------- Detail Customer ----------------------+");
             System.out.println("Customer ID : "+ rs.getInt(1));
             System.out.println("Customer Name : "+ rs.getString(2));
             System.out.println("Customer Address : "+ rs.getString(3));
             System.out.println("Customer Phone : "+ rs.getString(4));
             System.out.println("+----------------------------------------------------+");
             System.out.println("\n");
         }
       } catch (SQLException e) {
          e.printStackTrace();
       } catch (ClassNotFoundException e) {
          e.printStackTrace();
     }
  }
}
</code></pre>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">Let’s discuss line per line the above code.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">The first line is a line where this Java file located on </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">its package. While the 3</span></span><sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">rd</span></span></sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> line is a line where all the classes of </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>Java.sql</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> library has imported. And then we can see inside the program that there are two private static string variable defined which is:</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>………..
   private static String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
   private static String url = "jdbc:odbc:JavaMsAccess";
………..</code></pre>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">The first variable is a driver name that we will use it later to accessing ODBC data source, while the second variable is an url of the data source that we would like to access, just remember this data source name have to equals with the data source that we have created before which is: </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><strong>JavaMsAccess.</strong></span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And then let’s take a look the codes inside the main method. The first line on this main method is a line where we define a SQL query which we will use to access these </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>Microsoft Access </strong></em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">database. And then we create a try-catch block, this block is the block which all main process of the accessing process is happen. First in this block we initialize the driver that we have defined in the header of the program. And then we create a database connection and the print out the result of it’s connection.</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>…….
   Class.forName(driverName);
   Connection conn = DriverManager.getConnection(url);
   System.out.println("Connection Established..");
……….
</code></pre>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">The continuous steps are, create a statement, then execute the </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em>SQL Statement</em></span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"> using the SQL query that we have defined before.</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>…….
     Statement stmt = conn.createStatement();
     ResultSet rs = stmt.executeQuery(sql);
……….
</code></pre>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And the print out the result by loops the rs variable, which these ResultSet variable values had filled up before.</span></span></p>
<pre style="font-family:Andale Mono, Lucida Console, Monaco, fixed, monospace;color:#000000;background-color:#eee;font-size:12px;border:1px dashed #999999;line-height:14px;overflow:auto;width:100%;padding:5px;"><code>…….
   while (rs.next()){
        System.out.println("+----Detail Customer ------------------+");
        System.out.println("Customer ID : "+ rs.getInt(1));
        System.out.println("Customer Name : "+ rs.getString(2));
        System.out.println("Customer Address : "+ rs.getString(3));
        System.out.println("Customer Phone : "+ rs.getString(4));
        System.out.println("+--------------------------------------+");
        System.out.println("\n");
   }
…….<span style="font-family:Georgia;">
</span></code></pre>
<p style="text-align:auto;" align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">And then we add some catch statement to prevent error appear on runtime, and this catch is also can be use to trace the problem when error occured that can make our application cannot run properly.</span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;">If the program executed, and then the result will show just like image below &#8211; i have executed it on my favourite IDE, </span></span><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong>IntelliJidea 7.0.4</strong></em></span></span></p>
<p style="text-align:center;" align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong><img class="aligncenter size-full wp-image-133" title="executeodbc_java" src="http://josescalia.files.wordpress.com/2009/02/executeodbc_java.jpg" alt="executeodbc_java" width="614" height="384" /></strong></em></span></span></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><em><strong></strong></em></span></span></p>
<p><em><strong></strong></em></p>
<p><em><strong></strong></em></p>
<p><em><strong></p>
<p align="JUSTIFY"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><span style="font-weight:normal;"><span style="font-style:normal;">That&#8217;s it, that&#8217;s all our try out has finished. Please try and modify for your own need and your own desire.</span></span></span></span></p>
<p align="JUSTIFY"><span style="font-weight:normal;"><span style="font-style:normal;"><br />
</span></span></p>
<p align="RIGHT"><span style="font-style:normal;font-weight:normal;">Hope this will usefull</span></p>
<p align="RIGHT"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><span style="font-weight:normal;"><span style="font-style:normal;">Menteng, 09</span></span></span></span><sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><span style="font-weight:normal;"><span style="font-style:normal;">th</span></span></span></span></sup><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><span style="font-weight:normal;"><span style="font-style:normal;"> February, 2009</span></span></span></span></p>
<p align="RIGHT"><span style="font-weight:normal;"><span style="font-style:normal;"><br />
</span></span></p>
<p align="RIGHT"><span style="font-family:Verdana, sans-serif;"><span style="font-size:small;"><span style="font-weight:normal;"><span style="font-style:normal;">josescalia</span></span></span></span></p>
<p></strong></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/josescalia.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/josescalia.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/josescalia.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/josescalia.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/josescalia.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/josescalia.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/josescalia.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/josescalia.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=josescalia.wordpress.com&amp;blog=2216946&amp;post=128&amp;subd=josescalia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://josescalia.wordpress.com/2009/02/09/accessing-ms-access-database-with-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7fe4d61b394a2a7b7e04dc005f381a73?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">josescalia</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/02/createmsaccessdb.jpg" medium="image">
			<media:title type="html">createmsaccessdb</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/02/createmsaccessdb.jpg" medium="image">
			<media:title type="html">createmsaccessdb</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/02/fillupmsaccesstable.jpg" medium="image">
			<media:title type="html">fillupmsaccesstable</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/02/createodbcdsn.jpg" medium="image">
			<media:title type="html">createodbcdsn</media:title>
		</media:content>

		<media:content url="http://josescalia.files.wordpress.com/2009/02/executeodbc_java.jpg" medium="image">
			<media:title type="html">executeodbc_java</media:title>
		</media:content>
	</item>
	</channel>
</rss>
