<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andr&#233; L. S. &#187; Development</title>
	<atom:link href="http://www.andrels.com/wp-en_US/index.php/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andrels.com/wp-en_US</link>
	<description>Softwares Development, Technology and Games</description>
	<lastBuildDate>Wed, 08 Feb 2012 12:39:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Google launches Chrome for Android, finally1</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2012/02/google-launches-chrome-for-android-finally1/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2012/02/google-launches-chrome-for-android-finally1/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 22:38:15 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Devices]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[market]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=246</guid>
		<description><![CDATA[&#160; You can&#8217;t know but default Android&#8217;s browser isn&#8217;t Chrome, only a implementation of Webkit. Today(7), quietly, Google published the beta version<a href="http://www.andrels.com/wp-en_US/index.php/2012/02/google-launches-chrome-for-android-finally1/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-486" title="chrome_logo" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2012/02/chrome_logo.png" alt="" width="124" height="124" /></p>
<p>&nbsp;</p>
<p>You can&#8217;t know but default Android&#8217;s browser isn&#8217;t Chrome, only a implementation of <a href="http://pt.wikipedia.org/wiki/WebKit" target="_blank">Webkit</a>.</p>
<p>Today(7), quietly, Google published the beta version of your browser in Android Market. But, only the ICS (Ice Cream Sandwich), or above, is able to run it. I hope the Google change it to a most &#8220;accessible&#8221; version.</p>
<p>&nbsp;</p>
<p>The video below shows Chrome in action.</p>
<h5 style="text-align: center;"><object style="height: 448px; width: 560px;" width="560" height="448" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="https://www.youtube.com/v/lVjw7n_U37A?version=3&amp;feature=player_embedded" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><embed style="height: 448px; width: 560px;" width="560" height="448" type="application/x-shockwave-flash" src="https://www.youtube.com/v/lVjw7n_U37A?version=3&amp;feature=player_embedded" allowFullScreen="true" allowScriptAccess="always" allowfullscreen="true" allowscriptaccess="always" /></object><br />
Android Market</h5>
<p>Unfortunately I don&#8217;t have the Ice Cream Sandwich to write a review, but read complete description and comments of who already downloaded the brownser from <a href="https://market.android.com/details?id=com.android.chrome&amp;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5hbmRyb2lkLmNocm9tZSJd" target="_blank">Android Market</a>.</p>
<p>If you uses Chrome, share your experience with us. <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>See ya!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2012/02/google-launches-chrome-for-android-finally1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A easy way to compile many objects in Oracle database</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 22:42:47 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[PLSql]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=233</guid>
		<description><![CDATA[When compiles an object that is referenced by many others, they stay invalidated until Oracle compile they again and sometimes<a href="http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>When compiles an object that is referenced by many others, they stay invalidated until Oracle compile they again and sometimes it fails.</p>
<p>So, here&#8217;s a tip to compile several invalid packages, procedures and/or functions and fix this.</p>
<p>There is a command to compile all invalid objects under an user, the command is:</p>
<p>&lt;pre class=&#8221;brush:sql&#8221;&gt;exec dbms_ultility.compile_schema(&amp;lt;USER&amp;gt;);&lt;/pre&gt;</p>
<p>Replace  &amp;lt;USER&amp;gt; for &lt;i&gt;user&lt;/i&gt;, or for user name where invalid objects are.</p>
<p>This command is slow and not compiles objects invalidated by coding error. To find which are invalid you need runs the query below:</p>
<p>&lt;pre class=&#8221;brush:sql&#8221;&gt;<br />
select object_name<br />
from all_objects<br />
where status = &#8216;INVALID&#8217;<br />
&lt;/pre&gt;</p>
<p>Invalid objects will be listed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Motorola Droid Razr &#8211; The super smarphone Android</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/11/motorola-droid-razr-the-super-smarphone-android/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/11/motorola-droid-razr-the-super-smarphone-android/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 00:32:51 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[gingerbread]]></category>
		<category><![CDATA[icecream sandwich]]></category>
		<category><![CDATA[motorola]]></category>
		<category><![CDATA[razr]]></category>
		<category><![CDATA[smartphone]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=223</guid>
		<description><![CDATA[Recently released, the Motorola Droid Razr is the thinnest smartphone with 4G worldwide. With 7.1 mm thickness, it has a 4.3 inch<a href="http://www.andrels.com/wp-en_US/index.php/2011/11/motorola-droid-razr-the-super-smarphone-android/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-431 aligncenter" title="droid-razr" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/11/droid-razr.jpg" alt="" width="500" height="376" /></p>
<p>Recently released, the Motorola Droid Razr is the thinnest smartphone with 4G worldwide. With 7.1 mm thickness, it has a 4.3 inch Super AMOLED screen, 540 x 960 resolution and protected with Gorilla® Glass screen. Its 8MP camera, can record Full HD (1080p) videos, its front 1.3MP camera allow videos in HD resolution (720p).</p>
<p>More light and resistant, Motorola Razr is coated by <a href="http://pt.wikipedia.org/wiki/Kevlar" target="_blank">Kevlar®</a>, giving a more attractive finish.</p>
<p>Android Gingerbread (posteriorly Icecream Sandwich) is supported by your Dual-core processor 1.2 Ghz and 1GB RAM. Also can count with internal memory has 16 GB, more 16 GB (expansible to 32 GB) in MicroSD card that comes with it, EDGE, GPRS, 3G, Wi-FI and 4G, GPS and <a title="Inglês" href="http://en.wikipedia.org/wiki/Digital_Living_Network_Alliance" target="_blank">DLNA (Digital Living Network Alliance)</a> protocol.</p>
<p>Talking about connectivity, the smartphone will comes with <a href="http://www.motorola.com/Consumers/BR-PT/Consumer-Product-Services/MOTOCAST/Motocast" target="_blank">MotoCast</a> pre-installed. This application allows you to share your files, videos and music between your device and your PC trough Wi-Fi, 3G or 4G, without USB cable.</p>
<p>As Motorola Atrix, Droid Razr also compatible with <a href="http://www.motorola.com/Consumers/BR-PT/Consumer-Product-Services/WEBTOP/Meet-WEBTOP">Webtop</a> gadget.</p>
<p>The design of Motorola Droid Razr is based on his grandfather, Motorola Razr V3, wich sold 110 million units worldwide.</p>
<table style="background-color: #fff;" width="100%" border="0">
<tbody>
<tr>
<td style="background-color: #fff; border: none;" align="center" width="50%">
<p><div id="attachment_430" class="wp-caption alignnone" style="width: 210px"><img class="size-full wp-image-430 " title="razr-v3x" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/11/razr-v3x.jpg" alt="Razr V3 X" width="200" height="284" /><p class="wp-caption-text">Motorola Razr V3x</p></div></td>
<td style="background-color: #fff; border: none;" align="center">
<p><div id="attachment_432" class="wp-caption alignnone" style="width: 210px"><img class="size-full wp-image-432 " title="razr-droid" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/11/razr-droid.jpg" alt="Droid Razr" width="200" height="284" /><p class="wp-caption-text">Motorola Droid Razr</p></div></td>
</tr>
</tbody>
</table>
<p>The release was on november 16, but still is not possible find the device in Brazil, where the suggested price for Motorola is R$ 1999.00 (US$ 1110.00).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/11/motorola-droid-razr-the-super-smarphone-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apps can’t miss in your Android &#8211; Listen</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/10/apps-cant-miss-in-your-android-listen/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/10/apps-cant-miss-in-your-android-listen/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 20:33:32 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[market]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=215</guid>
		<description><![CDATA[You, that follows podcasts around the world and don&#8217;t have a computer all time to download them and copy them<a href="http://www.andrels.com/wp-en_US/index.php/2011/10/apps-cant-miss-in-your-android-listen/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignright size-full wp-image-415" style="margin-left: 10px; margin-right: 10px;" title="Listen" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/listen1.png" alt="" width="200" height="316" />You, that follows podcasts around the world and don&#8217;t have a computer all time to download them and copy them to your smartphone, can use <a href="https://market.android.com/details?id=com.google.android.apps.listen" target="_blank">Listen</a>.</p>
<p style="text-align: justify;">This application, developed by Google, allows you to find podcasts and subscribe to it. Podcast that aren&#8217;t found by search, can be subscribed manually in &#8220;My subscriptions&#8221; options.</p>
<p style="text-align: justify;">Here, with brazilian 3G quality, you will get a continuous audio (without buffer pauses) using the wi-fi connection or hearing tracks with 96kbps or less.</p>
<p style="text-align: justify;">The <a href="https://market.android.com/details?id=com.google.android.apps.listen" target="_blank">Listen</a> allows you download audios to listen it after, when you want and without internet connection.</p>
<p><strong>Link</strong>: <a href="https://market.android.com/details?id=com.google.android.apps.listen" target="_blank">Listen</a><br />
<strong>Price</strong>: Free<br />
<strong>Advertisement</strong>: No<br />
<strong>Rating</strong>*: 3,8/5</p>
<h5>* Rating obtained until publication</h5>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/10/apps-cant-miss-in-your-android-listen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharing 3G connection from Android to PCs and laptop through USB cable</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/10/sharing-3g-connection-from-android-to-pcs-and-laptop-through-usb-cable/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/10/sharing-3g-connection-from-android-to-pcs-and-laptop-through-usb-cable/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 03:19:36 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Devices]]></category>
		<category><![CDATA[Operational Systems]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[3g]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=203</guid>
		<description><![CDATA[Froyo, version 2.2 of Android, comes with application that allow you to share your 3G connection to anothers Wi-fi devices,<a href="http://www.andrels.com/wp-en_US/index.php/2011/10/sharing-3g-connection-from-android-to-pcs-and-laptop-through-usb-cable/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Froyo, version 2.2 of Android, comes with application that allow you to share your 3G connection to anothers Wi-fi devices, but, if you don&#8217;t have a Wi-fi network card in your computer, this application have not usability.</p>
<p style="text-align: justify;"><a href="https://market.android.com/details?id=com.proxoid&amp;feature=search_result" target="_blank">ProxoId</a>, free application available in <a href="https://market.android.com/" target="_blank">Android Marketing</a>, allows you to share connection from your Android  only using USB cable.</p>
<p style="text-align: justify;">It needs a stand alone program and Android drivers running in your PC/laptop to work.</p>
<p style="text-align: justify;">The driver and stand alone program can be found in a ZIP file for Windows 32 bits  <a href="http://www.baroukh.com/proxoid/proxoid-adb.zip" target="_blank">here</a>  and Windows 64 bits <a href="http://www.baroukh.com/proxoid/proxoid-adb64.zip">here</a>. If you&#8217;ve already installed manufacturer driver (from CD), skip to <strong>Finding your smartphone</strong> section.</p>
<h5 style="text-align: justify;">*Texts of images bellow are in Brazilian Portuguese</h5>
<p style="text-align: justify;"><span class="Apple-style-span" style="font-size: 20px; font-weight: bold;">Installing drivers</span></p>
<p style="text-align: justify;">Uncompress ZIP file and connect your Android to PC. The new hardware wizard will be shown.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-397" title="assistente" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img1.png" alt="" width="503" height="390" /></p>
<p style="text-align: justify;">Choose &#8220;No, not this time&#8221; and click in &#8220;Next&#8221;. In following screen, choose&#8221;Install from a list or specific location&#8221;. Click &#8220;Next&#8221;.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-398" title="img2" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img2.png" alt="" width="503" height="390" /></p>
<p style="text-align: justify;">Enable the options &#8220;Search for the best driver in these locations&#8221; and &#8220;Include this location in the search&#8221;, then click in &#8220;Browse&#8221;.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-399" title="img3" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img3.png" alt="" width="503" height="390" /></p>
<p style="text-align: justify;">Go to directory where you have uncompressed the ZIP file &gt; &#8220;usb_driver&#8221; &gt; &#8220;x86&#8243;, like image bellow.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-400" title="img4" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img4.png" alt="" width="325" height="318" /></p>
<p style="text-align: justify;">Click in &#8220;OK&#8221;, &#8220;Next&#8221; and follow next steps until complete the installation.</p>
<h2>Finding your smartphone</h2>
<p style="text-align: justify;">Make sure your Android is connected to computer. Open the directory &#8220;proxoid-adb&#8221; and run &#8220;check.bat&#8221;. A screen with number of your device, like this below, should be displayed.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-401" title="img5" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img5.png" alt="" width="500" height="206" /></p>
<p style="text-align: justify;">If don&#8217;t, try to desconnect and connect your smartphone again or try to reinstall the drivers.</p>
<h2>Configuring ProxoId</h2>
<p style="text-align: justify;">Configuration screen is opened when ProxoId runs:</p>
<p style="text-align: justify;">&#8220;Start/Stop ProxoId&#8221; &#8211; Control service to share the connection;<br />
&#8220;Port&#8221; &#8211; Port number to proxy<br />
&#8220;User-Agent Filter&#8221; &#8211; Mask to User-Agent (Browser).</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-402" title="proxoid" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img6.png" alt="" width="235" height="350" /></p>
<h2>Configuring Browser</h2>
<h4>Internet Explorer and Google Chrome</h4>
<p>Open &#8220;Start&#8221; menu &gt; &#8220;Control Panel&#8221; and &#8220;Internet Options&#8221;. Click in tab &#8220;Connections&#8221; and in &#8220;LAN Settings&#8221;.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-403" title="img7" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img7.png" alt="" width="363" height="450" /></p>
<p style="text-align: justify;">In &#8220;Address&#8221;, type &#8220;localhost&#8221; and, in &#8220;Port&#8221;,  type same value marked in application.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-406" title="img10" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img10.png" alt="" width="384" height="338" /></p>
<h4>FireFox</h4>
<p style="text-align: justify;">Open Firefox, clique in menu &#8220;Options&#8221;. Choose tab &#8220;Advanced&#8221; &gt; &#8220;Network&#8221; and click in button &#8220;Settings&#8230;&#8221;.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-404" title="img8" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img8.png" alt="" width="450" height="416" /></p>
<p style="text-align: justify;">Enable &#8220;Manual proxy configuration&#8221; option.</p>
<p style="text-align: justify;">In &#8220;HTTP&#8221;, type &#8220;localhost&#8221; and, in &#8220;Port&#8221;, type same value marked in application.</p>
<p style="text-align: center;"><img class="aligncenter" title="img9" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/10/img9.png" alt="" width="376" height="400" /></p>
<h2>Sharring the connection</h2>
<p style="text-align: justify;">Enable &#8220;Start/Stop ProxoId&#8221; in your Android.</p>
<p style="text-align: justify;">At computer, run &#8220;start-tunnel.bat&#8221; in &#8220;proxoid-adb&#8221; directory.</p>
<p style="text-align: justify;">That&#8217;s it! While application is enabled and  &#8221;start-tunnel.bat&#8221; is running, your computer will use your Android to connect at internet!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/10/sharing-3g-connection-from-android-to-pcs-and-laptop-through-usb-cable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android 2.2 &#8211; How to install apps directly in SD card</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/09/android-2-2-how-to-install-apps-directly-in-sd-card/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/09/android-2-2-how-to-install-apps-directly-in-sd-card/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 21:51:17 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=194</guid>
		<description><![CDATA[ome Android smartphones have low capacity internal memory and not allow you to install many apps. At Android 2.2 there<a href="http://www.andrels.com/wp-en_US/index.php/2011/09/android-2-2-how-to-install-apps-directly-in-sd-card/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/09/android_full.png" class="alignleft" width="233" height="265" />ome Android smartphones have low capacity internal memory and not allow you to install many apps.</p>
<p>At Android 2.2 there is a possibility migrate the apps to SD card after instalation, but some applications not allow to do this.</p>
<p>Looking for a fix to solve this problem in my Motorola Droid, I found a way to install apps directly in SD card, like show in <a href="http://www.mundozoom.com.br/android-instalar-aplicativos-no-cartao-sd.html" target="_blank">Mundo Zoom</a>, and not need <i>root</i>.</p>
<p>Download ZIP file from <a href="http://developer.android.com/sdk/index.html" target="_blank">Android SDK</a> and extract. Browse to folder &#8220;<b>android-sdk-windows\platform-tools</b>&#8220;.</p>
<p>Set your Android to debug mode. Don&#8217;t you know? <b>&#8220;Settings&#8221; &gt; &#8220;Applications&#8221; &gt; &#8220;Development&#8221;</b> and enable &#8220;USB debugging&#8221; option.</p>
<p>Connect your smartphone in USB and enable &#8220;Charge Only&#8221; on USB Connection Management.</p>
<p>Click in Start Menu, Run. Type &#8220;cmd&#8221; e press Enter to open command prompt.</p>
<p>With command prompt and Windows Explorer opened, click and drag file &#8220;adb.exe&#8221; to prompt window, after, insert a space and type &#8220;shell&#8221;. Press Enter.</p>
<p><img alt="" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2011/09/ss1.jpg" class="aligncenter" width="540" height="386" /></p>
<p>The &#8220;$&#8221; simbol and cursor should appear. Now type &#8220;<b>pm setInstallLocation 2</b>&#8221; and press Enter</p>
<p>This command sets partition &#8220;2&#8243; (SD Card) as default to install applications.</p>
<p>Done! That`s all you need for apps to be installed directly in your SD card</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/09/android-2-2-how-to-install-apps-directly-in-sd-card/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why to use File.separator and File.pathSeparator</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 16:17:49 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[programing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=190</guid>
		<description><![CDATA[Java programmers knows about methods quoted in title, but many doesn&#8217;t care with them. These methods are useful for programmer<a href="http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Java programmers knows about methods quoted in title, but many doesn&#8217;t care with them.</p>
<p>These methods are useful for programmer that do not knows wich characters represents file separator and path separator at OS that supports your application.</p>
<p>Linux/Unix, the methods <b><a href="http://download.oracle.com/javase/1,5.0/docs/api/java/io/File.html#separator">File.separator</a></b> and <b><a href="http://download.oracle.com/javase/1,5.0/docs/api/java/io/File.html#pathSeparator">File.pathSeparator</a></b> returns &#8220;/&#8221; and &#8220;.&#8221;, while in Windows, these methods returns &#8220;\&#8221; (or &#8220;\\&#8221; &#8211; escape) and &#8220;;&#8221;.</p>
<p>In recent case, the code below threw exception FileNotFoundException running over Linux, but not running over Windows:</p>
<pre class="brush:java">
String appPath = ctx.getRealPath();
String filePath = appPath + "\\" + "WEB-INF/classes/my/application/packages/";

File file = new File(filePath, "report.pdf");
OutputStream out = new FileOutputStream(file);
...
</pre>
<p>Worked in both systems after to replace &#8220;\\&#8221; by File.separator in line 2:</p>
<pre class="brush:java">
String appPath = ctx.getRealPath();
String filePath = appPath + File.separator + "WEB-INF/classes/my/application/packages/";

File file = new File(filePath, "report.pdf");
OutputStream out = new FileOutputStream(file);
...
</pre>
<p>Utilization of these methods, besides a good practice, is very usefull when same version of an application is running over differents operacional systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apps can&#8217;t miss in your Android – RemoteControl for Earphones</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/08/apps-cant-miss-in-your-android-remotecontrol-for-earphones/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/08/apps-cant-miss-in-your-android-remotecontrol-for-earphones/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 17:05:18 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[marketing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=183</guid>
		<description><![CDATA[I&#8217;m starting a new section called &#8220;Apps can&#8217;t miss in your Android&#8220;. This section will have reviews and tips for<a href="http://www.andrels.com/wp-en_US/index.php/2011/08/apps-cant-miss-in-your-android-remotecontrol-for-earphones/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting a new section called &#8220;<b>Apps can&#8217;t miss in your Android</b>&#8220;. This section will have reviews and tips for useful applications, that will help to extract all potentical from your Android.</p>
<p>I&#8217;ll start with <strong>RemoteControl for Earphones</strong>. It just cancel a vantage of iPhone over Android: to control media players using the earphones&#8217;s button.</p>
<p>The button&#8217;s behavior is to pause and start music. <strong>RemoteControl for Earphones</strong> allow you runs almost all commands of a media player. To play or pause, press button once, to skip forward, press button twice, to skip rewind, press four times&#8230;</p>
<div class="wp-caption aligncenter" style="width: 212px"><a href="https://www.gstatic.com/android/market/jp.co.chobirich.tools.mediabutton/ss-480-1-6"><img src="https://www.gstatic.com/android/market/jp.co.chobirich.tools.mediabutton/ss-480-1-6" alt="RemoteControl for Earphones" width="202" height="336" /></a><p class="wp-caption-text">App screen (Android Market)</p></div>
<p>This application is for free and don&#8217;t have advertisement.</p>
<p>Most players are incompatible, but it work very well in Morotola Droid&#8217;s player, <a href="https://market.android.com/details?id=com.songbirdnest.mediaplayer&#038;feature=search_result" target="_blank">Songbird</a>, but not work in Winamp and players of Samsung Galaxy S and Motorola Atrix.</p>
<p><strong>Link</strong>:  <a href="https://market.android.com/details?id=jp.co.chobirich.tools.mediabutton&amp;feature=search_result" target="_blank">RemoteControl for Earphones</a><br />
<strong>Price</strong>: Free<br />
<strong>Advertisement</strong>: No</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/08/apps-cant-miss-in-your-android-remotecontrol-for-earphones/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to read and write CLOB fields</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/05/how-to-read-and-write-clob-fields/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/05/how-to-read-and-write-clob-fields/#comments</comments>
		<pubDate>Fri, 20 May 2011 16:39:34 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[clob]]></category>
		<category><![CDATA[data base]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=167</guid>
		<description><![CDATA[The Character Large Object (or CLOB) is a commonly found in databases and used to store high quantity of characters.<a href="http://www.andrels.com/wp-en_US/index.php/2011/05/how-to-read-and-write-clob-fields/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>The Character Large Object (or CLOB) is a commonly found in databases and used to store high quantity of characters.</p>
<p>At MySQL, for example, this field is called MEMO.</p>
<h4>Writing CLOB field</h4>
<p>The method <em>setAsciiStream</em> of <em>PreparedStatement</em> allow to pass data to a CLOB.</p>
<pre class="brush:sql">ps.setAsciiStream(bindPosition, inputStream, textLength);</pre>
<p><strong>bindPosition</strong> &#8211; Position in PreparedStatment&#8217;s CLOB field.<br />
<strong>inputStream</strong> &#8211; Used to pass data.<br />
<strong>textLength</strong> &#8211; Data (text) length.</p>
<p><strong>Full code:</strong></p>
<pre class="brush:java">String sql = "INSERT INTO TABLE (text) VALUES(?)";
		try{
			String txt = readTxtFile();
			ByteArrayInputStream bais = new ByteArrayInputStream(txt.getBytes());

			PreparedStatement ps = conexao.prepareStatement(sql);
			//CLOB is '?' at first position
			ps.setAsciiStream(1, bais, txt.length());

			ps.execute();

			ps.close();
		}catch (Exception e) {
			e.printStackTrace();
		}</pre>
<h4>Retrieving CLOB data</h4>
<p>We&#8217;re using SELECT clause, this clause returns a ResultSet to fetch data and, calling getClob method, passing column name or your position in the query, it give to you a Clob object.</p>
<pre class="brush:sql">rs.getClob("xml");</pre>
<p><strong>Full code:</strong></p>
<pre class="brush:java">String sql = "SELECT xml FROM TEST";
		try{
			PreparedStatement ps = conexao.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();

			while(rs.next()){
				Clob clob = rs.getClob("xml");
				BufferedReader reader = new BufferedReader(clob.getCharacterStream());
				StringBuffer strBuf = new StringBuffer();

				String linha = null;
				while((linha = reader.readLine()) != null){
					strBuf.append(linha);
//Character.LINE_SEPARATOR insert break line
					strBuf.append((char)Character.LINE_SEPARATOR);
				}

				System.out.println("=========== CLOB ===========");
				System.out.println(strBuf.toString());
			}

			rs.close();
			ps.close();
		}catch (Exception e) {
			e.printStackTrace();
		}</pre>
<p>That&#8217;s it! Easy and painless <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Download full code <a href="http://www.andrels.com/wp-pt_BR/wp-content/plugins/download-monitor/download.php?id=6">here</a></p>
<p>To write a BLOB see this <a href="http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/05/how-to-read-and-write-clob-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing .apk packages at Android SDK emulator</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 23:40:10 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[apk]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=162</guid>
		<description><![CDATA[Sometimes our applications depends of third-part applications for tests or to access resources of emulator that aren&#8217;t available by default.<a href="http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Sometimes our applications depends of third-part applications for tests or to access resources of emulator that aren&#8217;t available by default.</p>
<p>In directories of SDK, commonly in<em> platform-tools</em>, there is an executable called <strong>adb</strong>, with it we&#8217;ll to install third-part applications.</p>
<p>You will need an application (.apk). Browse internet or copy from your Android smartphone using applications like <a href="https://market.android.com/details?id=com.IQBS.android.appSaver&amp;feature=search_result">AppSaver</a>.</p>
<p>- Run the emulator, you can use SDK Manager or Eclipse plugins.</p>
<p>- Using DOS Command (Windows) or terminal (Linux), open directory <em>platform-tools</em> and run commando line below:</p>
<pre class="brush: bash">$ adb install &lt;.apk path&gt;</pre>
<p>This message will be displayed</p>
<pre class="brush: bash">$ adb install Application.apk
125 KB/s (1091937 bytes in 8.474s)
        pkg: /data/local/tmp/Application.apk
Success</pre>
<p>Now, the third-part application is available at emulator menu, like have installed in your smartphone.</p>
<p>Agora o aplicativo estará disponível no menu do emulador. <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up internet access through proxy server</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 01:54:22 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=116</guid>
		<description><![CDATA[Today I had a trouble in my workplace when a client application, running through a terminal (DOS prompt), not reach<a href="http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Today I had a trouble in my workplace when a client application, running through a terminal (DOS prompt), not reach the server hosted in the internet, this is because the company where I work use proxy.</p>
<p>After some tries I found two solutions to solve my access problem: first was pass as <em>Java</em> parameters the proxy&#8217;s configurations.</p>
<pre class="brush:shell">$ java -Dhttp.proxyHost=serv -Dhttp.proxyPort=port -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass  ClassJava
</pre>
<p><strong>-Dhttp.proxyHost</strong> = IP or host name of server proxy<br />
<strong>-Dhttp.proxyPort</strong> = Proxy port<br />
<strong>-Dhttp.proxyUser</strong> = User<br />
<strong>-Dhttp.proxyPassword</strong> = Password</p>
<p>This way the class <em>ClassJava</em> will have access to internet through proxy server.</p>
<p>Another way, was insert the settings in own class:</p>
<pre class="brush:java">public static void main(String[] args){
...
System.getProperties().put("proxySet", "true");
System.getProperties().put("http.proxyHost", "serv");
System.getProperties().put("http.proxyPort", "port");
System.getProperties().put("http.proxyUser", "user");
System.getProperties().put("http.proxyPassword", "password");
...
}
</pre>
<p><strong>proxySet</strong> = Connect, or not, through proxy server<br />
<strong>http.proxyHost</strong> = IP or host name of server proxy<br />
<strong>http.proxyPortt</strong> = Proxy port<br />
<strong>http.proxyUse</strong> = User<br />
<strong>http.proxyPassword</strong> = Password</p>
<p>Using this resource you can set your application to access the internet through proxy server.</p>
<p>I hope help you.  Bye! <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating transparent and shaped windows using Java Swing/AWT</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/03/creating-transparent-and-shaped-windows-using-java-swingawt/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/03/creating-transparent-and-shaped-windows-using-java-swingawt/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 02:28:58 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[awt]]></category>
		<category><![CDATA[jframe]]></category>
		<category><![CDATA[swing]]></category>
		<category><![CDATA[transparency]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=107</guid>
		<description><![CDATA[The Java AWT offer various possibilities about window manipulation. Today I&#8217;ll talk about two possibilities using class AWTUtilities. Building a<a href="http://www.andrels.com/wp-en_US/index.php/2010/03/creating-transparent-and-shaped-windows-using-java-swingawt/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>The Java AWT offer various possibilities about window manipulation. Today I&#8217;ll talk about two possibilities using class AWTUtilities.</p>
<h3><strong>Building a transparent window</strong></h3>
<p>To make a <strong>Window</strong> (JFrame, JDialog &#8230;) with alpha effect, you should invoke the method <strong>AWTUtilities.setWindowOpacity</strong>. This method parameters are: the window to apply transparency and transparency degree, that can be between 0 (zero) and 1, being 0 invisible and 1 totally visible.</p>
<pre class="brush:java">JFrame  window = new JFrame("My Window");

//70% of transparency
AWTUtilities.setWindowOpacity(window, .7f);
window.setSize(800,600);
window.setVisible(true);
</pre>
<p>The result will be:<a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2010/03/2.jpg"><img class="aligncenter size-full wp-image-174" title="2" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2010/03/2.jpg" alt="" width="480" height="368" /></a></p>
<h3><strong>Changing window shape</strong></h3>
<p>To change the window shape you should use the method <strong>AWTUtilities.setWindowShape</strong>. This method parameters are: window that will be changed and the new shape (java.awt.Shape) of the window.</p>
<p>The most efficiently form to use is to implement the method <em>componentResized()</em>, cause you may recompute the window and components size</p>
<p>Here I&#8217;ll use a triangle with 70% of transparency.</p>
<pre class="brush:java">final JFrame  window = new JFrame("My Window");

try {
	//Add the ComponentListener to implement componentResized method
	window.addComponentListener(new ComponentAdapter(){
		@Override
		//building componentResized
		public void componentResized(ComponentEvent e) {
			int[] x = {0,400,800}; //Pontos X do polígono
			int[] y = {600,0,600}; //Pontos Y do polígono

			//Triangle with 800 w x 600 h
			Shape shape = new Polygon(x, y, 3);

			AWTUtilities.setWindowShape(window, shape);

			//70% of transparency
			AWTUtilities.setWindowOpacity(window, 0.7f);
		}
	});
} catch (SecurityException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
} catch (IllegalArgumentException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}

window.setUndecorated(true); //removing title bar
window.setSize(800,600);
window.setVisible(true);
</pre>
<p>Notice that the method <strong><em>setUndecorated( )</em></strong> was invoked with <em>true</em> as value. This method are responsible by hide the title bar (one with icon and the maximize, minimize and close buttons).  This is really necessary, because with title bar visible the window are not be shaped.</p>
<p>The result:<a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2010/03/1.jpg"><img class="aligncenter size-full wp-image-175" title="1" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2010/03/1.jpg" alt="" width="480" height="365" /></a></p>
<p>I hope you enjoy&#8230; <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/03/creating-transparent-and-shaped-windows-using-java-swingawt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Saving files in BLOB table column of a data base</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 00:46:06 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=102</guid>
		<description><![CDATA[To insert a file, is it in any format, you need call the method setBinaryStream, implemented by PreparedStatement. PreparedStatemente.setBinaryStream(int index,<a href="http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>To insert a file, is it in any format, you need call the method <i>setBinaryStream</i>, implemented by PreparedStatement.</p>
<pre class="brush:java">
PreparedStatemente.setBinaryStream(int index, Inputstream is, int length);
</pre>
<p>In sample, we set a table called <i>FILE</i>that contains <b>BLOB</b> column called <i>BIN</i>.</p>
<pre class="brush:java">
//Normal connection, as any JDBC connection
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@&lt;IP&gt;:&lt;PORT&gt;:&lt;SID&gt;","&lt;USER&gt;","&lt;PASSWORD&gt;");

//Reading the file and retrieving an InputStream
File file= new File("&lt;COMPLETE_FILE_PATH&gt;");
FileInputStream fis = new FileInputStream(file);

//Preparing statement
PreparedStatement ps = conn.prepareStatement("INSERT INTO FILE(bin) VALUES(?)");

//Passing InputStream and file length
ps.setBinaryStream(1, fis, (int)file.length());

ps.execute();

ps.close();
conn.close();
</pre>
<p>I used Oracle 8i to execute this sample. I haven&#8217;t a MySQL/PostgreSQL/MS SQL Server in my dispose, then you&#8217;ll responsible for testing in this data bases and send me the results, OK <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks! Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Retrieving an Oracle cursor in Java</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/01/retieving-an-oracle-cursor-in-java/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/01/retieving-an-oracle-cursor-in-java/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:22:32 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=99</guid>
		<description><![CDATA[Many people come here looking for one way to retrieve cursors of Oracle procedures in Java. To them, I&#8217;ve here<a href="http://www.andrels.com/wp-en_US/index.php/2010/01/retieving-an-oracle-cursor-in-java/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Many people come here looking for one way to retrieve cursors of Oracle <i>procedures</i> in Java. To them, I&#8217;ve here are a tutorial showing how to do this.</p>
<p>To retrieve the cursor you should declare him how a <i>REF CURSOR</i> in <i>Package spec</i>.</p>
<pre class="brush:sql">  --Creating the REF CURSOR type
  type g_cursor is ref cursor;
</pre>
<p>In both, <i>spec</i> and <i>body</i>, you need declare an <i>out REF CURSOR</i> variable in procedure signature, how cited above.</p>
<pre class="brush:sql">  procedure PRO_RETURN_CARS(
    i_id     in     tbl_car.car_id%type,
    o_cursor in out g_cursor);
</pre>
<p>The cursor must be opened in <i>procedure&#8217;s body</i> to return, this way:</p>
<pre class="brush:sql">
open o_cursor for
          select car_id, company, model, color, hp, price
          from tbl_car
          where car_id = i_id;
</pre>
<p>The complete <i>Package</i>:</p>
<pre class="brush:sql">create or replace package PAC_CURSOR is
  --Creating REF CURSOR type
  type g_cursor is ref cursor;

  --Procedure that return the cursor
  procedure PRO_RETURN_CARS(
    i_id     in     tbl_car.car_id%type,
    o_cursor in out g_cursor); -- Our cursor

end PAC_CURSOR;
/

create or replace package body PAC_CURSOR is
  procedure PRO_RETURN_CARS(
    i_id     in     tbl_car.car_id%type,
    o_cursor in out g_cursor) is

       begin
        --Opening the cursor to return matched rows
        open o_cursor for
          select car_id, company, model, color, hp, price
          from tbl_car
          where car_id = i_id;

  end PRO_RETURN_CARS;

end PAC_CURSOR;
</pre>
<p>We have Oracle side ready, now we need create Java call</p>
<p>How the cursors are being returned by a <i>procedure</i>, we&#8217;ll used a <i>java.sql.CallableStatement</i> instance.</p>
<pre class="brush:java">
CallableStatement cs = conn.prepareCall("{call PAC_CURSOR.PRO_RETURN_CARS(?,?)}");
</pre>
<p>The <i>registerOutParameter</i> will obtain <i>oracle.jdbc.OracleTypes.CURSOR</i> type and return a <i>java.sql.ResultSet</i> instance. We can iterate the <i>ResultSet</i> like a common <i>Iterator</i>.<br />
Each row column returned by <i>SELECT</i> will be represented how a map, using correspondent getter. For example, we will call <i>getString(&lt;column name&gt;)</i> method when value of column is a <i>varchar</i>, <i>getDate(&lt;column name&gt;)</i> when is a date and etc.</p>
<p>The complete code will be like this:</p>
<pre class="brush:java">
//Calling Oracle procedure
CallableStatement cs = conn.prepareCall("{call PAC_CURSOR.PRO_RETURN_CARS(?,?)}");

//Defining type of return
cs.registerOutParameter("o_cursor", OracleTypes.CURSOR);
cs.setLong("i_id", id);

cs.execute();//Running the call

//Retrieving the cursor as ResultSet
ResultSet rs = (ResultSet)cs.getObject("o_cursor");

//Iterating the returned rows
while(rs.next()){
	//Getting column values
	System.out.println("ID: " + rs.getLong("car_id"));
	System.out.println("Manufacturer: " + rs.getString("company"));
	System.out.println("Model: " + rs.getString("model"));
	System.out.println("Color: " + rs.getString("color"));
	System.out.println("HP: " + rs.getString("hp"));
	System.out.println("Price: " + rs.getFloat("price"));
}
</pre>
<p>In the end you will get any value returned in a <i>SELECT</i> clause.</p>
<p>See ya!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/01/retieving-an-oracle-cursor-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating &#8216;EXE&#8217; to start your Java applications</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/10/generating-exe-to-start-your-java-applications/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/10/generating-exe-to-start-your-java-applications/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 23:52:08 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[exe]]></category>
		<category><![CDATA[jsmooth]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=89</guid>
		<description><![CDATA[Many developers need, or have needed, distribute their Java applications so that Windows users could start them naturally, not running<a href="http://www.andrels.com/wp-en_US/index.php/2009/10/generating-exe-to-start-your-java-applications/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Many developers need, or have needed, distribute their Java applications so that Windows users could start them naturally, not running <em>java -jar &lt;jar file&gt;</em> command or batch (.BAT) file.</p>
<p>I&#8217;ve been there too, then I found a easy and with many resources solution: <a href="http://jsmooth.sourceforge.net/" target="_blank">JSmooth</a></p>
<p>This software allow you &#8220;transform&#8221; your JAR file in an executable (EXE), but, of course, will need the JVM already installed and running.</p>
<p>Here I only have mentioned the settings that I consider important, then let&#8217;s go!</p>
<hr />Download JSmooth in <a href="http://sourceforge.net/projects/jsmooth/files/" target="_blank">http://sourceforge.net/projects/jsmooth/files/</a>;</p>
<p>After install (or unzip, this depends of file that you have downloaded) run him;</p>
<p>In the side menu, click in &#8220;Skeleton&#8221;;</p>
<p style="text-align: center;"><a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/1.jpg"><img class="size-full wp-image-119 aligncenter" title="1" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/1.jpg" alt="1" width="524" height="364" /></a></p>
<p>In the &#8220;Skeleton Selection&#8221; screen you need define how application will be run, select &#8220;Window Wrapper&#8221;.</p>
<p>In &#8220;Skeleton Properties&#8221;, you need define a message when user have no JVM installed (&#8220;Message&#8221; field) and where can be downloaded (&#8220;URL&#8221; field).</p>
<p>The &#8220;Launch java app in the exe process&#8221; field define if JAR file will be executed in same process of EXE (only the executable process will be displayed in Windows Task Manager), otherwise the <em>javaw.exe</em> will be displayed too.</p>
<p>The &#8220;Single Instance&#8221; field define if more than one instance can be opened.</p>
<p>&#8220;Debug Console&#8221; open the EXE from prompt window, displaying possibles outputs.</p>
<p>Now click in &#8220;Executable&#8221;</p>
<p style="text-align: center;"><a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/2.jpg"><img class="aligncenter size-full wp-image-120" title="2" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/2.jpg" alt="2" width="524" height="364" /></a></p>
<p>In &#8220;Executable Setting&#8221; you inform where EXE will be builded (&#8220;Executable Binary&#8221; field), the EXE&#8217;s icon (&#8220;Executable Icon&#8221; filed) and what will be the application execution directory.</p>
<p>Click in &#8220;Application&#8221;</p>
<p style="text-align: center;"><a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/3.jpg"><img class="aligncenter size-full wp-image-121" title="3" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/3.jpg" alt="3" width="524" height="364" /></a></p>
<p>First, click in the icon <img class="size-full wp-image-125 alignnone" title="7" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/7.jpg" alt="7" width="50" height="27" /> and select JAR that contains the main class.</p>
<p>After, select the main class in the field &#8220;Main Class&#8221; clicking in button <img class="alignnone size-full wp-image-126" title="8" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/8.jpg" alt="8" width="39" height="20" />.</p>
<p>In the field &#8220;Application arguments&#8221; you can inform necessaries parameters for your main class.</p>
<p>&#8220;Embedded JAR&#8221; field allows you to aggregate your JAR file in EXE file, in other words, only EXE file will be necessarie, because the JAR will be uncompressed by EXE in each execution.</p>
<p>Now click in &#8220;JVM Selection&#8221;.</p>
<p style="text-align: center;"><a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/4.jpg"><img class="aligncenter size-full wp-image-122" title="4" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/4.jpg" alt="4" width="524" height="364" /></a></p>
<p>Here you can define the minimum and maximum version of JVM that your application support.</p>
<p>The &#8220;JVM Serach Sequence&#8221; inform the seek order of <em>javaw.exe</em> file, in this case, he search in resgistry first, after in JAVA_HOME enviroment and so.</p>
<p>Click in &#8220;JVM Configuration&#8221;.</p>
<p style="text-align: center;"><a href="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/5.jpg"><img class="aligncenter size-full wp-image-123" title="5" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/5.jpg" alt="5" width="524" height="364" /></a></p>
<p>Here the maximum and minimum memory available for your application can be configured, as the options that can passed to JVM.</p>
<p>Until here we only have configured the JSmooth. To build the EXE file click in button <img class="size-full wp-image-124 alignnone" title="6" src="http://www.andrels.com/wp-pt_BR/wp-content/uploads/2009/10/6.jpg" alt="6" width="32" height="30" />. If you don&#8217;t have saved the project, a new window will open to choose the place to save. Done it, the EXE file will be create in directory mentioned in &#8220;Executable Binary&#8221; field of &#8220;Executable&#8221; screen.</p>
<p>Now just execute the EXE file and your application will be run!</p>
<p style="text-align: left;">
<p>To more information visit <a href="http://jsmooth.sourceforge.net/" target="_blank">http://jsmooth.sourceforge.net/</a></p>
<p style="text-align: left;">
<p style="text-align: left;">I hope you enjoyed, feel free to comment!</p>
<p style="text-align: left;">Until next! <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/10/generating-exe-to-start-your-java-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrieving objects collection from Oracle procedure</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/09/retrieving-objects-collection-from-oracle-procedure/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/09/retrieving-objects-collection-from-oracle-procedure/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 22:25:07 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=79</guid>
		<description><![CDATA[As I&#8217;ve promised in post &#8220;Learn to pass a Java Object as Oracle Procedure parameter&#8220;, I&#8217;ll show how retrieve object<a href="http://www.andrels.com/wp-en_US/index.php/2009/09/retrieving-objects-collection-from-oracle-procedure/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve promised in post &#8220;<a href="http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Learn to pass a Java Object as Oracle Procedure parameter</a>&#8220;, I&#8217;ll show how retrieve object that have a collection of objects as attribute through of an <a href="http://www.oracle.com/">Oracle</a> procedure. Is highly recommended to read <a href="http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">previous post</a>.</p>
<p>For this tutorial, we&#8217;ll need create the table TBL_CLASS and add your primary key as foreign key in TBL_USER table.</p>
<pre class="brush:sql">--num class is PK and desc_class description
create table TBL_CLASS (num_class number, desc_class varchar(100));
alter table TBL_CLASS add primary key(num_class);

alter table TBL_USER add num_class number;
alter table TBL_USER add constraint FK_CLASS foreign key(num_class) references tbl_class(num_class);</pre>
<p>Now we need to include the new types:</p>
<pre class="brush:sql">create or replace type class_type as object (num_class number, desc_class varchar2(100), users arr_users);
/
create or replace type arr_class as table of class_type;
/</pre>
<p>The <em>class_type</em> type will be the Java Object. Notice that in your signature was included the <em>arr_users</em> type, that will be our collection of <em>user_type</em> (read <a href="http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">previous post</a> for more information), the <em>arr_class</em> type will be the <em>class_type</em> collection.</p>
<p>Now we&#8217;ll include the procedure that returns our  <em>class_type</em> collection.</p>
<pre class="brush:sql">procedure pro_select_class(clas in class_type, class_return in out arr_class)is
  class_ref_cur ref_cur;
  --class_type array
  classes arr_class := arr_class();

  begin
    open class_ref_cur for
      select cast(
                multiset(
                  select num_class,
                         desc_class,
                         (select cast(
                                  multiset(
                                    select user_name,
                                           height,
                                           b_date
                                    from tbl_user
                                    --JOIN with TBL_USER
                                    where tbl_user.num_class = tbl_class.num_class
                                  ) as arr_users)
                          from dual) users
                  from tbl_class
                  --Using num_class attribute of in parameter
                  where num_class = clas.num_class) as arr_class
      ) classes
    from dual;

    --including the return in array
    fetch class_ref_cur into classes;
    --transferring arrar to variable out
    class_return := classes;
end pro_select_class;</pre>
<p>Notice that procedure receive <em>class_type</em> as parameter in and returns <em>arr_class</em> type.</p>
<p>Separating code charge back and set up our objects, we have:</p>
<pre class="brush:sql">
--Mount return
select cast(
        multiset(

          --Will returns the objects class_type and your attributes
          select num_class,
                 desc_class,

                 --Populate user_type collection
                 (select cast(
                          multiset(
                            select user_name,
                                   height,
                                   b_date
                            from tbl_user
                            where tbl_user.num_class = tbl_class.num_class
                          ) as arr_users)

                  from dual) users

          from tbl_class
          where num_class = clas.num_class) as arr_class
) classes
from dual;
</pre>
<p>Oracle objects done, now the Java code!</p>
<p>We&#8217;ll create the object that will be interpreted by the Oracle. Called TypeClass:</p>
<pre class="brush:java">
public class TypeClass implements SQLData{
	public static final String ORACLE_OBJECT_NAME = "CLASS_TYPE"; //Type name in Oracle
	public static final String ORACLE_CLASS_ARRAY_NAME = "ARR_CLASS"; //Array name in Oracle

        //Attibutes of TBL_CLASS table
	private Long number;
	private String desc;
	private Array users; //This will be user_type collection (or TypeUser in Java)

	public String getSQLTypeName() throws SQLException {
		return ORACLE_OBJECT_NAME;
	}

	public void readSQL(SQLInput stream, String typeName) throws SQLException {
		setNumber(stream.readLong());
		setDesc(stream.readString());
		setUsers(stream.readArray());//Used by JDBC driver to read the collection
	}

	public void writeSQL(SQLOutput stream) throws SQLException {
		stream.writeLong(getNumber());
		stream.writeString(getDesc());
		stream.writeArray(getUsers());//Used by JDBC driver to write the collection
	}
	//Getters and setters omitted
}
</pre>
<p>We need to map types interpreted in request, this way:</p>
<pre class="brush:java">
Map<String, Class<?>> typeMaps = connection.getTypeMap();
typeMaps.put(TypeUser.ORACLE_OBJECT_NAME, TypeUser.class);
typeMaps.put(TypeClass.ORACLE_OBJECT_NAME, TypeClass.class);
</pre>
<p>We need to map the <em>arrays</em> too:</p>
<pre class="brush:java">
typeMaps.put(TypeClass.ORACLE_CLASS_ARRAY_NAME, TypeClass[].class);//returned by procedure
typeMaps.put(TypeUser.ORACLE_USER_ARRAY_NAME, TypeUser[].class);//returned by class_type collection
</pre>
<p>For request, we do:</p>
<pre class="brush:java">
cs = conn.prepareCall("{call PAC_BEAN.PRO_SELECT_CLASS(?,?)}");
//registering out type, that will be a TypeClass array
cs.registerOutParameter("class_return", OracleTypes.ARRAY, TypeClass.ORACLE_CLASS_ARRAY_NAME);

//passing parameter object
cs.setObject("clas", classQry);

cs.execute();
//retrieving and looping the TypeClass array
Object[] array = (Object[])cs.getArray("class_return").getArray();

for(Object obj : array){
	TypeClass objClass = ((TypeClass)obj);

	System.out.println("Description: "+objClass.getDesc());

        //Here we obtains user_type(TypeUser) array returned by query.
	Object[] userArray = (Object[])objClass.getUsers().getArray();
	for(Object user : userArray){
		System.out.println("\tName: " + ((TypeUser)user).getName());
		System.out.println("\tHeight: " + ((TypeUser)user).getHeight());
		System.out.println("\tBirth: " + sdf.format(((TypeUser)user).getBirth())+ "\r\n");
	}
}
</pre>
<p>In the end you&#8217;ll have a <a href="http://www.j2ee.me/j2se/1.4.2/docs/api/java/sql/class-use/Array.html" target="_blank">java.sql.Array</a> of TypeUser in getUsers() attribute of TypeClass.</p>
<p>Here I fulfilled my promise. Download the source code of this sample (with previous post sample too) <a href="http://www.andrels.com/wp-en_US/wp-content/plugins/download-monitor/download.php?id=3" title="Downloaded 216 times">here</a>.</p>
<p>Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/09/retrieving-objects-collection-from-oracle-procedure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Taking Screen Shots with Java</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/09/taking-screen-shots-with-java/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/09/taking-screen-shots-with-java/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 14:38:40 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[awt]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=75</guid>
		<description><![CDATA[Here I&#8217;ll show how to implements a class to take Screen shots. I thinking about the complexity of a class<a href="http://www.andrels.com/wp-en_US/index.php/2009/09/taking-screen-shots-with-java/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Here I&#8217;ll show how to implements a class to take Screen shots.</p>
<p>I thinking about the complexity of a class that takes screen shots and store the files in hard disk and, asking to &#8220;uncle G&#8221;, I fonded the class <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html" target="_blank">Robot</a>, that provide <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html#createScreenCapture(java.awt.Rectangle)" target="_blank">createScreenCapture</a> method.</p>
<p>Now I&#8217;ll show how to implement this functionality:</p>
<pre class="brush:java">Robot robot = new Robot();
//Setting the rectangle that mark capture area. In this case, will be all screen..
Rectangle rect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());

BufferedImage img = robot.createScreenCapture(rect);</pre>
<p>Here we defined capture area and obtained a <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/BufferedImage.html" target="_blank">BufferedImage</a>, our image. Now, we needed to persist in hard disk.</p>
<pre class="brush:java">//Capturing the ImageWriter and ImageWriterParam
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next();
ImageWriteParam iwp = writer.getDefaultWriteParam();

//Setting compression mode and the image quality
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(1);

//Persisting the image
writer.setOutput(new FileImageOutputStream(arquivo));

IIOImage iioimage = new IIOImage(img, null, null);

writer.write(null, iioimage, iwp);
writer.dispose();</pre>
<p>We captured the <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/ImageWriter.html" target="_blank">ImageWriter</a> and <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/ImageWriteParam.html" target="_blank">ImageWriterParam</a> to set the compression method and the image quality.</p>
<p>In line <strong>07</strong> we defined the image quality as 1, where the value can be between 0 (zero), more compression and less quality and 1 (one), less compression and more quality. Then we have kept the file in HD.</p>
<p>We&#8217;ve done! Simple, isn&#8217;t?</p>
<p>Download this sample <a href="http://www.andrels.com/wp-en_US/wp-content/plugins/download-monitor/download.php?id=2" title="Downloaded 138 times">here</a>.</p>
<p>See ya!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/09/taking-screen-shots-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting maximum number of characters in JTextField</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 16:07:48 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[jtextfield]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=73</guid>
		<description><![CDATA[The default implementation of JTextField not allow set maximum number of characters. To enable this resource you need implements a<a href="http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>The default implementation of <i>JTextField</i> not allow set maximum number of characters. To enable this resource you need implements a <i>Document</i>, overriding <i>insertString</i> method.</p>
<pre class="brush:java">
public class MaxLengthTextDocument extends PlainDocument {
	//Store maximum characters permitted
	private int maxChars;

	@Override
	public void insertString(int offs, String str, AttributeSet a)
			throws BadLocationException {
		if(str != null &#038;&#038; (getLength() + str.length() < maxChars)){
			super.insertString(offs, str, a);
		}
	}

	//getter e setter omitted
}
</pre>
<p>Here we defined one class called <i>MaxLengthTextDocument</i> that extends <i>PlainDocument</i>. In <i>insertString</i> attribute, we checked if quantity of characters minor than <i>maxChars</i> attribute, inserting in String if true.</p>
<p>After this, only insert our implementation in JTextField, this way:</p>
<pre class="brush:java">
	...
	MaxLengthTextDocument maxLength = new MaxLengthTextDocument();
	maxLength.setMaxChars(50);//50 is a maximum number of character 

	jTextField.setDocument(maxLength);
	...
</pre>
<p>And voilà!</p>
<p>See ya!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Inserting padding into a JLabel</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 15:07:38 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=63</guid>
		<description><![CDATA[To insert padding into a JLabel we should use an EmptyBorder, where the attribute &#8216;width&#8217; will be our padding. Like<a href="http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>To insert padding into a JLabel we should use an EmptyBorder, where the attribute &#8216;width&#8217; will be our padding. Like this:</p>
<pre class="brush:java">...
JLabel jLabel = new JLabel("My JLabel");
//Border used as padding
Border paddingBorder = BorderFactory.createEmptyBorder(10,10,10,10);

jLabel.setBorder(BorderFactory.createCompoundBorder(border,paddingBorder));
...</pre>
<p>Here, the JLabel contains a padding with 10 pixels in top, right, bottom and left, respectively.</p>
<p><img class="aligncenter size-full wp-image-64" title="0" src="http://www.andrels.com/wp-en_US/wp-content/uploads/2009/08/0.jpg" alt="0" width="300" height="100" /></p>
<p>If you want to put border around the JLabel, you can use a CompoundBorder, setting Border and EmptyBorder (padding):</p>
<pre class="brush:java">...
JLabel jLabel = new JLabel("Meu JLabel");
//Border used as padding
Border paddingBorder = BorderFactory.createEmptyBorder(10,10,10,10);
//JLabel will be involved for this border
Border border = BorderFactory.createLineBorder(Color.BLUE);

jLabel.setBorder(BorderFactory.createCompoundBorder(border,paddingBorder));
...</pre>
<p><img src="http://www.andrels.com/wp-en_US/wp-content/uploads/2009/08/1.jpg" alt="1" title="1" width="300" height="100" class="aligncenter size-full wp-image-65" /></p>
<p>Download the source code of this sample <a href="http://www.andrels.com/wp-en_US/wp-content/plugins/download-monitor/download.php?id=1" title="Downloaded 275 times">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iBatis tutorial, learning the basic</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/07/ibatis-tutorial-learning-the-basic/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/07/ibatis-tutorial-learning-the-basic/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 20:09:57 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ibatis]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=56</guid>
		<description><![CDATA[When we talk about the persistence framework, we think in Hibernate/JPA. Recently I was presented to iBatis, a framework that<a href="http://www.andrels.com/wp-en_US/index.php/2009/07/ibatis-tutorial-learning-the-basic/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>When we talk about the persistence framework, we think in Hibernate/JPA. Recently I was presented to iBatis, a framework that so easy to install, to configure and to use. You can download it in your sponsor site, <a href="http://www.apache.org" target="_blank">Apache</a>, clicking <a href="http://ibatis.apache.org/javadownloads.cgi" target="_blank">here</a>.</p>
<p><em><strong>Setting iBatis</strong></em></p>
<p>Unlike another frameworks, to configure iBatis you need only one XML file, called <em>SqlMapConfig</em>.</p>
<p>The mains sections of XML are:</p>
<pre class="brush: xml">&lt;properties resource="tuto/ibatis/config/SqlMap.properties"/&gt;</pre>
<p>This code is optional and specifies the .properties file that&#8217;ll be used to declare variables used in configuration. </p>
<pre class="brush: xml">&lt;typeAlias alias="car" type="tuto.ibatis.beans.Car"/&gt;</pre>
<p>Defines the JavaBean used and your alias. You can set much lines, depending of modeling complexity.<br />
In example, we&#8217;ll Car bean below:</p>
<pre class="brush:java">public class Car {
	private Long carId;
	private String company;
	private String model;
	private String color;
	private Integer	hp;
	private Float price;

	//Setters and getters omitted
}</pre>
<pre class="brush: xml">&lt;transactionManager type="JDBC"&gt;
    &lt;dataSource type="SIMPLE"&gt;
        &lt;property name="JDBC.Driver" value="${driver}"/&gt;
        &lt;property name="JDBC.ConnectionURL" value="${url}"/&gt;
        &lt;property name="JDBC.Username" value="${username}"/&gt;
        &lt;property name="JDBC.Password" value="${password}"/&gt;
    &lt;/dataSource&gt;
&lt;/transactionManager&gt;</pre>
<p>Parameters used in database connection. The variables ${driver}, ${url}, ${username} and ${password} are defined in .properties file in section <i>properties</i>. If you prefer, can put the values directly in fields.</p>
<p>See the complete file:</p>
<pre class="brush: xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
        "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"&gt;

&lt;sqlMapConfig&gt;
    &lt;properties resource="tuto/ibatis/config/SqlMap.properties"/&gt;

    &lt;settings
        cacheModelsEnabled="true"
        enhancementEnabled="true"
        lazyLoadingEnabled="true"
        maxRequests="32"
        maxSessions="10"
        maxTransactions="5"
        useStatementNamespaces="false" /&gt;

    &lt;typeAlias alias="car" type="tuto.ibatis.beans.Car"/&gt;

    &lt;transactionManager type="JDBC"&gt;
        &lt;dataSource type="SIMPLE"&gt;
            &lt;property name="JDBC.Driver" value="${driver}"/&gt;
            &lt;property name="JDBC.ConnectionURL" value="${url}"/&gt;
            &lt;property name="JDBC.Username" value="${username}"/&gt;
            &lt;property name="JDBC.Password" value="${password}"/&gt;
        &lt;/dataSource&gt;
    &lt;/transactionManager&gt;

    &lt;sqlMap resource="tuto/ibatis/sqlmaps/CarSqlMap.xml"/&gt;
&lt;/sqlMapConfig&gt;</pre>
<p>The <em>properties</em> have this content:</p>
<pre class="brush:plain">driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@&lt;host&gt;:&lt;porta&gt;:&lt;sid&gt;
username=&lt;login&gt;
password=&lt;senha&gt;</pre>
<p>Next you need to configure the <i>SqlMap</i>. This XML contains the querys used in application and your name need be equals described in <i>sqlMap</i> section of <i>SqlMapConfig</i>, in our case will be <i>CarSqlMap.xml</i></p>
<p>In example only we will see utilization of tags select, insert, update and delete.</p>
<pre class="brush:xml">&lt;select id="getCars" resultClass="tuto.ibatis.beans.Car"
	parameterClass="java.lang.Long"&gt;
    SELECT COMPANY  as company,
           MODEL    as model,
           COLOR    as color,
           HP       as hp,
           PRICE    as price
    FROM TBL_CAR
    WHERE CAR_ID = #var#
&lt;/select&gt;</pre>
<p>Execute the <i>select</i> statement can return a single object or one collection of objects, the type is same of <i>resultClass</i> attribute, o <i>parameterClass</i> is the type sent to execute the <i>query</i> and the <i>id</i> is the query identification call.</p>
<p>We will use the SqlMap below:</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
	"http://ibatis.apache.org/dtd/sql-map-2.dtd"&gt;

&lt;sqlMap namespace="Car"&gt;
    &lt;select id="getCars" resultClass="tuto.ibatis.beans.Car"
    parameterClass="java.lang.Long"&gt;
        SELECT COMPANY  as company,
               MODEL    as model,
               COLOR    as color,
               HP       as hp,
               PRICE    as price
        FROM TBL_CAR
        WHERE CAR_ID = #var#
    &lt;/select&gt;

    &lt;insert id="addCar" parameterClass="tuto.ibatis.beans.Car"&gt;
        INSERT INTO TBL_CAR (CAR_ID, COMPANY, MODEL, COLOR, HP, PRICE)
        VALUES (#carId#, #company#, #model#, #color#, #hp#, #price#)
    &lt;/insert&gt;

    &lt;delete id="delCar" parameterClass="java.lang.Long"&gt;
        DELETE FROM TBL_CAR WHERE CAR_ID = #var#
    &lt;/delete&gt;

    &lt;update id="updCar" parameterClass="tuto.ibatis.beans.Car"&gt;
        UPDATE TBL_CAR
          SET COMPANY = #company#,
              MODEL = #model#,
              COLOR = #color#,
              HP = #hp#,
              PRICE = #price#
        WHERE CAR_ID = #carId#
    &lt;/update&gt;
&lt;/sqlMap&gt;</pre>
<p>Data base connection configured, now we will implements the singleton class the will used as <i>SqlMapClient</i>, called OracleMapConfig.</p>
<pre class="brush:java">package tuto.ibatis.connection;

import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class OracleMapConfig {
	private static final SqlMapClient sqlMapClient;

	static{
		try{
			//Defining path of SqlMapConfig and creating reader
			String res = "tuto/ibatis/config/SqlMapConfig.xml";
			Reader reader = Resources.getResourceAsReader(res);

			//Retrieving the client to SqlMap
			sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch(Exception e){
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

	//Method used to retrieve the client
	public static SqlMapClient getSqlMapClient(){
		return sqlMapClient;
	}
}</pre>
<p>The client is responsible  for execute the querys configured in SqlMap and return the results.</p>
<p><em><strong>Executing Querys and treating the return</strong></em></p>
<p>To call any query is too simple, only execute the correspondent method of client class.</p>
<p>The <em>select</em> can be called this way:</p>
<pre class="brush:java">OracleMapConfig.getSqlMapClient().queryForObject("&lt;id&gt;", &lt;parâmetro&gt;);</pre>
<p>The<i>id</i> need be equals of <i>id</i> specified in <b>SqlMap</b></p>
<p>Only one line is return in code above, to get all lines change to <em>queryForList</em>, this way:</p>
<pre class="brush:java">OracleMapConfig.getSqlMapClient().queryForList("&lt;id&gt;", &lt;parâmetro&gt;);</pre>
<p>Will be returned a <i>Collection</i> containing the objects;</p>
<p><strong>Select</strong></p>
<pre class="brush:java">try{
	Car car = (Car)OracleMapConfig.getSqlMapClient().queryForObject("getCars",
		new Long(readKeyboard()));

	System.out.println("Company: "+car.getCompany());
	System.out.println("Model: "+car.getModel());
	System.out.println("Color: "+car.getColor());
	System.out.println("HP: "+car.getHp());
	System.out.println("Price: "+car.getPrice());
}catch (Exception e) {
	e.printStackTrace();
}</pre>
<p>The <i>id</i> &#8220;getCars&#8221; are defined in select attributes of <em>SqlMap</em>, providing one Long type and retrieving a Car type, both defined in line &lt;select id=&#8221;<span style="color: #0000ff;">getCars</span>&#8221; resultClass=&#8221;<span style="color: #0000ff;">tuto.ibatis.beans.Car</span>&#8221; parameterClass=&#8221;<span style="color: #0000ff;">java.lang.Long</span>&#8220;&gt;.</p>
<p><strong>Insert</strong></p>
<pre class="brush:java">try{
	OracleMapConfig.getSqlMapClient().insert("addCar", newCar);
}catch (Exception e) {
	e.printStackTrace();
}</pre>
<p>Now we will provide as parameter a Car type, &lt;insert id=&#8221;<span style="color: #0000ff;">addCar</span>&#8221; parameterClass=&#8221;<span style="color: #0000ff;">tuto.ibatis.beans.Car</span>&#8220;&gt;, and call the methods using sharp (#), this way:</p>
<pre class="brush:plain">INSERT INTO TBL_CAR (CAR_ID, COMPANY, MODEL, COLOR, HP, PRICE)
VALUES (#carId#, #company#, #model#, #color#, #hp#, #price#)</pre>
<p><strong>Delete</strong></p>
<pre class="brush:java">try{
	int lines = OracleMapConfig.getSqlMapClient().delete("delCar",
		new Long(readKeyboard()));

	System.out.println(lines + " lines deleted");
}catch (Exception e) {
	e.printStackTrace();
}</pre>
<p>The method <em>delete</em> of <i>client</i> return a type int, this represents the number of rows deleted.</p>
<p><strong>Update</strong></p>
<pre class="brush:java">try{
	int lines = OracleMapConfig.getSqlMapClient().update("updCar", car);

	System.out.println(lines + " cars updated");
}catch (Exception e) {
	e.printStackTrace();
}</pre>
<p>Update return a type int, this represents the number of rows affected by update.</p>
<p>How you see, with only three XML and three classes we built a simple storage management and price consulting system.</p>
<p>You can download the source code of this tutorial clicking <a href="../wordpress_external/downloads/TutoIbatis.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">here</a>.</p>
<p>Until next post!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/07/ibatis-tutorial-learning-the-basic/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learn to pass a Java Object as Oracle Procedure parameter</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 03:19:51 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[jdbc]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=44</guid>
		<description><![CDATA[In the enterprise where I work was a discussion about possibility to pass a Java objects into an Oracle procure<a href="http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>In the enterprise where I work was a discussion about possibility to pass a <a href="http://java.sun.com/" target="_blank">Java</a> objects into an <a href="http://www.oracle.com" target="_blank">Oracle</a> procure or function, then I looked for and here is a simple solution to reach this objective.</p>
<p><em>This tutorial only work with </em><em>Oracle</em><em>9i , or above, and using the JDBC driver ojdbc14g, or above</em><em>.</em></p>
<p>First, we create the tables, objects and procedures. Remember: the types <em>tbl_users </em>and <em>user_type </em>must be declared out of packages, as global types:</p>
<pre class="brush: sql">-- Creating table
create table tbl_user(user_name varchar2(100), height number, b_date date);
/
--Creating type user_type (own bean)
create or replace type user_type as object (user_name varchar2(100), height number, birth_date date);
/
--Creating type arr_users, table of user_type (array of user_type)
create or replace type arr_users as table of user_type;
/</pre>
<p>Creating specification and body of package<em>.</em></p>
<pre class="brush: sql">--Spec
create or replace package PAC_BEAN is
  type ref_cur is ref cursor;

  -- Procedure used to insert values
  procedure pro_insert_user(usu in user_type);

  -- Procedure used to select
  procedure pro_select_user(usu in user_type, user_return in out arr_users);
end PAC_BEAN;
/</pre>
<pre class="brush: sql">--Body
create or replace package body PAC_BEAN is
  --The insert procedure will receive user_type and put him into table tbl_user.
  procedure pro_insert_user(usu in user_type) is
    begin
      insert into tbl_user (user_name, height, b_date)
      values (usu.user_name, usu.height, usu.birth_date);

      commit;
    exception
      when others then
        rollback;
  end pro_insert_user;

  --The procedure used for select will receive a user_type (where clause) and will return the array arr_users
  procedure pro_select_user(usu in user_type, user_return in out arr_users)is
    user_ref_cur ref_cur;

    --Instancing the array
    users arr_users := arr_users();

    begin
      --Opening the cursor that will return the array
      open user_ref_cur for
        select cast(
                 multiset(
                   select user_name,
                          height,
                          b_date
                   from tbl_user
                   where user_name like '%'||usu.user_name||'%'
                 ) as arr_users
              ) arr
        from dual;

      --Putting the cursor into arr_users instance.
      fetch user_ref_cur into users;

      --Returning the instance through OUT variable
      user_return := users;
  end pro_select_user;
end PAC_BEAN;
/</pre>
<p><em>See <a href="http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/functions015.htm#sthref1120" target="_blank">CAST</a> and <a href="http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/operators006.htm" target="_blank">MULTISET</a> about how they work.</em></p>
<p>Built database objects, we need prepare the JavaBean. It&#8217;ll an implementation of <em>java.sql.SQLData</em>, because it will be necessary to implement the methods:</p>
<p><em>getSQLTypeName()</em> &#8211; Getter used to obtain the name of type.</p>
<p><em>readSQL(SQLInput, String)</em> &#8211;  Used to convert an object in Java object.</p>
<p><em>writeSQL(SQLOutput stream)</em> &#8211; Used to mount a SQL object, used byJDBC Driver.</p>
<pre class="brush: java">public class TypeUser implements SQLData{
	//Name declared in Oracle
	public static final String ORACLE_OBJECT_NAME = "USER_TYPE";
	//Array name declared in Oracle
	public static final String ORACLE_USER_ARRAY_NAME = "ARR_USERS";

	//The attributes
	private String name;
	private Float height;
	private Date birth;

	public TypeUser() {
		height = 0F;
	}

	public String getSQLTypeName() throws SQLException {
		return ORACLE_OBJECT_NAME;
	}

	public void readSQL(SQLInput stream, String typeName) throws SQLException {
		setName(stream.readString());
		setHeight(stream.readFloat());
		setBirth(stream.readDate());
	}

	public void writeSQL(SQLOutput stream) throws SQLException {
		stream.writeString(getName());
		stream.writeFloat(getHeight());
		stream.writeDate(getBirth() != null ?
				new java.sql.Date(getBirth().getTime()) : null);
	}

        //getters and setters omitted
}</pre>
<p>To define a type that can will be send to procedure be necessary add him  into type map<em> </em>through <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html#getTypeMap()" target="_blank"><em>Connection.getTypeMap()</em></a>. This method return the <em>Map&lt;String,Class&lt;?&gt;&gt;</em>, where type name is the key and class of SQLData implementation is the value, in own case the type <em>TypeUser</em>. Sample:</p>
<pre class="brush: java">Map&lt;String,Class&lt;?&gt;&gt; typeMaps = connection.getTypeMap();
typeMaps.put(TypeUser.ORACLE_OBJECT_NAME, TypeUser.class);</pre>
<p>Then the connection will be:</p>
<pre class="brush: java">//Making connection
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:&lt;host&gt;:&lt;port&gt;:&lt;db&gt;","&lt;user&gt;","&lt;pass&gt;");

//Mapping necessary tipes
Map&lt;String,Class&lt;?&gt;&gt; typeMaps = connection.getTypeMap();
typeMaps.put(TypeUser.ORACLE_OBJECT_NAME, TypeUser.class);</pre>
<p>Now, we create the insert method, it receive an instance of <em>TypeUser </em>and <em>Connection</em>:</p>
<pre class="brush: java">CallableStatement cs = null;
try {
	//call the procedure
	cs = conn.prepareCall("{call PAC_BEAN.PRO_INSERT_USER(?)}");

	//defining the instance of TypeUser as variable IN "usu"
	cs.setObject("usu", typeUser);

	cs.execute();
} catch (SQLException e) {
	e.printStackTrace();
}</pre>
<p>Now, the select method. This method return a object array, then be necessary insert the type of array in <em>Connection TypeMap</em>. The name passed as key should be equals of Oracle&#8217;s array name and the values will be the array class, like this:</p>
<pre class="brush: java">connection.getTypeMap().put(TypeUser.ORACLE_USER_ARRAY_NAME, TypeUser[].class);</pre>
<p>To call procedure and registerOutParameter<em>:</em></p>
<pre class="brush: java">cs = conn.prepareCall("{call PAC_BEAN.PRO_SELECT_USER(?,?)}");
cs.registerOutParameter("user_return", OracleTypes.ARRAY, TypeUser.ORACLE_USER_ARRAY_NAME);
cs.setObject("usu", typeUserQry);

cs.execute();</pre>
<p>To obtain the array, do it:</p>
<pre class="brush: java">//user_return is the OUT variable name
Object[] array = (Object[])cs.getArray("user_return").getArray();</pre>
<p>If until here is alright, smile, to obtain array values just iterate him and cast each index to Type User.</p>
<pre class="brush: java">for(Object obj : array){
	System.out.println("Nome: " + ((TypeUser)obj).getName());
	System.out.println("Altura: " + ((TypeUser)obj).getHeight());
	System.out.println("Data de Nascimento: " + sdf.format(((TypeUser)obj).getBirth()));
}</pre>
<p>So we can pass and retrieve simple Java objects of a Oracle procedure or function. The next step, <a href="http://www.andrels.com/wp-en_US/index.php/2009/09/retrieving-objects-collection-from-oracle-procedure/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Retrieving objects collection from Oracle procedure</a>.</p>
<p>See ya!</p>
<p>Download the source code of this tutorial <a href="../wordpress_external/downloads/post31.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed" target="_blank">here</a>.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 2322px; width: 1px; height: 1px;">
<pre class="brush: java">&lt;host&gt;:&lt;porta&gt;:&lt;bd&gt;","&lt;usuario&gt;","&lt;senha&gt;"</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/06/learn-to-pass-a-java-object-as-oracle-procedure-parameter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Collections, what to use?</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/05/collections-what-to-use/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/05/collections-what-to-use/#comments</comments>
		<pubDate>Sun, 24 May 2009 16:38:49 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[collection]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=27</guid>
		<description><![CDATA[Collection interface has many implementations, like ArrayList, LinkedList, TreeSet and others. With so many variations, some times you don’t known<a href="http://www.andrels.com/wp-en_US/index.php/2009/05/collections-what-to-use/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Collection interface has many implementations, like <a href="http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html" target="_blank">ArrayList</a>, <a href="http://java.sun.com/javase/6/docs/api/java/util/LinkedList.html" target="_blank">LinkedList</a>, <a href="http://java.sun.com/javase/6/docs/api/java/util/TreeSet.html" target="_blank">TreeSet</a> and others. With so many variations, some times you don’t known what to use, this depends of your objective. Now I’ll try to explain some differences in ArrayList, LinkedList and TreeSet.</p>
<p><strong>ArrayList</strong><br />
The ArrayList Collection allow to store objects and null values, but your access is unordered, the first object inserted, can be a last to retrieve.</p>
<p><strong>LinkedList</strong><br />
This implementation of Collection is like ArrayList, but the difference is in access to objects stored, where each object is returned in your inserted order.</p>
<p><strong>TreeSet</strong><br />
If you want retrieve the objects of your Collection in specified order, this Collection can do the work! Insert values in TreeSet is equal previously classes, but your return depends of <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html" target="_blank">Comparable</a> implemented in values. It sort your object values using result of <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html#compareTo(T)" target="_blank">compareTo</a> method, inherited of Comparable Interface.</p>
<p>For more information, visits <a href="http://java.sun.com/javase/6/docs/api/java/util/Collection.html" target="_blank">Collection</a> Javadoc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/05/collections-what-to-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn JavaFX in 15 minutes</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/05/learn-javafx-in-15-minutes/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/05/learn-javafx-in-15-minutes/#comments</comments>
		<pubDate>Sun, 24 May 2009 16:04:58 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javafx]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=13</guid>
		<description><![CDATA[This video show some commands for JavaFX, from a simple “Hello World” to functions and access modifiers. Thanks for Roberto<a href="http://www.andrels.com/wp-en_US/index.php/2009/05/learn-javafx-in-15-minutes/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://tinyurl.com/bznwp5" target="_blank">video</a> show some commands for JavaFX, from a simple “Hello World” to functions and access modifiers.</p>
<p>Thanks for <a href="http://www.furutani.com.br">Roberto Furutani</a>!</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/05/learn-javafx-in-15-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrieving hard drives or removable devices</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/05/retrieving-file-roots/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/05/retrieving-file-roots/#comments</comments>
		<pubDate>Sun, 24 May 2009 15:59:31 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[file]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=7</guid>
		<description><![CDATA[You&#8217;ve tried retrieve the hard drives or removable devices using java.io.File and passed &#8220;/&#8221; like parameter in class constructor? The<a href="http://www.andrels.com/wp-en_US/index.php/2009/05/retrieving-file-roots/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve tried retrieve the hard drives or removable devices using java.io.File and passed &#8220;/&#8221; like parameter in class constructor? The result is the root of classpath, isn&#8217;t?</p>
<p>To obtain the hard drives or removable devices, use <strong>File.<em>listRoots()</em></strong>. This code return a File array, where each index of array is a removable device or hard disk unit.</p>
<p>Follow this sample:</p>
<pre class="brush: java">File[] units = File.listRoots();

for(File unit : units){
    System.out.println(unit.getAbsolutePath());
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/05/retrieving-file-roots/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Manipulating ID3 Tags of MP3 files</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/05/hello-world/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/05/hello-world/#comments</comments>
		<pubDate>Sat, 23 May 2009 15:34:34 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[mp3 java]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=1</guid>
		<description><![CDATA[This post will teach you how to manipulate ID3 tags of MP3 files using Java Jid3Lib Tag Library. First, download<a href="http://www.andrels.com/wp-en_US/index.php/2009/05/hello-world/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>This post will teach you how to manipulate ID3 tags of MP3 files using Java Jid3Lib Tag Library. First, download the jar file from <a href="http://javamusictag.sourceforge.net/">http://javamusictag.sourceforge.net/</a>.</p>
<p>The code below will show you how to get any information of MP3 file:</p>
<pre class="brush: java">try {
    MP3File mp3 = new MP3File("D:\\Musics\\MP3\\ACDC\\ACDC - Back In Black.mp3");
    System.out.println("Album:" + mp3.getID3v2Tag().getAlbumTitle());
    System.out.println("Band:" + mp3.getID3v2Tag().getLeadArtist());
    System.out.println("Composer:" + mp3.getID3v2Tag().getAuthorComposer());
    System.out.println("Year:" + mp3.getID3v2Tag().getYearReleased());
} catch (Exception e) {
	e.printStackTrace();
}</pre>
<p>The result:</p>
<blockquote><p>Album: Back in Black<br />
Band: AC/DC<br />
Composer: Angus Young/Brian Johnson/Malcolm Young<br />
Year:</p></blockquote>
<p>To change any information of any ID3 tags, try the code bellow:</p>
<pre class="brush: java">mp3.getID3v2Tag().setYearReleased("1980");
mp3.save();</pre>
<p>This library has many methods that help you to customize any MP3 file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/05/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

