<?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>Kristian Lunde &#187; Linux</title>
	<atom:link href="http://www.klunde.net/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klunde.net</link>
	<description>www.klunde.net</description>
	<lastBuildDate>Sun, 18 Jul 2010 21:00:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CentOS, where is all my memory gone?</title>
		<link>http://www.klunde.net/2010/01/15/centos-where-is-all-my-memory-gone/</link>
		<comments>http://www.klunde.net/2010/01/15/centos-where-is-all-my-memory-gone/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 22:25:03 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=478</guid>
		<description><![CDATA[
			
				
			
		
I encountered a rather strange issue on one of MySapients CentOS 5 servers the other day, the server seemed to run fine, without any issues what so ever, but it seem to run very low on memory. In fact it only had 150MB memory available of a total 4GB. 
This obviously caused me a bit [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2010%2F01%2F15%2Fcentos-where-is-all-my-memory-gone%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2010_2F01_2F15_2Fcentos-where-is-all-my-memory-gone_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2010%2F01%2F15%2Fcentos-where-is-all-my-memory-gone%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I encountered a rather strange issue on one of <a href="http://www.mysapient.com" onclick="urchinTracker('/outgoing/www.mysapient.com?referer=');">MySapients</a> CentOS 5 servers the other day, the server seemed to run fine, without any issues what so ever, but it seem to run very low on memory. In fact it only had 150MB memory available of a total 4GB. </p>
<p>This obviously caused me a bit of a worry, but after some digging around I found the answer, linux is borrowing unused memory to do disk caching. Memory is automatically reassigned when the server needs to allocate memory to other services, in other words there is nothing to worry about.</p>
<p>There is a good site about this describing this functionality in more detail, you can read it at:</p>
<p><a href="http://www.linuxatemyram.com/" onclick="urchinTracker('/outgoing/www.linuxatemyram.com/?referer=');">http://www.linuxatemyram.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2010/01/15/centos-where-is-all-my-memory-gone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My 7 things</title>
		<link>http://www.klunde.net/2009/01/22/my-7-things/</link>
		<comments>http://www.klunde.net/2009/01/22/my-7-things/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 23:34:32 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=253</guid>
		<description><![CDATA[
			
				
			
		
The 7 things have been all around the PHP community for a while now, and I got tagged by Christer a while ago. So I guess I should go around and publish my seven things:

I am an assisting nurse graduate
I have a 3 year old daughter
Expired dairy products are some of the most disgusting things [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F01%2F22%2Fmy-7-things%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F01_2F22_2Fmy-7-things_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F01%2F22%2Fmy-7-things%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The 7 things have been all around the PHP community for a while now, and I got tagged by <a href="http://cogo.wordpress.com/2009/01/04/seven-things-tagged-by-shahar-evron" onclick="urchinTracker('/outgoing/cogo.wordpress.com/2009/01/04/seven-things-tagged-by-shahar-evron?referer=');">Christer</a> a while ago. So I guess I should go around and publish my seven things:</p>
<ol>
<li>I am an assisting nurse graduate</li>
<li>I have a 3 year old daughter</li>
<li>Expired dairy products are some of the most disgusting things I know</li>
<li>I dream of some day having a small cabin by the lake, without any internet or television?!?</li>
<li>I often think about how it would be like to be the only person alive on the earth. (Something similar to the &#8220;I am legend&#8221; movie, without the zombies).</li>
<li>I took dance lessons when I was a kid, however I really suck at dancing.</li>
<li>I drink way to much Pepsi</li>
</ol>
<p>Those seven things were not really interesting at all, but it was all I could get together for now. Who knows someday I just might publish: &#8220;the top 1000 things you did not know about me&#8221; <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>My lucky seven bloggers which I tag are:</p>
<ul>
<li>Ms. Ramona Zachariassen</li>
<li><a href="http://yeknaa.wordpress.com/" onclick="urchinTracker('/outgoing/yeknaa.wordpress.com/?referer=');">Mr. Mike Parker</a></li>
<li><a href="http://www.fuselagetown.com/" onclick="urchinTracker('/outgoing/www.fuselagetown.com/?referer=');">Ms. Torunn Seim Skrogstad</a></li>
<li><a href="http://tomdancer.com/" onclick="urchinTracker('/outgoing/tomdancer.com/?referer=');">Mr. T. Dancer</a></li>
<li><a href="http://dispo.se/" onclick="urchinTracker('/outgoing/dispo.se/?referer=');">Mr. Jan-Petter Jensen</a></li>
<li><a href="http://blog.michaelodden.com/" onclick="urchinTracker('/outgoing/blog.michaelodden.com/?referer=');">Mr. Michael Odden</a></li>
<li><a href="http://thyrhaug.net" onclick="urchinTracker('/outgoing/thyrhaug.net?referer=');">Mr. Magne Thyrhaug</a></li>
</ul>
<p>Here are some rules that must be followed by anyone who decide to follow up:</p>
<p>    * Link your original tagger(s), and list these rules on your blog.<br />
    * Share seven facts about yourself in the post &#8211; some random, some wierd.<br />
    * Tag seven people at the end of your post by leaving their names and the links to their blogs.<br />
    * Let them know they’ve been tagged by leaving a comment on their blogs and/or Twitter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/01/22/my-7-things/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>2.5 applications I really miss in OS X</title>
		<link>http://www.klunde.net/2008/12/03/25-applications-i-really-miss-in-os-x/</link>
		<comments>http://www.klunde.net/2008/12/03/25-applications-i-really-miss-in-os-x/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 21:51:40 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Kate]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[TortoiseSVN]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=211</guid>
		<description><![CDATA[
			
				
			
		
In a previous post I wrote about my new life running on a MacBook Pro and OSX. It has now been over a month since I switch over to this unix hybrid, and I am quite liking it. It is very stable, I almost never turn off my mac, but I put it to sleep, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F12%2F03%2F25-applications-i-really-miss-in-os-x%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F12_2F03_2F25-applications-i-really-miss-in-os-x_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F12%2F03%2F25-applications-i-really-miss-in-os-x%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In a previous post I wrote about my new life running on a MacBook Pro and OSX. It has now been over a month since I switch over to this unix hybrid, and I am quite liking it. It is very stable, I almost never turn off my mac, but I put it to sleep, this is working fine and my last reboot is over two weeks ago. I have also gotten used to some of the new weird keys on the keyboard and the shortcuts, but I am not yet as efficent on a mac as I am/were on ubuntu/windows.  During the last few weeks I have discovered that Apple and other in most cases provide me with the applications I need, but not always, and here is the list of applications I really miss:</p>
<p>1. <a href="http://tortoisesvn.net/" onclick="urchinTracker('/outgoing/tortoisesvn.net/?referer=');">TortoiseSVN</a><br />
Windows application which integrates itself with Windows Explorer and provide a SVN client. I would say that this is the best graphical SVN client I have ever used. SVNX which I currently use on the mac is not a very good replacement.</p>
<p>2.  Kate / Notepad++<br />
<a href="http://kate-editor.org/" onclick="urchinTracker('/outgoing/kate-editor.org/?referer=');">Kate</a> is a KDE text editor for unix based systems. <a href="http://notepad-plus.sourceforge.net/uk/site.htm" onclick="urchinTracker('/outgoing/notepad-plus.sourceforge.net/uk/site.htm?referer=');">Notpad++</a> is Kates equivalent on Windows. Both editors provide a simple and intuitive user interface, and a lot of syntax highlight files for all the obscure programming languages you can think of.<br />
I know Mac have the TextMate application, but that is third party software and you have to pay €48 or something for a license, and that is probably what I probably will do. The TextMate application is really good and provide most if not all the functionality that Kate and Notepad++ provide.</p>
<p>In my desperation for a good text editor I almost went off and tried to install KDE on Mac, but that was said to be experimental and could break my entire system. So that is a no go for now. The article however was really interesting:</p>
<p>URL: <a href="http://www.simplehelp.net/2007/07/22/how-to-install-kde-4-in-os-x/" onclick="urchinTracker('/outgoing/www.simplehelp.net/2007/07/22/how-to-install-kde-4-in-os-x/?referer=');">http://www.simplehelp.net/2007/07/22/how-to-install-kde-4-in-os-x/</a>.</p>
<p>I still miss my ubuntu system and will probably go off and install parallels or vmware and ubuntu, just to have it accessible <img src='http://www.klunde.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/12/03/25-applications-i-really-miss-in-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Firefox killing the sound on my Ubuntu box</title>
		<link>http://www.klunde.net/2008/06/27/ubuntu/</link>
		<comments>http://www.klunde.net/2008/06/27/ubuntu/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 19:25:24 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[no sound]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=29</guid>
		<description><![CDATA[
			
				
			
		
Tonight I encountered a rather strange problem on my Ubuntu box. While doing nothing special on my machine, just surfing and listening to music and suddenly there are no sound?!? 
Doing a quick search on ubuntuforums.org I quickly found the solution. The problem seems to be Firefox, killing the firefox sessions and restarting the alsa-utils [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F06%2F27%2Fubuntu%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F06_2F27_2Fubuntu_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F06%2F27%2Fubuntu%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Tonight I encountered a rather strange problem on my Ubuntu box. While doing nothing special on my machine, just surfing and listening to music and suddenly there are no sound?!? </p>
<p>Doing a quick search on <a href="http://ubuntuforums.org/showthread.php?p=2742327" onclick="urchinTracker('/outgoing/ubuntuforums.org/showthread.php?p=2742327&amp;referer=');">ubuntuforums.org</a> I quickly found the solution. The problem seems to be Firefox, killing the firefox sessions and restarting the alsa-utils did the trick for me, and voila the sound is back <img src='http://www.klunde.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  </p>
<p>The howto get the sound back is found here: <a href="http://ubuntuforums.org/showthread.php?p=2742327" onclick="urchinTracker('/outgoing/ubuntuforums.org/showthread.php?p=2742327&amp;referer=');">http://ubuntuforums.org/showthread.php?p=2742327</a></p>
<p>BTW: starting firefox again did not cause any problems <img src='http://www.klunde.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/06/27/ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using GNU screen</title>
		<link>http://www.klunde.net/2008/05/27/using-gnu-screen/</link>
		<comments>http://www.klunde.net/2008/05/27/using-gnu-screen/#comments</comments>
		<pubDate>Tue, 27 May 2008 20:14:18 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[GNU]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=25</guid>
		<description><![CDATA[
			
				
			
		
Recently I&#8217;ve been the victim of a really unstable internet connection. This lack of stability has made me a great fan of the GNU screen command in unix systems.
GNU Screen is a small piece of software that lets you initiate a number of terminals inside a single terminal window. The great advantage with screen is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F05%2F27%2Fusing-gnu-screen%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F05_2F27_2Fusing-gnu-screen_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F05%2F27%2Fusing-gnu-screen%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently I&#8217;ve been the victim of a really unstable internet connection. This lack of stability has made me a great fan of the GNU screen command in unix systems.</p>
<p>GNU Screen is a small piece of software that lets you initiate a number of terminals inside a single terminal window. The great advantage with screen is that if you loose your internet connection, the screen terminals and operations inside these terminals still run on the server, contrary to operations running directly on the terminal window of your external server.</p>
<p>Screen is real simple and in most cases you only need a few important commands:</p>
<ul>
<li>starting a session</li>
<li>listing all running sessions</li>
<li>attaching to a session</li>
<li>de attaching from a session</li>
<li>killing a session</li>
</ul>
<h3>Creating a new screen session</h3>
<p><strong>Command:</strong> <em>screen</em></p>
<pre>kristian@Saturn:~$ screen </pre>
<p><strong>Example:</strong></p>
<h3>Listing all active screen sessions</h3>
<p><strong>Command:</strong><em> screen -ls</em></p>
<p><strong>Example:</strong></p>
<div class="geshi no bash">
<div class="head">kristian@Saturn:~$ screen -ls</div>
<ol>
<li class="li1">
<div class="de1">There are screens on:</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">11179</span>.pts<span class="nu0">-0</span>.Saturn <span class="br0">&#40;</span>Detached<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">11114</span>.pts<span class="nu0">-0</span>.Saturn <span class="br0">&#40;</span>Detached<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">2</span> Sockets <span class="kw1">in</span> <span class="sy0">/</span>var<span class="sy0">/</span>run<span class="sy0">/</span>screen<span class="sy0">/</span>S-kristian.</div>
</li>
</ol>
</div>
<h3>Attaching to a session</h3>
<p>If only one screen session is active the command below will take you directly to the session. If there are several sessions running the command below will display a list of running sessions. To choose one of them the screen -r command has to be followed by the session name.</p>
<p><strong>Command: </strong><em>screen -r</em></p>
<p><strong>Example of several screen sessions running:</strong></p>
<div class="geshi no bash">
<div class="head">kristian@Saturn:~$ screen -r</div>
<ol>
<li class="li1">
<div class="de1">There are several suitable screens on:</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">11179</span>.pts<span class="nu0">-0</span>.Saturn <span class="br0">&#40;</span>Detached<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">11114</span>.pts<span class="nu0">-0</span>.Saturn <span class="br0">&#40;</span>Detached<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">Type <span class="st0">&quot;screen [-d] -r [pid.]tty.host&quot;</span> to resume one of them.</div>
</li>
</ol>
</div>
<p><strong>Example of attaching to a screen session:</strong></p>
<pre lang="bash">kristian@Saturn:~$ screen -r 11179.pts-0.Saturn</pre>
<h3>De attaching from a session</h3>
<p>De attaching from a screen session is real simple just remember the key combinations <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Hold the<strong> CTRL</strong> key down, press<strong> A</strong>, then<strong> D</strong>. Thats it.</p>
<h3>Killing a screen session</h3>
<p>Killing a session is as simple as de attaching from one, just use the correct key combinations.</p>
<p>Keep the <strong>CTRL</strong> button down, press <strong>A</strong>, then <strong>K</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/05/27/using-gnu-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first introduction to java and databases</title>
		<link>http://www.klunde.net/2008/05/05/my-first-introduction-to-java-and-databases/</link>
		<comments>http://www.klunde.net/2008/05/05/my-first-introduction-to-java-and-databases/#comments</comments>
		<pubDate>Mon, 05 May 2008 20:14:57 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=9</guid>
		<description><![CDATA[
			
				
			
		
The other day I did a complete reconfiguration of java on my system. Tonight I started to play around with java and postgresql. I installed PostgreSQL 8.2 (yes I know 8.3 is out there), and downloaded the jdbc driver for PosgreSQL.
PostgreSQL
After installing PostgreSQL, you have to add a user to the authorization file pg_hba.conf located [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F05%2F05%2Fmy-first-introduction-to-java-and-databases%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F05_2F05_2Fmy-first-introduction-to-java-and-databases_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F05%2F05%2Fmy-first-introduction-to-java-and-databases%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The other day I did a complete reconfiguration of java on my system. Tonight I started to play around with java and postgresql. I installed PostgreSQL 8.2 (yes I know 8.3 is out there), and downloaded the jdbc driver for PosgreSQL.</p>
<h3>PostgreSQL</h3>
<p>After installing PostgreSQL, you have to add a user to the authorization file pg_hba.conf located in /etc/postgresql/8.x/main on a ubuntu system, remember to restart the postgreSQL server after editing pg_hba.conf. When that is done add the same user to the postgreSQL server either by using postgreSQL&#8217;s <em><strong>createuser</strong></em> function or by logging into the postgreSQL server and doing a SQL CREATE USER, I did the latter one.</p>
<div class="geshi no sql">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">CREATE</span> USER kristian <span class="kw1">WITH</span> PASSWORD <span class="st0">&#39;xxxxxxxx&#39;</span> CREATEDB;</div>
</li>
</ol>
</div>
<p>This enables me to do a regular access of the database with:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">kristian<span class="sy0">@</span>Saturn:~$ psql -U kristian crawler</div>
</li>
<li class="li1">
<div class="de1">Welcome to psql <span class="nu0">8.2</span><span class="nu0">.7</span>, the PostgreSQL interactive terminal.<span class="sy0">&lt;/</span>code<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Type: &nbsp;\copyright <span class="kw1">for</span> distribution terms</div>
</li>
<li class="li1">
<div class="de1">\h <span class="kw1">for</span> <span class="kw3">help</span> with SQL commands</div>
</li>
<li class="li1">
<div class="de1">\? <span class="kw1">for</span> <span class="kw3">help</span> with psql commands</div>
</li>
<li class="li1">
<div class="de1">\g or terminate with semicolon to execute query</div>
</li>
<li class="li1">
<div class="de1">\q to quit</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">crawler=</span><span class="co0">#</span></div>
</li>
</ol>
</div>
<p>My table:</p>
<div class="geshi no sql">
<ol>
<li class="li1">
<div class="de1">crawler<span class="sy0">=</span><span class="co2"># \d document;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">TABLE</span> <span class="st0">&quot;public.document&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">COLUMN</span> &nbsp; &nbsp; <span class="sy0">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Modifiers</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span></div>
</li>
<li class="li1">
<div class="de1">id &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">|</span> integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">|</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="kw1">NEXTVAL</span><span class="br0">&#40;</span><span class="st0">&#39;document_id_seq&#39;</span>::regclass<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">url &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">|</span> text &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">|</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span></div>
</li>
<li class="li1">
<div class="de1">document &nbsp; &nbsp; &nbsp;<span class="sy0">|</span> text &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">|</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span></div>
</li>
<li class="li1">
<div class="de1">ts_downloaded <span class="sy0">|</span> timestamp without time zone <span class="sy0">|</span> <span class="kw1">DEFAULT</span> now<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>Data in the table:</p>
<div class="geshi no sql">
<ol>
<li class="li1">
<div class="de1">crawler<span class="sy0">=</span><span class="co2"># select * from document;</span></div>
</li>
<li class="li1">
<div class="de1">id <span class="sy0">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">|</span> document <span class="sy0">|</span> &nbsp; &nbsp; &nbsp; ts_downloaded</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">1</span> <span class="sy0">|</span> http://www.klunde.net <span class="sy0">|</span> jalla &nbsp; &nbsp;<span class="sy0">|</span> <span class="nu0">2008</span><span class="nu0">-04</span><span class="nu0">-19</span> <span class="nu0">21</span>:<span class="nu0">11</span>:<span class="nu0">11.805482</span></div>
</li>
</ol>
</div>
<h3>Java</h3>
<p>First thing to get the postgreSQL jdbc driver to work is to add it to the java classpath, and of course copy the actual jar file to its correct location, for instance<em> /usr/lib/jvm/java-6-sun-1.6.0.03/jre/ext/lib/</em>which is my java library path.<br />
My classpath:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>jvm<span class="sy0">/</span>java<span class="nu0">-6</span>-sun<span class="nu0">-1.6</span><span class="nu0">.0</span><span class="nu0">.03</span><span class="sy0">/</span>lib:<span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>jvm<span class="sy0">/</span>java<span class="nu0">-6</span>-sun<span class="nu0">-1.6</span><span class="nu0">.0</span><span class="nu0">.03</span><span class="sy0">/</span>jre<span class="sy0">/</span>ext<span class="sy0">/</span>lib<span class="sy0">/</span>postgresql<span class="nu0">-8.3</span><span class="nu0">-603</span>.jdbc4.jar:.</div>
</li>
</ol>
</div>
<p>Now its about time to write some actual code:</p>
<div class="geshi no java">
<ol>
<li class="li1">
<div class="de1"><span class="co2">import java.sql.Connection;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.sql.DriverManager;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.sql.PreparedStatement;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.sql.ResultSet;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.sql.SQLException;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.sql.Statement; &lt;/code&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> DatabaseTest</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <span class="kw3">Connection</span> connection = <span class="kw2">null</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw3">String</span> USERNAME = <span class="st0">&quot;XXXXX&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw3">String</span> PASSWORD = <span class="st0">&quot;XXXXX&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw3">String</span> <span class="kw3">URL</span> = <span class="st0">&quot;jdbc:postgresql:&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw3">String</span> DATABASE = <span class="st0">&quot;crawler&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> DatabaseTest<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">try</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">connection = <span class="kw3">DriverManager</span>.<span class="me1">getConnection</span><span class="br0">&#40;</span><span class="kw3">URL</span> + DATABASE, USERNAME, PASSWORD<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">ResultSet</span> rs = doQuery<span class="br0">&#40;</span><span class="st0">&quot;SELECT * FROM document&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">rs.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">System</span>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span>rs.<span class="me1">getString</span><span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">catch</span> <span class="br0">&#40;</span><span class="kw3">SQLException</span> e<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">System</span>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;Database Exception!&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">System</span>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span>e.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw3">ResultSet</span> doQuery<span class="br0">&#40;</span><span class="kw3">String</span> sql<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">ResultSet</span> rs<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">try</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">Statement</span> stmt = connection.<span class="me1">createStatement</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">rs = stmt.<span class="me1">executeQuery</span><span class="br0">&#40;</span>sql<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">return</span> rs<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">catch</span> <span class="br0">&#40;</span><span class="kw3">SQLException</span> e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">return</span> <span class="kw2">null</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Trying to execute my script:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">kristian<span class="sy0">@</span>Saturn:~<span class="sy0">/</span>workspace<span class="sy0">/</span>crawler$ &nbsp;javac DatabaseTest.java</div>
</li>
<li class="li1">
<div class="de1">kristian<span class="sy0">@</span>Saturn:~<span class="sy0">/</span>workspace<span class="sy0">/</span>crawler$ &nbsp;java -Djdbc.<span class="re2">drivers=</span>org.postgresql.Driver DatabaseTest</div>
</li>
<li class="li1">
<div class="de1">http:<span class="sy0">//</span>www.klunde.net</div>
</li>
</ol>
</div>
<p>It works <img src='http://www.klunde.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  The installation and initial setup went pretty much by the book, but as a PHP developer I must say that I&#8217;m a little bit disappointed, JDBC cannot compare itself to the PHP PDO extension yet. But then again, maybe I just need to get to know the JDBC library better. Anyhow it was fun writing this little java app and refreshing some of my java skills.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/05/05/my-first-introduction-to-java-and-databases/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java on Ubuntu</title>
		<link>http://www.klunde.net/2008/05/02/java-on-ubuntu/</link>
		<comments>http://www.klunde.net/2008/05/02/java-on-ubuntu/#comments</comments>
		<pubDate>Fri, 02 May 2008 08:04:35 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=11</guid>
		<description><![CDATA[
			
				
			
		
The other day I decided that it was about time to refresh my java knowledge. I&#8217;ve done some java development at work lately, but besides that It has been about 3 years since I last wrote any decent java apps. I have a few ideas of some small cool apps I want to write, but [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F05%2F02%2Fjava-on-ubuntu%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F05_2F02_2Fjava-on-ubuntu_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F05%2F02%2Fjava-on-ubuntu%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The other day I decided that it was about time to refresh my java knowledge. I&#8217;ve done some java development at work lately, but besides that It has been about 3 years since I last wrote any decent java apps. I have a few ideas of some small cool apps I want to write, but first of all I had to check the java installation on my machine.</p>
<p>Im currently sitting on a Ubuntu 7.04 installation, so I started out by opening my console and typing<br />
<code><br />
java -version<br />
</code></p>
<p>I was a bit surprised about the result, java version could not be determined, I found out that 4 different versions of java were installed and neither the classpath or java_home were set. The java version I wished to used were not among the installed versions. I used the java installation guide on <a href="https://help.ubuntu.com/community/JavaInstallation" onclick="urchinTracker('/outgoing/help.ubuntu.com/community/JavaInstallation?referer=');">help.ubuntu.com</a> to install my preferred java version, the java 6 version from Sun. The guide was straight forward and the java installation seemed to work as expected after completing the guide.</p>
<p><code><br />
kristian@Saturn:/usr/lib$ java -version<br />
java version "1.6.0_03"<br />
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)<br />
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)<br />
</code></p>
<p>Looking good. So I tried typing:</p>
<p><code><br />
kristian@Saturn:/usr/lib$ javac -version<br />
javac: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory<br />
</code></p>
<p>Not looking that good, something was wrong <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  I googled the result and found my mistake. Earlier while I was trying to get it all together with the 4 different java versions I changed the symlink in<em><strong> /usr/bin/</strong></em> and I forgot to add the <strong><em>-s</em></strong> when I created the link. Removing the symblink and recreating it did the trick.</p>
<p><code><br />
kristian@Saturn:/usr/bin$ sudo ln -s /etc/alternatives/javac javac<br />
</code></p>
<p>The javac in /etc/alternatives is a symblink to the current java version. And  trying the all famous <em><strong>javac -version</strong></em> now result in the anticipated result:</p>
<p><code><br />
kristian@Saturn:~$ javac -version<br />
javac 1.6.0_03<br />
</code></p>
<p>Now I&#8217;m all set to go and try out my java skills <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/05/02/java-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>yes</title>
		<link>http://www.klunde.net/2008/04/18/yes/</link>
		<comments>http://www.klunde.net/2008/04/18/yes/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 13:10:11 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=3</guid>
		<description><![CDATA[
			
				
			
		
Ever tried to replace a bunch of files with  cp -rf some/destination . in linux?
Then you might have had to do a number &#8216;y&#8217; to confirm the replacement of the already existing files, pretty annoying. Well linux has this marvelous little tool called yes, which automate this process and adds a y after the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F04%2F18%2Fyes%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F04_2F18_2Fyes_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F04%2F18%2Fyes%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Ever tried to replace a bunch of files with  <em><strong>cp -rf some/destination </strong>. </em>in linux?</p>
<p>Then you might have had to do a number &#8216;y&#8217; to confirm the replacement of the already existing files, pretty annoying. Well linux has this marvelous little tool called yes, which automate this process and adds a y after the prompt when replacing a file.</p>
<p>if you just try to type <strong><em>yes </em></strong>in your console you will see that it starts printing &#8216;y&#8217;.</p>
<p>so this is how you actually do it:</p>
<p><em><strong>yes cp -r some/directory/* .</strong></em></p>
<p>For more information type <strong><em>man yes</em></strong> in your concole.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/04/18/yes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
