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

<channel>
	<title>Baran İpek Oracle and Java</title>
	<atom:link href="http://baranipek.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://baranipek.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 13 Sep 2011 19:37:35 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='baranipek.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Baran İpek Oracle and Java</title>
		<link>http://baranipek.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://baranipek.wordpress.com/osd.xml" title="Baran İpek Oracle and Java" />
	<atom:link rel='hub' href='http://baranipek.wordpress.com/?pushpress=hub'/>
		<item>
		<title>RESTful Web Services</title>
		<link>http://baranipek.wordpress.com/2011/09/13/restful-web-services/</link>
		<comments>http://baranipek.wordpress.com/2011/09/13/restful-web-services/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 19:04:45 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=138</guid>
		<description><![CDATA[I could not write&#160; blog entry for a long time because of&#160;intense pace of work and master but I wanna publish one of my article (that I wrote for my lesson ) is about with Restful Web Service.&#160; I hope that is useful for you and gives idea. You can reach via link below. Click [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=138&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I could not write&nbsp; blog entry for a long time because of&nbsp;intense pace of work and master but I wanna publish one of my article (that I wrote for my lesson ) is about with Restful Web Service.&nbsp; I hope that is useful for you and gives idea. You can reach via link below.<br />
<a href='http://baranipek.files.wordpress.com/2011/09/swe577-finalproject-2011summer-iefbfbdefbfbdpekbaran1.pdf'>Click Here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=138&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2011/09/13/restful-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>Vulnerability in OC4J</title>
		<link>http://baranipek.wordpress.com/2010/10/03/vulnerability-in-oc4j/</link>
		<comments>http://baranipek.wordpress.com/2010/10/03/vulnerability-in-oc4j/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 18:52:47 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=131</guid>
		<description><![CDATA[I encountered one of oc4j vulnerability and want to share this experience. Container_tabs.jsp  is  reachable and vulnerable for Cross Site Scripting that is not part of my ear file  when you type url like http://domain/webapp/jsp/container_tabs.jsp. This jsp is located under home/j2ee/applications/webapp/jsp folder  and this page could be exploited by attackers to execute arbitrary scripting code. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=131&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I encountered one of oc4j vulnerability and want to share this experience. Container_tabs.jsp  is  reachable and vulnerable for Cross Site Scripting that is not part of my ear file  when you type url like <a href="http://domain/webapp/jsp/container_tabs.jsp">http://domain/webapp/jsp/container_tabs.jsp</a>. This jsp is located under home/j2ee/applications/webapp/jsp folder  and this page could be exploited by attackers to execute arbitrary scripting code. The solution is enable securty_mod if it isn’t  or you need to remove this page. The last option is waiting for a patch from Oracle but as we know Oracle tend to support Weblogic instead Oc4j.</p>
<p>For further reading</p>
<p>http://hungred.com/web-development/solutions-crosssite-scripting-xss-attack/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=131&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2010/10/03/vulnerability-in-oc4j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>Multithread Url Call with Java</title>
		<link>http://baranipek.wordpress.com/2010/02/12/multithread-url-call-with-java/</link>
		<comments>http://baranipek.wordpress.com/2010/02/12/multithread-url-call-with-java/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 09:34:40 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=115</guid>
		<description><![CDATA[Assume that you want to make sure  your web application’s concurrency as a curious developer:). We can call url with get method through a simple java class. We will test two cases. First test will show us 20 concurent user call url at the same time.However,we will use Executors classes for concurrency call and  Thread [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=115&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Assume that you want to make sure  your web application’s concurrency as a curious developer:). We can call url with get method through a simple java class. We will test two cases. First test will show us 20 concurent user call url at the same time.However,we will use Executors classes for concurrency call and  Thread classes for consecutive call. Thanks to this test,you can monitor Heap usage and memory allocated in the application server.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;Test-1<br />
import java.io.IOException;<br />
import java.util.Calendar;<br />
import java.util.concurrent.ExecutorService;<br />
import java.util.concurrent.Executors;<br />
import java.util.concurrent.TimeUnit;</p>
<p>public class MultiproccesingIndependent {<br />
ExecutorService executor = Executors.newFixedThreadPool(1);</p>
<p>public void start() throws IOException {<br />
int i=0;</p>
<p>while (!executor.isShutdown() &amp;&amp; i&lt;20)<br />
executor.submit(new MyThread(i++));<br />
}</p>
<p>public void shutdown() throws InterruptedException {<br />
executor.shutdown();<br />
executor.awaitTermination(30, TimeUnit.SECONDS);<br />
executor.shutdownNow();<br />
}</p>
<p>public static void main(String argv[]) throws Exception {<br />
new MultiproccesingIndependent().start();<br />
}<br />
}</p>
<p>class MyThread implements Runnable {<br />
private int i;<br />
MyThread(int i) {<br />
this.i = i;<br />
}</p>
<p>public void run() {</p>
<p>Calendar cal = Calendar.getInstance();</p>
<p>MultiProcessing urlReader = new MultiProcessing();<br />
try {</p>
<p>urlReader<br />
.callAdress(url);</p>
<p>} catch (IOException e) {</p>
<p>e.printStackTrace();<br />
}</p>
<p>}<br />
}</p>
<p>&#8212;&#8212;-Test-2</p>
<p><strong>import</strong> java.io.BufferedReader;</p>
<p><strong>import</strong> java.io.IOException;</p>
<p><strong>import</strong> java.io.InputStreamReader;</p>
<p><strong>import</strong> java.net.URL;</p>
<p><strong>import</strong> java.net.URLConnection;</p>
<p><strong>public</strong> <strong>class</strong> MultiProcessing {</p>
<p><strong>static</strong> <strong>void</strong> threadMessage() {</p>
<p>String threadName = Thread.<em>currentThread</em>().getName();</p>
<p>System.<em>out</em>.print(threadName);</p>
<p>}</p>
<p><strong>private</strong> <strong>static</strong> <strong>class</strong> MessageLoop <strong>implements</strong> Runnable {</p>
<p><strong>public</strong> MessageLoop() {</p>
<p>}</p>
<p><strong>public</strong> <strong>void</strong> run() {</p>
<p><strong>synchronized</strong> (MessageLoop.<strong>class</strong>) {</p>
<p><strong>try</strong> {</p>
<p><em>threadMessage</em>();</p>
<p>MultiProcessing urlReader = <strong>new</strong> MultiProcessing();</p>
<p>urlReader.callAdress(&#8220;<strong>your url</strong>&#8220;);</p>
<p>} <strong>catch</strong> (IOException e) {</p>
<p>e.printStackTrace();</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><strong>public</strong> <strong>void</strong> callAdress(String urlEnd) <strong>throws</strong> IOException</p>
<p>{</p>
<p>URL url = <strong>new</strong> URL(urlEnd);</p>
<p>URLConnection conn = <strong>null</strong>;</p>
<p><strong>try</strong> {</p>
<p>conn = url.openConnection();</p>
<p>} <strong>catch</strong> (IOException e) {</p>
<p>e.printStackTrace();</p>
<p>}</p>
<p>BufferedReader in = <strong>new</strong> BufferedReader(<strong>new</strong> InputStreamReader(conn</p>
<p>.getInputStream()));</p>
<p>String line;</p>
<p><strong>while</strong> ((line = in.readLine()) != <strong>null</strong>) {</p>
<p>System.<em>out</em>.println(line);</p>
<p>}</p>
<p>}</p>
<p><strong>public</strong> <strong>static</strong> <strong>void</strong> main(String args[]) <strong>throws</strong> InterruptedException {</p>
<p><strong>for</strong> (<strong>int</strong> i = 0; i &lt; 30; i++)</p>
<p>{</p>
<p>MessageLoop mLopp = <strong>new</strong> MessageLoop();</p>
<p><strong>new</strong> Thread(mLopp).start();</p>
<p>}</p>
<p>}</p>
<p><strong>For further reading</strong></p>
<p>http://java.sun.com/docs/books/tutorial/essential/concurrency/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=115&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2010/02/12/multithread-url-call-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>How to run an application on a specific port  in OC4j</title>
		<link>http://baranipek.wordpress.com/2010/01/20/oc4j/</link>
		<comments>http://baranipek.wordpress.com/2010/01/20/oc4j/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 12:06:04 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=86</guid>
		<description><![CDATA[On the whole, lots of applications are running on the same application server. In order to distinguish applications from each other, you must have different URL’s on the same port. Adding a new port is another and also smart way to do this. I use OC4j version of 10.1.2.3 as a application server. When it comes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=86&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On the whole, lots of applications are running on the same application server. In order to distinguish applications from each other, you must have different URL’s on the same port. Adding a new port is another and also smart way to do this. I use OC4j version of 10.1.2.3 as a application server.</p>
<p>When it comes to adding port in OC4j, Firstly, you must create an instance that runs at the port then you add port in turn by clicking http server, Administration and server properties tab. I added 6000 port as you see below in order to use it later.</p>
<p><a href="http://baranipek.files.wordpress.com/2010/01/oc4j.jpg"><img class="size-full wp-image-87 alignnone" title="oc4j" src="http://baranipek.files.wordpress.com/2010/01/oc4j.jpg?w=350&#038;h=200" alt="" width="350" height="200" /></a></p>
<p>After that, you must create virtual host will use port which you added before.</p>
<p><a href="http://baranipek.files.wordpress.com/2010/01/oc4jsecond.jpg"><img class="size-full wp-image-92 alignnone" title="oc4jsecond" src="http://baranipek.files.wordpress.com/2010/01/oc4jsecond.jpg?w=389&#038;h=300" alt="" width="389" height="300" /></a></p>
<p>         Now we have port and virtual host and we have to relate port with instance. Under  Advanced server properties, you must edit httpd.conf file and add this commands  below.</p>
<p>    <strong>NameVirtualHost *:6000</strong></p>
<p><strong>    Listen 6000</strong></p>
<p><strong>    &lt;VirtualHost _default_:6000&gt;</strong></p>
<p><strong>        ServerName xxxxx.com.tr</strong></p>
<p><strong>        SSLWallet file:D:\OraHome_1\Apache\Apache\conf\ssl.wlt\default</strong></p>
<p><strong>        SSLEngine on</strong></p>
<p><strong>        CustomLog D:\OraHome_1\Apache\Apache\logs\smth</strong></p>
<p><strong>        Port 6000</strong></p>
<p><strong>    &lt;/VirtualHost&gt;</strong></p>
<p><a href="http://baranipek.files.wordpress.com/2010/01/oc4jthird1.jpg"></a></p>
<p>This step will  provide us to relate port with your instance. You must edit mod_ocf4.conf file and  add this commands  below</p>
<p><a href="http://baranipek.files.wordpress.com/2010/01/oc4jforth.jpg"></a></p>
<p><strong>&lt;VirtualHost *:6000&gt;</strong></p>
<p><strong>        Oc4jMount / instancename</strong></p>
<p><strong>        Oc4jMount /* instancename</strong></p>
<p><strong>        ServerName  serverip </strong></p>
<p><strong>    &lt;/VirtualHost&gt;</strong></p>
<p>For more reading</p>
<p><a href="http://download-west.oracle.com/docs/cd/A97329_03/core.902/a92171/config.htm">http://download-west.oracle.com/docs/cd/A97329_03/core.902/a92171/config.htm</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=86&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2010/01/20/oc4j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>

		<media:content url="http://baranipek.files.wordpress.com/2010/01/oc4j.jpg" medium="image">
			<media:title type="html">oc4j</media:title>
		</media:content>

		<media:content url="http://baranipek.files.wordpress.com/2010/01/oc4jsecond.jpg" medium="image">
			<media:title type="html">oc4jsecond</media:title>
		</media:content>
	</item>
		<item>
		<title>A short comparison between HIBERNATE and JDBC</title>
		<link>http://baranipek.wordpress.com/2010/01/13/40/</link>
		<comments>http://baranipek.wordpress.com/2010/01/13/40/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 14:56:32 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=40</guid>
		<description><![CDATA[Nowadays, ORM is a hot topic in java world. You have many options if you decide to use ORM in your Project  but hibernate is the most popular one.When we look into advantages  of hibernate, Caching and connection pooling is  not maintained manually in hibernate. It is done by hand-coding in JDBC.  JDBC supports only [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=40&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Nowadays, ORM is a hot topic in java world. You have many options if you decide to use ORM in your Project  but hibernate is the most popular one.When we look into advantages  of hibernate, Caching and connection pooling is  not maintained manually in hibernate. It is done by hand-coding in JDBC.  JDBC supports only sql but hibernate is independant from database and provides query language HQL that is similar to  native sql. Hibernate also supports native sql. With JDBC you must handle result set and convert it to java object but hibernate  reduces code lines by maintaining object-table mapping and return java object to application.As many approaches,hibernate has also disadvantages beside its advantages.  In case of simple database that never changes ,hibernate increase complexity. For complex data ,conversion  reduces performance. As you know, learning hibernate is overhead for developers. So you must estimate software costs well . The choice depends on Project requirements,the skill of development team.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=40&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2010/01/13/40/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>Increase the memory of OC4J standalone server</title>
		<link>http://baranipek.wordpress.com/2009/08/18/increase-the-memory-of-oc4j-standalone-server/</link>
		<comments>http://baranipek.wordpress.com/2009/08/18/increase-the-memory-of-oc4j-standalone-server/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 19:45:05 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=36</guid>
		<description><![CDATA[ If your  jsp or servlet pages  have any problems and you see  “java.lang.OutOfError” in your log files then you probably increase your JVM’s heap size. But before then  I strongly recommend you to revise your code before increasing heapsize. Maybe you don’t use connection pooling or  you create object in infinite loop J (I hope [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=36&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> If your  jsp or servlet pages  have any problems and you see  “java.lang.OutOfError” in your log files then you probably increase your JVM’s heap size. But before then  I strongly recommend you to revise your code before increasing heapsize. Maybe you don’t use connection pooling or  you create object in infinite loop J (I hope you don’t do that).</p>
<p>If you use oc4j as a application server you will  edit opmn.xml  file .Adding parts of the xml file are highlighted below.  I increase 64 that is default to 512 M.  Once you change the file, execute the command below to request OPMN to reload the configuration file into memory:</p>
<p>&gt;$ORACLE_HOME/opmn/bin/opmnctl reload and then and then start the OC4J instance.</p>
<p> </p>
<p>&lt;process-type id=&#8221;<strong>myinstance</strong>&#8221; module-id=&#8221;<strong>OC4J</strong>&#8220;&gt;</p>
<p><strong><span style="text-decoration:underline;">-</span></strong>&lt;module-data&gt;</p>
<p><a href="/Users/Baran/Desktop/opmn.xml"><strong>-</strong></a> &lt;category id=&#8221;<strong>start-parameters</strong>&#8220;&gt;</p>
<p><strong> </strong> &lt;data id=&#8221;<strong>java-options</strong>&#8221; value=&#8221;<strong>-</strong>server -Xrs -Djava.security.policy=D:\Hukuk10gAS\j2ee\hukuk\config\java2.policy -Djava.awt.headless=true -XX:PermSize=128m -XX:MaxPermSize=128m <strong>–Xms512m –Xmx512m&#8221;</strong> /&gt;</p>
<p><strong> </strong> &lt;data id=&#8221;<strong>oc4j-options</strong>&#8221; value=&#8221;<strong>-properties</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;/category&gt;</p>
<p><a href="/Users/Baran/Desktop/opmn.xml"><strong>-</strong></a> &lt;category id=&#8221;<strong>stop-parameters</strong>&#8220;&gt;</p>
<p><strong> </strong> &lt;data id=&#8221;<strong>java-options</strong>&#8221; value<strong>=&#8221;-</strong>Djava.security.policy=D:\Hukuk10gAS\j2ee\hukuk\config\java2.policy -Djava.awt.headless=true<strong>&#8220;</strong> /&gt;</p>
<p><strong> </strong> &lt;/category&gt;</p>
<p><strong> </strong> &lt;/module-data&gt;</p>
<p><strong> </strong> &lt;start timeout=&#8221;<strong>900</strong>&#8221; retry=&#8221;<strong>2</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;stop timeout=&#8221;<strong>120</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;restart timeout=&#8221;<strong>720</strong>&#8221; retry=&#8221;<strong>2</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;port id=&#8221;<strong>ajp</strong>&#8221; range=&#8221;<strong>12501-12600</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;port id=&#8221;<strong>rmi</strong>&#8221; range=&#8221;<strong>12401-12500</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;port id=&#8221;<strong>jms</strong>&#8221; range=&#8221;<strong>12601-12700</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;process-set id=&#8221;<strong>default_island</strong>&#8221; numprocs=&#8221;<strong>1</strong>&#8221; /&gt;</p>
<p><strong> </strong> &lt;/process-type&gt;</p>
<p> </p>
<p> </p>
<p>For more reading</p>
<p><a href="http://download.oracle.com/docs/cd/B25221_04/core.1013/b15976/opmnxml.htm">http://download.oracle.com/docs/cd/B25221_04/core.1013/b15976/opmnxml.htm</a></p>
<p><a href="http://www.deakin.edu.au/its/dba/oracle-doco/9.0.4.1/9.0.4_doc_library/integrate.904/b12121/perf.htm">http://www.deakin.edu.au/its/dba/oracle-doco/9.0.4.1/9.0.4_doc_library/integrate.904/b12121/perf.htm</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=36&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2009/08/18/increase-the-memory-of-oc4j-standalone-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Collections</title>
		<link>http://baranipek.wordpress.com/2008/10/05/java-collections/</link>
		<comments>http://baranipek.wordpress.com/2008/10/05/java-collections/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 18:20:01 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=30</guid>
		<description><![CDATA[This is my first blog entry on java technologies. My friend asked me why I don&#8217;t publish articles on Java. So i ama little excited. Well, Today we glance at Collection on java. A collection in data structure terms, is a group of elements.It includes Sets and Lists. It also includes Maps which don’t implement [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=30&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is my first blog entry on java technologies. My friend asked me why I don&#8217;t publish articles on Java. So i ama little excited. Well, Today we glance at Collection on java. A collection in data structure terms, is a group of elements.It includes Sets and Lists. It also includes Maps which don’t implement Collection. Collection is the interface implemented by classes such as Arraylists,TreeSet and HashSet implement. It defines to methods to them all. Collection classes live in java.util package. I want to give ArrayList and LinkList Class example that implements List interface</p>
<p><strong>public class Data {<br />
protected int  myArray [];<br />
public int size ;<br />
public Data()<br />
{<br />
myArray = new int [50];<br />
}<br />
public Data (int n)<br />
{<br />
myArray = new int[50];<br />
size =n;<br />
}<br />
protected void finalize() {<br />
System.out.println(&#8220;cleaned&#8221; + size);</strong></p>
<p><strong>}<br />
}</strong><br />
<strong>import java.util.*;</strong></p>
<p><strong>public class ArrayListExample<br />
{</strong></p>
<p><strong>public static void main(String[] args) {<br />
ArrayList l = new ArrayList();<br />
int sizeOfL ;<br />
for (int i = 0; i&lt;5; i++)<br />
{<br />
l.add(new Data(i));<br />
}<br />
sizeOfL = l.size();<br />
for (int i = 0; i &lt;sizeOfL; i++) {<br />
int size =((Data) l.get(i)).size;<br />
System.out.println(&#8220;elements 1&#8230;&#8221; + size);<br />
}</strong></p>
<p><strong>l.add(0, new Data(6)); // 6,0,1,2,3,4<br />
l.add(2, new Data(17)); // 6,0,17,1,2,3,4<br />
sizeOfL = l.size();</strong></p>
<p><strong>for (int i = 0; i &lt;sizeOfL; i++) {<br />
int size =((Data) l.get(i)).size;<br />
System.out.println(&#8220;elements 2&#8230;.&#8221; + size);<br />
}<br />
l.remove(3); //6,0,17,2,3,4<br />
List sub = l.subList(1, 3); // 0,17<br />
}</strong></p>
<p><strong>}</strong></p>
<p>A LinkedList is similar to an ArrayList in that it is ordered by index position. If you want to have random access of the list<br />
Arraylist offers quick access than LinkList but this comes at slower operations for adding and removing in the middle of the<br />
list.<br />
Vector is synchronized whereas ArrayList is not.ArrayList and Vector class both implement the List interface. Both classes are implemented using dynamically resizable arrays, providing fast random access and fast traversal when you want programs to run in multithreading environment then use concept of vector because it is synchronized. But ArrayList is not synchronized so, avoid use of it in a multithreading environment.Arraylist has no default size but vector has size of ten. We can see using capacity()method.</p>
<p><strong>import java.util.*;<br />
public class Demo1 {<br />
public static void main(String[] args) {<br />
//creating vector<br />
Vector v= new Vector();<br />
v.add(&#8220;baran&#8221;);<br />
v.add(&#8220;ipek&#8221;);<br />
//creating enumeration interface<br />
Enumeration E=v.elements();<br />
System.out.println(&#8220;Element are : &#8220;);<br />
while(E.hasMoreElements())<br />
{<br />
System.out.println(E.nextElement()+&#8221;\t&#8221;);<br />
}<br />
//Returns the current capacity of this vector.<br />
int i=v.capacity();<br />
System.out.println(&#8220;Capacity of the vector is: &#8220;+i);<br />
}</strong></p>
<p><strong>}</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=30&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2008/10/05/java-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>PL/SQL EXCEPTIONS</title>
		<link>http://baranipek.wordpress.com/2008/02/16/plsql-exceptions/</link>
		<comments>http://baranipek.wordpress.com/2008/02/16/plsql-exceptions/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 16:15:38 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/?p=29</guid>
		<description><![CDATA[Evde yaptıgım ufak bir exceptions örneğini anlatmak istedim. Birazda giriş sevyesinde fonksiyonlar ve ref cursor hakkında bilgi vermiş olacağım. Çok basit bir işlem yapan fonksiyon 3 kolondan oluşan tabloma ID verip diger bilgileri alan fonksiyon yazdım cursor döndürcem sonuç olarak. O zaman hemen fonksiyonu yazalım. Eger exception alırsam 1 parametresini yollicam. CREATE OR REPLACE FUNCTION [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=29&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Evde yaptıgım ufak bir exceptions örneğini anlatmak istedim. Birazda giriş sevyesinde fonksiyonlar ve ref cursor hakkında bilgi vermiş olacağım. Çok basit bir işlem yapan fonksiyon 3 kolondan oluşan tabloma ID verip diger bilgileri alan fonksiyon yazdım cursor döndürcem sonuç olarak. O zaman hemen fonksiyonu yazalım. Eger exception alırsam  1 parametresini yollicam.</p>
<p><i>CREATE OR REPLACE FUNCTION test<br />
(<br />
iid    IN NUMBER,<br />
ostatu OUT NUMBER<br />
) RETURN SYS_REFCURSOR AS<br />
TYPE v_cursor IS REF CURSOR;<br />
p_cursor  v_cursor;<br />
verrormsg VARCHAR2(4000);</i></p>
<p><i>l_row VARCHAR2(200) := &#8221;;<br />
BEGIN<br />
l_row := &#8216;select * from deneme where ID = :iID&#8217;;</i></p>
<p><i>OPEN p_cursor FOR l_row<br />
USING iid;</i></p>
<p><i>EXCEPTION<br />
WHEN OTHERS THEN<br />
ostatu    := 1;<br />
verrormsg := substr(SQLERRM, 1, 3000);<br />
INSERT INTO log_data VALUES (iid, verrormsg, SYSDATE);<br />
COMMIT;<br />
RETURN p_cursor;</i></p>
<p><i>END; </i></p>
<p>Hemen ardından test ediyim bakalım data getiriyormu ?</p>
<p><i>DECLARE<br />
refcursor SYS_REFCURSOR;<br />
vid       NUMBER;<br />
vname     VARCHAR2(100);<br />
vn_statu  NUMBER;<br />
vil       NUMBER;<br />
BEGIN</i></p>
<p><i>refcursor := test(104022008230216, ostatu =&gt; vn_statu);</i></p>
<p><i>LOOP<br />
FETCH refcursor<br />
INTO vid, vname;<br />
EXIT WHEN refcursor%NOTFOUND;</i></p>
<p><i>dbms_output.put_line(vid || &#8216; | &#8216; || vname);</i></p>
<p><i>END LOOP;<br />
CLOSE refcursor;<br />
END; </i></p>
<p>Getiriyor valla denedim gördüm. Sonra ne zorum varsa gidip select çektiğim tabloyu drop ettim. Dedimki o zaman log_data tablosu yapıyım da hatayı göriyim sanki bilmiyomuşum gibi:) Exception kısmından gelebilecek tüm exceptionlar için <b>when others then </b>kullandım. Sonra yine test ettim .</p>
<p>DECLARE<br />
refcursor SYS_REFCURSOR;</p>
<p>vn_statu NUMBER;<br />
<i><br />
BEGIN</i></p>
<p><i>refcursor := test(104022008230216, ostatu =&gt; vn_statu);</i></p>
<p><i>dbms_output.put_line(vn_statu);<br />
CLOSE refcursor;<br />
END;</i></p>
<p>OUT parametrem olan 1 gördüm ve merat edip gidip log  tabloma baktım. Evet table or view doesn&#8217;t exist diyor allah allah ne oldu acaba:) Basit bir örnek göstermek istedim tabi bu arada yaptıgım eksikler de var hızlı yapıyım derken. Mesela paketin içine yazmalıydım fonksiyonu,dynamic sql &#8216;e gerek varmı ? vb.. ama dediğim gibi örneklendirmek için basit bir örnek göstermek istedim.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/baranipek.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/baranipek.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=29&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2008/02/16/plsql-exceptions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>PL/SQL performans</title>
		<link>http://baranipek.wordpress.com/2007/09/21/plsql-performans/</link>
		<comments>http://baranipek.wordpress.com/2007/09/21/plsql-performans/#comments</comments>
		<pubDate>Fri, 21 Sep 2007 08:20:28 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/2007/09/21/plsql-performans/</guid>
		<description><![CDATA[Using Bind or Not SGA’nın bölümlerinden biri olan shared pool data dictionary cache ve library cache olarak iki bölümden oluşur. Library cache yazdığımız ve kullandığımız en son sql ve pl/sql leri (procedure ve function vb..) saklar yani LRU(last recent used) algoritması doğrultusunda çalıştırır. Örneğin yazdığımız bir function bir kullancı tarafından kullanılmak istendiğinde kullanıcı bunu shared [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=24&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Using Bind or Not</strong></p>
<p>SGA’nın bölümlerinden biri olan shared pool data dictionary cache ve library cache olarak iki bölümden oluşur. Library cache yazdığımız ve kullandığımız en son sql ve pl/sql leri (procedure ve function vb..) saklar yani LRU(last recent used) algoritması doğrultusunda çalıştırır. Örneğin yazdığımız bir function bir kullancı tarafından kullanılmak istendiğinde kullanıcı  bunu  shared pool dan alır ve function zaten memory de olduğu için performansdan kazanmış olurum. O zaman library cache alanından haberdar olmak  bir  database developer için bize büyük fayda sağlayacaktır.</p>
<p>Library cache’in shared sql area sında yeni bir sql gelirse yeni alan oluşturulup sql için parse tree ve execution bilgileri oluşturulur. Tüm alanlar dolduğunda daha once bahsettiğimiz LRU algoritması ile alanlar sql lere dağıtılır. SQL’in  çalışması için dört evresinden (parsing,optimization,row-source generation,execution) birincisi parsing işlemidir. Parsing işleminde sql’in doğru yazılıp yazılmadığı,sql deki objelerin olup olmaması ,daha önce sql’in kullanılıp kullanılmadığı gibi daha birçok  işlem kontrol edilir ki bu da en maliyetli kısım olarak karşımıza çıkıyor. O zaman bir developer olarak performans için elimizden geldiği kadar parsing işlemini minimum sevyede tutmaya çalışacağız. O zaman amacımız  ‘one parse-execute many’  olacaktır.</p>
<p>Daha öncede bahsettiğimiz gibi developer sql ve pl/sql yazdıktan sonra Oracle shared pool’a gidip daha önceden parse ve optimized işlemi yapılmış diye bakar. Eğer bulursa tekrar kullanır ve bu sistem için en performanslı yoldur . Eğer  bulamazsa yukarda bahsettiğimiz dört aşamadan geçer. İşte bu noktada bind variable yardımımıza koşacaktır. Tek kullanıcılı sistemde performans farkı kullanıp kullanmama arasında daha az olacktır ama analizler yine bind kullanımı destekleyecektir.</p>
<p><em>Select * from emp where empno=123;</em></p>
<p><em>Selct * from emp where empno=:empno;</em></p>
<p>Mesela yukardaki ilk sorguda 123 nolu employee getirdim. Sonra bunu 234,345 vb gibi değiştirdiğim zaman her seferinde sorgumu baştan parse etmiş olacağım. Bind variable kullandığım ikinci sorguda ise sorgu bir kez compile edilip query planıyla birlikte library cache saklanır. Daha sonra istenildiği zaman parse edilmeden kullanılabilinir. Şimdi daha önceden bahsettiğimiz tkprof ile örneklerimizi analiz edelim. Birincisinde bind variable kullanıp ikincisinde kullanmayacağım. Alter system flush shared_pool ile testimin sağlıklı sonuç vermesi için shared pool’u sıfırlayacağım.</p>
<p>set timing on<br />
set serveroutput on</p>
<p>alter session set max_dump_file_size=unlimited;<br />
ALTER session SET timed_statistics = true;<br />
alter session set STATISTICS_LEVEL = ALL ;</p>
<p>alter system flush shared_pool;<br />
alter system flush buffer_cache;</p>
<p>alter session set tracefile_identifier = bind ;<br />
ALTER SESSION SET EVENTS &#8217;10046 TRACE NAME CONTEXT FOREVER, LEVEL 12&#8242;;</p>
<p>declare<br />
TYPE rc IS REF CURSOR;<br />
l_rc    rc;<br />
l_dummy all_objects.object_name%TYPE;<br />
l_start NUMBER DEFAULT dbms_utility.get_time;<br />
BEGIN<br />
FOR i IN 1 .. 1000 LOOP<br />
OPEN l_rc FOR &#8216;select object_name<br />
from all_objects<br />
where object_id = <img src='http://s2.wp.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> &#8216; USING i;<br />
FETCH l_rc INTO l_dummy;<br />
CLOSE l_rc;<br />
END LOOP;<br />
dbms_output.put_line(round((dbms_utility.get_time &#8211; l_start) / 100,<br />
2) || &#8216;seconds&#8230;&#8217;);<br />
END;<br />
/</p>
<p>ALTER SESSION SET EVENTS &#8217;10046 TRACE NAME CONTEXT OFF&#8217;;</p>
<p>1.48seconds&#8230;</p>
<p>set timing on<br />
set serveroutput on</p>
<p>alter session set max_dump_file_size=unlimited;<br />
ALTER session SET timed_statistics = true;<br />
alter session set STATISTICS_LEVEL = ALL ;</p>
<p>alter system flush shared_pool;<br />
alter system flush buffer_cache;</p>
<p>alter session set tracefile_identifier = nobind1 ;<br />
ALTER SESSION SET EVENTS &#8217;10046 TRACE NAME CONTEXT FOREVER, LEVEL 12&#8242;;</p>
<p>declare<br />
TYPE rc IS REF CURSOR;<br />
l_rc    rc;<br />
l_dummy all_objects.object_name%TYPE;<br />
l_start NUMBER DEFAULT dbms_utility.get_time;<br />
BEGIN<br />
FOR i IN 1 .. 1000 LOOP<br />
OPEN l_rc FOR &#8216;select object_name<br />
from all_objects<br />
where object_id = &#8216; || i;<br />
FETCH l_rc INTO l_dummy;<br />
CLOSE l_rc;<br />
END LOOP;<br />
dbms_output.put_line(round((dbms_utility.get_time &#8211; l_start) / 100,<br />
2) || &#8216;seconds&#8230;&#8217;);<br />
END;<br />
/</p>
<p>ALTER SESSION SET EVENTS &#8217;10046 TRACE NAME CONTEXT OFF&#8217;;</p>
<p>31.02seconds&#8230;</p>
<p>İki sorgu arasında zaman farkı anlamak için başta ve sonda dbms_utility.get_time ile zamanı alıp kıyasladığımda bind kullanmadan yaklaşık 30 katı kadar sure fazla harcamış gözüküyorum. İlk trace dosyamın boyutu 57kb ikne ikinci trace dosyam 3mb civarında. O zaman trace dosyalarımızın farkının nerden geldiğine bir bakalım.</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
Parse     1063      0.02       0.02          0          0                 0           0<br />
Execute  1092     0.17       0.23          0          0                 0           0<br />
Fetch     1301     0.08       0.93        171       6790             0        1203<br />
total     3456      0.27       1.19        171       6790             0        1203</p>
<p>Misses in library cache during parse: 7</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
Parse     2100     29.07      29.73          0          6                    0             0<br />
Execute  2296      0.34       0.31          0          0                     0            0<br />
Fetch     2612      0.32       2.10        200      10549                 0         3646<br />
total     7008     29.73      32.15        200      10555                0          3646</p>
<p>Misses in library cache during parse: 1019</p>
<p>Yukardaki analizleri kıyasladığımda  ikinci trace’imde parse işlemin maliyeti görüldüğü gibi cpu değerine de yansıdı. Fazladan parsing,cpu kullanımı,response time performansımın düşmesine neden oldu.</p>
<p>Bind</p>
<p>select object_name<br />
from all_objects<br />
where object_id = <img src='http://s2.wp.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> </p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
Parse     1000      0.02       0.01          0          0          0           0<br />
Execute 1000      0.15       0.19          0          0          0           0<br />
Fetch     1000      0.05       0.19        49       6315          0         953<br />
total     3000      0.22       0.40         49       6315          0         953</p>
<p>Nobind</p>
<p>select object_name<br />
from all_objects</p>
<p>where object_id = 1</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
Parse        1      0.07       0.07              0          0                    0           0<br />
Execute      1      0.00       0.00            0          0                    0           0<br />
Fetch        1      0.00       0.02             2          5                     0           1<br />
total        3      0.07       0.09               2          5                     0           1</p>
<p>………………………………………..<br />
………………………………………..<br />
……………………………………….</p>
<p>select object_name<br />
from all_objects</p>
<p>where object_id = 999</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
Parse        1      0.07       0.07               0             0          0           0<br />
Execute    1      0.00       0.00               0             0          0           0<br />
Fetch        1      0.00       0.02               3             8          0           1<br />
total          3      0.07       0.09               3             8          0           1</p>
<p>Birinci trace dosyamda yukardaki sorgu için bir defa plan oluşturuluken ikinci sorgumda x değerinin 1000’e kadar her değeri için ayrı  parse etti ve plan oluşturdu ve bu ikinci trace dosyamın büyük boyutlara ulaşmasına neden oldu. Bind variable’nın parse sayısını azaltması  cpu  kazanımın yanında çoklu kullanıcılarda library cachedeki  latch sayısını da azaltacağı için sistem daha hızlı çalışacaktır. Share sql alanında bir anda tek oturum hard parse edeceğinden birçok kullanıcının hard parse yapması bekleme yaratacaktır. Bu da yine performans kaybına yol açar.</p>
<p>Bind variable performansın yanında veritabanı güvenliği açısından da önemlidir. Sql injection sql üzerinden veritabanına sızma olarak adlandırılır. Bu bir paket çağırma,verileri göstermek olabilir. Sql injection olması için sql’in dynamic sql olması gerekir ve gelecek parametrelere  gore runtime sırasında oluşur ve bu da güvenlik açısından bir açık olarak karşımıza çıkabilir. İşte bu noktada bind variable kullanımı yardımımıza yetişiyor.</p>
<p>IF you use dynamic sql<br />
AND<br />
you use string concatenation<br />
THEN<br />
you are subject to sql injection<br />
END IF</p>
<p>Yukarda ifade ettiğimiz gibi concatenation kullanımı sql injection için uygun zemin hazırlayacaktır. Şimdi sql injection yönetmi ile ilgili bir örnek yapıp bind kullanımın yararlarını görelim. Önce bir tablo yaratacağız sonra sonra bir fonksiyon yardımıyla banka hesabına sızmaya çalışağız.</p>
<p>create table my_top_secrets (<br />
PK_SECRET VARCHAR2(30) PRIMARY KEY,<br />
BANK_ACCOUNT VARCHAR2(30),<br />
AMOUNT NUMBER(10)<br />
);<br />
insert into my_top_secrets values(’1′, ‘Malta Bank &#8211; 123456′, 123000000);<br />
insert into my_top_secrets values(’2′, ‘Isviçre Bank &#8211; 7890′, 4567000000);<br />
commit;</p>
<p>create or replace function get_bankaccount(p_secret varchar2) return varchar2 is<br />
TYPE rc IS REF CURSOR;<br />
l_rc rc;<br />
l_dummy varchar2(64) := &#8216;Fail&#8217;;<br />
BEGIN<br />
OPEN l_rc FOR &#8216;select BANK_ACCOUNT<br />
from my_top_secrets<br />
where PK_SECRET = &#8216;|| p_secret;<br />
FETCH l_rc INTO l_dummy;<br />
CLOSE l_rc;<br />
return l_dummy ;<br />
END;</p>
<p>Tabloyu yaratıp satırları ekledik sonra bize  banka hesaplarını getirmesini istedik .</p>
<p>set serveroutput on<br />
declare<br />
l_dummy1 varchar2(64) := &#8216;-1&#8242;;<br />
l_dummy2 varchar2(64);<br />
begin<br />
l_dummy2 := get_bankaccount(l_dummy1);<br />
dbms_output.put_line(l_dummy2);<br />
end;<br />
/<br />
Fail<br />
PL/SQL procedure successfully completed.</p>
<p>Dedikten sonra  beklendiği üzere fail mesajını  aldık</p>
<p>declare<br />
l_dummy1 varchar2(64) := ‘-1′ || ‘ or 1=1′;<br />
l_dummy2 varchar2(64);<br />
begin<br />
l_dummy2 := get_bankaccount(l_dummy1);<br />
dbms_output.put_line(l_dummy2);<br />
end;<br />
/</p>
<p>Malta Bank &#8211; 123456</p>
<p>Yukarıda  kırmızıyla eklenen kısımla banka hesabımızın içine sızılmış oldu. Halbuki fonksiyonu yazarken bu durumu düşünmemiştik. O zaman  bu gibi durumlara karşı önlem almak için fonksiyonda bind kullanıp tekrar sızmaya çalışalım.</p>
<p>create or replace function get_bankaccount (p_secret varchar2) return varchar2 is<br />
TYPE rc IS REF CURSOR;<br />
l_rc rc;<br />
l_dummy varchar2(64) := &#8216;Fail&#8217;;<br />
BEGIN<br />
OPEN l_rc FOR &#8216;select BANK_ACCOUNT<br />
from my_top_secrets<br />
where PK_SECRET = <img src='http://s2.wp.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> &#8216; USING p_secret;<br />
FETCH l_rc INTO l_dummy;<br />
CLOSE l_rc;<br />
return l_dummy ;<br />
END;<br />
/<br />
declare<br />
l_dummy1 varchar2(64) := &#8216;-1&#8242;|| &#8216;or 1=1&#8242;;<br />
l_dummy2 varchar2(64);<br />
begin<br />
l_dummy2 := get_bankaccount(l_dummy1);<br />
dbms_output.put_line(l_dummy2);<br />
end;<br />
/</p>
<p>Fail</p>
<p>Bind kullanımından sonra bilgilerimize ulaşılamadı. Zaten bind kullanımın performasını yukarıda ıspatlamıştık. O zaman dynamic sql ifadelerde veya  java da bind kullanamadığımız durumlar hariç(tablo isimleri,colon isimleri vb) her zaman bind kullanımı performans ve güvenliğimiz açısından yararlı olacaktır.</p>
<p><strong>Cursor</strong></p>
<p>PL/SQL içinde SQL yazdığımız zaman Oracle sqller için özel bir alan tahsis eder. Bu alan yazdığımız sqllerden ve getirdiği kayıtlardan oluşur. Cursor bu alana isim verebilmemizi ve içerdiği kayıtarı işlememizi sağlayan pl/sql mekanizmasıdır ya da başka bir deyişle veritabanımdaki tabloların içindeki pointer olarak söylenebilinir. İki çeşit cursor tanımlayabiliriz.</p>
<p>Kapalı İmleçler(İmplicit Cursor): Yazılan her sql komutları için Oracle tarafından  otomatik olarak açılan imleçlerdir. Yazılan her kapalı imleç için SQL%NOTFOUND, SQL%ROWCOUNT, SQL%FOUND, SQL%NOTFOUND özellikleri açıktır.Cursor declare etmeye gerek yoktur .</p>
<p>SELECT SUM (salary) INTO department_total<br />
FROM employee<br />
WHERE department_number = 10;</p>
<p>Yukardaki ifader için Oracle implicit cursor otomatik olarak yaratacaktır. Eğer ifade birden fazla satır getitirse exception yaratacaktır. İkinci satırı getirmem için TOO_MANY_ROWS exception’ a ihtiyacım olacaktır .</p>
<p>Açık İmleçler(Explicit Cursor):Programcı  tarafından belirli bir işi yapabilmek için açılan imleçlerdir..Cursordaki birden çok  satıra tek tek erişme, processde olan satırı işlemek gibi işlemleri programcıya sunan cursor çeşididir. Parametre alabilir.</p>
<p>declare<br />
cursor c1 is select ename, job, sal from emp;<br />
v_ename emp.ename%type;<br />
v_job emp.job%type;<br />
v_sal emp.sal%type;<br />
begin<br />
open c1;<br />
loop<br />
fetch c1 into v_ename, v_job, v_sal;<br />
exit when c1%notfound;<br />
dbms_output.put_line(v_ename||&#8217;  &#8216;|v_job||&#8217;  &#8216;||v_sal);<br />
end loop;<br />
end;<br />
/</p>
<p>Yukarda gördüğümüz önce cursorı declare ettik sonra open ile açtık ve bir döngü içerisinde daha once kolonla aynı type da kolon değişkenlere fetch ettik. Yukarıda gördüğümüz gibi cursorun açılması,fetch edilmesi ve kapanması herşeyi programcı yapıyor fakat implicit cursorda Oracle bu işlemleri otomatik yapar. Şimdi implicit ve explicit cursorları kıyaslayalım ve hangisi kullanacağımıza karar verelim. İlk önce performansları kıyaslayalım.</p>
<p><strong>İmplicit cursor</strong></p>
<p>create or replace procedure implicit_interpreted( p_times in number )<br />
as<br />
l_dummy dual.dummy%type;<br />
l_start number default dbms_utility.get_time;<br />
begin<br />
for i in 1 .. p_times<br />
loop<br />
select * into l_dummy from dual;<br />
end loop;<br />
dbms_output.put_line( (dbms_utility.get_time-l_start) || &#8216; hsecs&#8230;&#8217; );<br />
end;<br />
/<br />
<strong><br />
Explicit cursor</strong></p>
<p>create or replace procedure explicit_interpreted( p_times in number )<br />
as<br />
cursor c is select * from dual;<br />
l_dummy dual.dummy%type;<br />
l_start number default dbms_utility.get_time;<br />
begin<br />
for i in 1 .. p_times<br />
loop<br />
open c;<br />
fetch c into l_dummy;<br />
if ( c%notfound ) then<br />
raise no_data_found;<br />
end if;</p>
<p>fetch c into l_dummy;<br />
if ( c%found ) then<br />
raise too_many_rows;<br />
end if;</p>
<p>close c;<br />
end loop;<br />
dbms_output.put_line( (dbms_utility.get_time-l_start) || &#8216; hsecs&#8230;&#8217; );<br />
end;<br />
/</p>
<p>exec explicit_interpreted( 50000 );</p>
<p>PL/SQL procedure successfully completed.</p>
<p>Elapsed: 00:00:26.51</p>
<p>call     count          cpu    elapsed       disk      query    current        rows<br />
Parse       31            0.00       0.00          0             0                 0                 0<br />
Execute  50035        1.14       1.13          0           0               0                     0<br />
Fetch   100113         1.41       1.89         78     150264          0           50093<br />
total     150179         2.55       3.02         78     150264          0           50093</p>
<p>exec implicit_interpreted( 50000 );</p>
<p>PL/SQL procedure successfully completed.</p>
<p>Elapsed: 00:00:02.48</p>
<p>call     count       cpu    elapsed       disk      query    current        rows<br />
&#8212;&#8212;- &#8212;&#8212;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-  &#8212;&#8212;&#8212;-<br />
Parse       31      0.00       0.00          0          0          0           0<br />
Execute  50035      1.00       1.05          0          0          0           0<br />
Fetch    50113      1.43       2.27         76     150267          0       50093<br />
&#8212;&#8212;- &#8212;&#8212;  &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-  &#8212;&#8212;&#8212;-<br />
total   100179      2.43       3.33         76     150267          0       50093</p>
<p>Parse ve execute aynı değerlere sahip çıktı. Elapsed süreleri  için explicit cursor’ın daha fazla çıktı. Cpu kullanımı explicit de daha fazla olduğunu gördük. İmplicit cursor daha performanslı olduğunu burda ıspatladı  Ayrıca select into yazmanın open,fetch,close yazmaya gore   kadar kolay olduğu örneğimizden de görebiliriz. Sadece sql ile yapabileceğimiz sorguları sql ile yapmalı ve  bunu pl/sql bırakmalıyız. Bu bize performans kaybı olarak dönecektir.  Daha öncede bahsetdiğimiz gibi kolay yazılıp okunan kompleks olmayan kodlar herzaman bizim için daha avantajlı olacaktır.</p>
<p>İmplicit</p>
<p>for x in ( select * from t )<br />
loop<br />
&#8230;.<br />
end loop</p>
<p>Explicit<br />
Cursor is select * from t;<br />
open c;<br />
loop<br />
fetch c into x;<br />
exit when c%notfound<br />
&#8230;.<br />
end loop;<br />
close c;</p>
<p>Yukardaki aynı işlevi yapan iki farklı cursora baktığım zaman daha öncede bahsettiğimiz yazım kolaylığı ortaya çıkıyor. Explicit cursorda bazen nerde cursor’ın açılacağını  nerde kapanacağını ya da nıasl yazılacağını unutabilirsiniz. Kısacası kompleks sorgulardan uzak durmaktan yana olacağız. İmplicit ile ilgili ilk örneğimizde birden fazla satır getirmemiz gerektiğinde  TOO_MANY_ROWS exceptionu kullanmamız gerekir demiştik. Aşağıdaki örnekleri inceleyip bu durumu tekrar gözden geçirelim.</p>
<p>Explicit cursor</p>
<p>declare<br />
l_dname  dept.dname%type;<br />
l_deptno dept.deptno%type;<br />
l_ename  emp.ename%type;</p>
<p>cursor c1<br />
is<br />
select deptno, dname<br />
from dept<br />
order by deptno;</p>
<p>cursor c2( p_deptno in number )<br />
is<br />
select ename<br />
from emp<br />
where deptno = p_deptno<br />
and sal = (select max(sal)<br />
from emp<br />
where deptno = p_deptno);<br />
begin<br />
open c1;<br />
loop<br />
fetch c1 into l_deptno, l_dname;<br />
exit when c1%notfound;<br />
open c2(l_deptno);<br />
fetch c2 into l_ename;<br />
close c2;<br />
dbms_output.put_line<br />
( l_deptno || &#8216;, &#8216; || l_dname || &#8216;, &#8216; || l_ename );<br />
end loop;<br />
close c1;<br />
end;<br />
/</p>
<p>İmplicit cursor</p>
<p>declare<br />
l_ename  emp.ename%type;<br />
begin<br />
for x in (select deptno, dname from dept order by deptno)<br />
loop<br />
begin<br />
select ename into l_ename<br />
from emp<br />
where deptno = x.deptno<br />
and sal = (select max(sal)<br />
from emp<br />
where deptno = x.deptno)<br />
and rownum = 1;<br />
exception when no_data_found<br />
then<br />
l_ename := &#8216;(none)&#8217;;<br />
end;<br />
dbms_output.put_line<br />
( x.deptno || &#8216;, &#8216; || x.dname || &#8216;, &#8216; || l_ename );<br />
end loop;<br />
end;<br />
/</p>
<p>Yukarda yazdığımız implicit cursor bu sefer birden fazla satır getirme ihtimaline karşı hata vermesine karşın rownum=1 ile tek tek getirmesini ve no_data_found ile boş satır getirmesi durumunda ne yapması gerktiğini söyledik ve böylece implicit cursor ile ilgili birden fazla satır getirirken TOO_MANY_ROWS exception kullanmamız gerektiği ve explicit cursor’ın bize daha fazla kontrol etme imkanı sunduğu gibi  ifadeleri yıkmış olduk. İmplicit cursor’ın performansını ve kullanım kolaylığını ıspatladıktan sonra artık geriye  bize implicit cursor kullanmak düşüyor.</p>
<p><strong>Using the BULK COLLECT Clause</strong></p>
<p>Yukarıda gördüğümz gibi sql ifadelerimiz çalışırken pl/sql engine ve sql engine sürekli birbirleriyle satır  transferi  halindedirler. Bulk Binding iki engine arasında satırları  transfer ederken collections(dizi veya liste) halinde gönderme olanağı sağlar. Bu da performansı artıracaktır.</p>
<p>Bulk Collect bulk binding ‘in select sorguları  için kullandığı sentaksıdır.Bulk Collect bütün satırları tek seferde  resul set olarak almamızı sağlar. Satırda istediğimiz kolonu değişkene atarak istediğimiz işlemi yapmamızı sağlar ve bunu çok hızlı bir şekilde yapar. SELECT INTO, FETCH INTO, and RETURNING INTO clauseları yardımıyla kullanabiliriz.Şimdi bir tablo yaratıp all_objects kayıtlarını alalım ve birkaç kez  defa insert  edelim.</p>
<p>create table t_all_objects as select * from all_objects;</p>
<p>insert into t_all_objects select * from t_all_objects;</p>
<p>insert into t_all_objects select * from t_all_objects;</p>
<p>Bulk</p>
<p>SQL&gt; declare<br />
2  cursor c1 is select object_name from t_all_objects;<br />
3  type c1_type is table of c1%rowtype;<br />
4  rec1 c1_type;<br />
5  begin<br />
6  open c1;<br />
7<br />
8     fetch c1 bulk collect into rec1;<br />
9<br />
10<br />
11  end;<br />
12  /</p>
<p>call     count       cpu    elapsed       disk      query       current        rows<br />
Parse       28      0.01        0.02          2             2              0               0<br />
Execute  30      0.02         0.02          0             0               0               0<br />
Fetch      84       0.97        2.47       1433         1609          0           110660<br />
total       142      1.00        2.52       1435         1611          0           110660</p>
<p>Nobulk</p>
<p>declare<br />
cursor c1 is select object_name from t_all_objects;<br />
rec1 c1%rowtype;<br />
begin<br />
open c1;<br />
loop<br />
fetch c1 into rec1;<br />
exit when c1%notfound;<br />
null;<br />
end loop;<br />
end;</p>
<p>call     count       cpu    elapsed       disk         query      current           rows<br />
Parse       14        0.01       0.01          1              1                0                 0<br />
Execute    15       0.02       0.01          0            0                0                0<br />
Fetch     98346     1.50       2.16       1259       98405          0             98338<br />
total       98375     1.53       2.19       1260         98406          0             98338</p>
<p>Yukarıda görüldüğü gibi ilk örneğimde fetch ederken bulk collect kullandım. Sql ve pl/sql engine  arasındaki row  satır interaction azaldı, fetch sayım azaldı ve daha az cpu kullanımı sağlamış oldum.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/baranipek.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/baranipek.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=24&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2007/09/21/plsql-performans/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
		<item>
		<title>Düşünelim Bakalım</title>
		<link>http://baranipek.wordpress.com/2007/09/21/dusunelim-bakalim/</link>
		<comments>http://baranipek.wordpress.com/2007/09/21/dusunelim-bakalim/#comments</comments>
		<pubDate>Fri, 21 Sep 2007 08:18:40 +0000</pubDate>
		<dc:creator>baranipek</dc:creator>
				<category><![CDATA[Zeka Soruları]]></category>

		<guid isPermaLink="false">http://baranipek.wordpress.com/2007/09/21/dusunelim-bakalim/</guid>
		<description><![CDATA[Aslında zekanın bir iki soruyla ölçülmeyeceğini düşünsemde(çok yönlü bir kavram) yinede bazı begendiğim sorular oluyor onları paylaşmak istedim.Emrehan Halıcının zeka soruları kitabından yazıcam yavşa yavaş bir-iki soruyla başlayalım sonra yazarım cevapları:) 1-)İki arkadaş bir oyun oynuyor. 10 tane şişeden sırayla 1 ya da 2 şişe alma şansınız var. Sıranızda sizde iken diğerine şişeleri alıp diğerine [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=25&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Aslında zekanın bir iki soruyla ölçülmeyeceğini düşünsemde(çok yönlü bir kavram) yinede bazı begendiğim sorular oluyor onları paylaşmak istedim.Emrehan Halıcının zeka soruları kitabından yazıcam yavşa yavaş bir-iki soruyla başlayalım sonra yazarım cevapları:)</p>
<p>1-)İki arkadaş bir oyun oynuyor. 10 tane şişeden sırayla 1 ya da 2 şişe alma şansınız var. Sıranızda sizde  iken diğerine şişeleri alıp diğerine şişe bırakmayan oyunu kazanıyor. Oyuna sizin başladığınızı düşünürseniz oyunu kazanmak için nasıl bir yol izlersiniz.</p>
<p>2-)İki arkadaş atlarını yarştırmak istiyorlar ama farklı olarak yarışmayı sonuncu kazanacaktır.İkiside başlangıç çizigisine geliyor ama yarışmayı sonuncu kazanacağı için başlamak istemiyorlar. Bu yarışmayı nasıl gerçekleştiririz o zaman?</p>
<p>3-)100 tane kartım var ve üstlerinde yazılar var. İlk kartı açtım ve üstünde &#8220;bu kartların yalnızca bir tanesi yalan söylüyor &#8221; yazıyor ikinciyi açıyorum &#8220;bu kartların yalnızca iki tanesi yalan söylüyor&#8221; yazıyor ve  yazılar açtığım kartın sırası olarak  artarak gidiyor .Peki kaçıncı kart doğru söylüyor.</p>
<p>Devamı gelecek:)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/baranipek.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/baranipek.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/baranipek.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/baranipek.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/baranipek.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/baranipek.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/baranipek.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/baranipek.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/baranipek.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/baranipek.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=baranipek.wordpress.com&amp;blog=1363712&amp;post=25&amp;subd=baranipek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://baranipek.wordpress.com/2007/09/21/dusunelim-bakalim/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1af5de744b33deae9c31d66c58af9409?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">baranipek</media:title>
		</media:content>
	</item>
	</channel>
</rss>
