<?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>Talkwards &#187; Computers and Internet</title>
	<atom:link href="http://www.talkwards.com/category/computers-and-internet/feed" rel="self" type="application/rss+xml" />
	<link>http://www.talkwards.com</link>
	<description>Advancing Talkwards...</description>
	<lastBuildDate>Sat, 03 Sep 2011 16:33:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How do you log to the Windows event log from C# .NET?</title>
		<link>http://www.talkwards.com/2011/05/how-do-you-log-to-the-windows-event-log-from-c-net</link>
		<comments>http://www.talkwards.com/2011/05/how-do-you-log-to-the-windows-event-log-from-c-net#comments</comments>
		<pubDate>Tue, 17 May 2011 11:34:50 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computers and Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=611</guid>
		<description><![CDATA[This seems to do the trick: private void logError(string message, string source) { System.Diagnostics.EventLog log = new System.Diagnostics.EventLog(); log.Source = source; log.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error); log.Close(); } private void logError(Exception exception, string source) { logError(exception.ToString(), source); } Put it in your class, or in a special logging class. Read more: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=77 http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx I might add that the [...]]]></description>
			<content:encoded><![CDATA[<p>This seems to do the trick:</p>
<pre style="padding-left: 30px;">private void logError(string message, string source)
{
	System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
	log.Source = source;
	log.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error);
	log.Close();
}

private void logError(Exception exception, string source)
{
	logError(exception.ToString(), source);
}</pre>
<p>Put it in your class, or in a special logging class.</p>
<p>Read more:</p>
<ul>
<li><a href="http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=77" target="_blank">http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=77</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx</a><br />
I might add that the comment about latency when creating event log sources <em>does not</em> seem to apply on Windows 2008 Server (where I tested the above code &#8211; which doesn&#8217;t even create a source&#8230; ummm)</li>
<li><a href="http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx" target="_blank">http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx</a></li>
</ul>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">
<table border="0" cellspacing="0" frame="VOID" rules="NONE">
<colgroup>
<col width="199"></col>
<col width="234"></col>
<col width="161"></col>
<col width="300"></col>
</colgroup>
<tbody>
<tr>
<td width="199" height="18" align="LEFT" valign="TOP">Internt/Egna</td>
<td width="234" align="LEFT" valign="TOP">SharePoint – Miniprojekt</td>
<td width="161" align="LEFT" valign="TOP">Utveckling/Design</td>
<td width="300" align="LEFT" valign="TOP">Lookup fält programmagiskt&#8230; / ContentTypes</td>
</tr>
</tbody>
</table>
</div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2011%2F05%2Fhow-do-you-log-to-the-windows-event-log-from-c-net&amp;title=How%20do%20you%20log%20to%20the%20Windows%20event%20log%20from%20C%23%20.NET%3F" id="wpa2a_2"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2011/05/how-do-you-log-to-the-windows-event-log-from-c-net/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Java pass-by-value or pass-by-reference?</title>
		<link>http://www.talkwards.com/2009/07/is-java-pass-by-value-or-pass-by-reference</link>
		<comments>http://www.talkwards.com/2009/07/is-java-pass-by-value-or-pass-by-reference#comments</comments>
		<pubDate>Fri, 17 Jul 2009 23:00:14 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=564</guid>
		<description><![CDATA[The question if Java passes parameters by value or by reference seems to be one of the things newcomers to the Java language stumble upon quite often. In general the answer is simple: Java is always pass-by-value. What does this mean? Pass-by-value means that you get a copy of the passed in object to work [...]]]></description>
			<content:encoded><![CDATA[<p>The question if Java passes parameters<em> by value</em> or <em>by reference</em> seems to be one of the things newcomers to the Java language stumble upon quite often.</p>
<p>In general the answer is simple: <strong>Java is always pass-by-value</strong>.</p>
<p>What does this mean?</p>
<p>Pass-by-value means that you get a <em>copy</em> of the passed in object to work with, as opposed to a reference to it.</p>
<p>Let&#8217;s exemplify.  Assume we have a method that manipulates a List object:</p>
<blockquote>
<pre>public void updateList(List list) {</pre>
<pre>    ..;</pre>
<pre>}</pre>
</blockquote>
<p>Now, assume we&#8217;d like to replace the passed-in list with another list we&#8217;ve created inside the method.  We might like to do something like:</p>
<blockquote>
<pre>public void updateList(List list) {</pre>
<pre>    List myList = new ArrayList();</pre>
<pre>    // add objects to myList</pre>
<pre>    list = myList; // replace list with my new list? <strong>*WRONG*</strong></pre>
<pre>}</pre>
</blockquote>
<p>However, if we test this new method we&#8217;ll find <strong>list</strong> has not changed at all.</p>
<p>This is because <strong>list</strong> is a copy of the object we passed-in to the method, and not the passed-in object itself.  <strong>list</strong> has been passed-by-value!</p>
<p>So, are we unable to change variables that are passed-in to a method in Java?  Can we only change them by returning a new object?</p>
<p>No.</p>
<p>And this is where the confusion sets in, because while we&#8217;re unable to replace the passed-in object <strong>list</strong> with another object, we&#8217;re perfectly allowed to <em>manipulate it&#8217;s member objects.</em></p>
<p>Basically this means if we want to replace a passed-in list with our own list we <em>must </em>do:</p>
<blockquote>
<pre>public void updateList(List list) {</pre>
<pre>    List myList = new ArrayList();</pre>
<pre>    // add objects to myList</pre>
<pre>    list.clear(); // empty passed-in list</pre>
<pre>    list.addAll(myList); // replace passed-in list with my new list!</pre>
<pre>}</pre>
</blockquote>
<p>Since we never try to replace <strong>list</strong><em> itself</em>, the whole method works just fine and does what we expect.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2009%2F07%2Fis-java-pass-by-value-or-pass-by-reference&amp;title=Is%20Java%20pass-by-value%20or%20pass-by-reference%3F" id="wpa2a_4"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2009/07/is-java-pass-by-value-or-pass-by-reference/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Black pointer: Never lose track of your mouse pointer again</title>
		<link>http://www.talkwards.com/2009/07/black-pointer-never-lose-track-of-your-mouse-pointer-again</link>
		<comments>http://www.talkwards.com/2009/07/black-pointer-never-lose-track-of-your-mouse-pointer-again#comments</comments>
		<pubDate>Fri, 10 Jul 2009 23:00:12 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computer Operating Systems]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=553</guid>
		<description><![CDATA[I&#8217;ve tried several ways to keep track of my mouse pointer.  It&#8217;s kind of hard from time to time.  Adding more than one monitor does not help at all! Recently a colleague gave me the tip to make the mouse pointer black&#8230; and larger. I tried this and found that the mouse pointer was much [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve tried several ways to keep track of my mouse pointer.  It&#8217;s kind of hard from time to time.  Adding more than one monitor does not help at all!</p>
<p>Recently a colleague gave me the tip to make the mouse pointer black&#8230; and larger. I tried this and found that the mouse pointer was much easier to spot.  No surprise there, really.  After all, white on white tends to become a bit hard to keep track of, tiny silhouette outline or not.</p>
<p>I was told how to do this in Windows (Control Panel &gt; Mouse &gt; Pointer, but that&#8217;s another story).</p>
<p>In Gnome (I&#8217;m running Ubuntu 8.10) you do it in the System &gt; Preferences &gt; Appearance dialog (see below).  In my version of Window&#8217;s there&#8217;s no settings under Appearance &gt; Mouse.</p>
<p><img class="alignnone size-medium wp-image-555" title="Appearance Preferences" src="http://www.talkwards.com/wp-content/uploads/2009/07/appearance-preferences-300x267.png" alt="Appearance Preferences" width="300" height="267" /></p>
<p>Next you click the &#8220;Customize&#8221; button:</p>
<p><img class="alignnone size-medium wp-image-556" title="Customize Theme" src="http://www.talkwards.com/wp-content/uploads/2009/07/customize-theme-225x300.png" alt="Customize Theme" width="225" height="300" /></p>
<p>In the new dialog select the &#8220;Pointer&#8221;-tab and select the color of pointer you want.  In order to resize it, see the &#8220;size slider&#8221; below the list of pointers (there seems to be three distinct sizes to choose from).</p>
<p>Click &#8220;Close&#8221; once you&#8217;re done, and voila, you have a new and much easier to spot mouse pointer!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2009%2F07%2Fblack-pointer-never-lose-track-of-your-mouse-pointer-again&amp;title=Black%20pointer%3A%20Never%20lose%20track%20of%20your%20mouse%20pointer%20again" id="wpa2a_6"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2009/07/black-pointer-never-lose-track-of-your-mouse-pointer-again/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sun Tzu&#8217;s Art of War &#8211; Agile&#8230;</title>
		<link>http://www.talkwards.com/2009/06/sun-tzus-art-of-war-agile</link>
		<comments>http://www.talkwards.com/2009/06/sun-tzus-art-of-war-agile#comments</comments>
		<pubDate>Fri, 05 Jun 2009 23:00:59 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[agile programming]]></category>
		<category><![CDATA[programming practices]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=541</guid>
		<description><![CDATA[A quote from the Art of War that might have some baring on Agile development techniques: 31. Water shapes its course according to the nature of the ground over which it flows; the soldier works out his victory in relation to the foe whom he is facing. 32. Therefore, just as water retains no constant [...]]]></description>
			<content:encoded><![CDATA[<p>A quote from the Art of War that might have some baring on Agile development techniques:</p>
<blockquote><p>31. Water shapes its course according to the nature<br />
of the ground over which it flows; the soldier works<br />
out his victory in relation to the foe whom he is facing.</p>
<p>32. Therefore, just as water retains no constant shape,<br />
so in warfare there are no constant conditions.</p></blockquote>
<p>But then again, we all know war is agile, right?</p>
<p>Or another quote I heard (source unknown, original language Swedish):</p>
<blockquote><p>Meeting all requirements in programming is like walking on water.  It&#8217;s easy if the water and the requirements are frozen&#8230;</p></blockquote>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2009%2F06%2Fsun-tzus-art-of-war-agile&amp;title=Sun%20Tzu%26%238217%3Bs%20Art%20of%20War%20%26%238211%3B%20Agile%26%238230%3B" id="wpa2a_8"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2009/06/sun-tzus-art-of-war-agile/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random thought: Windows disproves Darwinism</title>
		<link>http://www.talkwards.com/2009/02/random-thought-windows-disproves-darwinism</link>
		<comments>http://www.talkwards.com/2009/02/random-thought-windows-disproves-darwinism#comments</comments>
		<pubDate>Mon, 09 Feb 2009 11:43:09 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computers and Internet]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[sarcasm]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=495</guid>
		<description><![CDATA[Microsoft Windows is the unique case that disproves Darwin&#8217;s theories of natural evolution and survival of the fittest while at the same time supplying no support for the main theory opposing Darwinism, the so called Intelligent Design Theory.  It is obvious the existence of a system such as Microsoft Windows is the work of a [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft Windows is the unique case that disproves Darwin&#8217;s theories of natural evolution and survival of the fittest while at the same time supplying no support for the main theory opposing Darwinism, the so called Intelligent Design Theory.  It is obvious the existence of a system such as Microsoft Windows is the work of a deity.  In this case an inherently chaotic and evil one; we usually refer to it as the Devil.</p>
<p>Mmm&#8230; wonder if I may be able to do a thesis on that, just wonder if it should be in the religion or computer science department&#8230; <img src='http://www.talkwards.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2009%2F02%2Frandom-thought-windows-disproves-darwinism&amp;title=Random%20thought%3A%20Windows%20disproves%20Darwinism" id="wpa2a_10"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2009/02/random-thought-windows-disproves-darwinism/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARVA: A Java Windowing Toolkit for Text Terminals</title>
		<link>http://www.talkwards.com/2008/11/charva-a-java-windowing-toolkit-for-text-terminals</link>
		<comments>http://www.talkwards.com/2008/11/charva-a-java-windowing-toolkit-for-text-terminals#comments</comments>
		<pubDate>Fri, 28 Nov 2008 22:00:54 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[command-line]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[user interface (ui)]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=430</guid>
		<description><![CDATA[Looking around for an easy way to create applications with text GUIs for running over SSH terminals I came across CHARVA. CHARVA&#8217;s API copies Swings, it unfortunately is not built on top of Swing but is a copy of Swing. This forces implementers to import classes in the charva.awt and charvax.swing packages instead of traditional [...]]]></description>
			<content:encoded><![CDATA[<p>Looking around for an easy way to create applications with text GUIs for running over SSH terminals I came across <a href="http://www.pitman.co.za/projects/charva/index.html" target="_blank">CHARVA</a>. CHARVA&#8217;s API copies Swings, it unfortunately is not built on top of Swing but is a copy of Swing.  This forces implementers to import classes in the charva.awt and charvax.swing packages instead of traditional awt and swing classes.  However, the result is rather nice, at least if you&#8217;re looking to run applications off a server on a simple Point-of-Sale or Point-of-Service (POS) terminal that may not even support graphics.</p>
<p>In my case I&#8217;m looking into making a simple app that I can use to keep track of passwords, both when I&#8217;m at home (regular swing) and when I&#8217;m away (at work or similar) and only able to access the application via SSH (CHARVA).</p>
<p>For more info, check out CHARVA here: <a href="http://www.pitman.co.za/projects/charva/index.html" target="_blank">http://www.pitman.co.za/projects/charva/index.html</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F11%2Fcharva-a-java-windowing-toolkit-for-text-terminals&amp;title=CHARVA%3A%20A%20Java%20Windowing%20Toolkit%20for%20Text%20Terminals" id="wpa2a_12"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/11/charva-a-java-windowing-toolkit-for-text-terminals/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling to different versions of Java in Eclipse</title>
		<link>http://www.talkwards.com/2008/11/compiling-to-different-versions-of-java-in-eclipse</link>
		<comments>http://www.talkwards.com/2008/11/compiling-to-different-versions-of-java-in-eclipse#comments</comments>
		<pubDate>Fri, 21 Nov 2008 22:00:50 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computer Architecture]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache Tomcat]]></category>
		<category><![CDATA[configuration management]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[runtime errors]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=440</guid>
		<description><![CDATA[I&#8217;ve just had the rather unsettling experience of trying to deploy a new jar file (one I recompiled after some changes). This file were to be deployed on a rather old set up of Java 1.4.2. On first try everything broke with the classic &#8220;Unsupported major.minor version 50.0&#8243;. So I went back to the drawing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just had the rather unsettling experience of trying to deploy a new jar file (one I recompiled after some changes).  This file were to be deployed on a rather old set up of Java 1.4.2.  On first try everything broke with the classic &#8220;Unsupported major.minor version 50.0&#8243;.</p>
<p>So I went back to the drawing board.  I installed java 1.4, and made sure my development Tomcat was running it.  Then I did some research and found out how to make Eclipse compile 1.4 compliant code.  I started and I got the same error still.</p>
<p>Once I figured out what was wrong I realized I was an idiot (Doh!).  The error I&#8217;ve gotten wasn&#8217;t for any file part of the jar I was trying to deploy but for &#8220;index_jsp&#8221;.  The thing is my Tomcat compiled my JSP:s into class files and never looked at them again until they were changed.  I am sure there&#8217;s several ways to solve the problem, I just went and deleted the files in the &#8220;work&#8221;-directory (those pertaining to my Context).</p>
<div id="attachment_442" class="wp-caption alignright" style="width: 310px"><a href="http://www.talkwards.com/wp-content/uploads/2008/11/eclipse-source-target-versions.png"><img class="size-medium wp-image-442" title="The Eclipse preferences window" src="http://www.talkwards.com/wp-content/uploads/2008/11/eclipse-source-target-versions-300x269.png" alt="The preferences window for setting source and target versions for java compilation" width="300" height="269" /></a><p class="wp-caption-text">The preferences window for setting source and target versions for Java compilation</p></div>
<p>Now over to how to make Eclipse code projects to a certain Java version.</p>
<p>There are two values you will want to keep track of.  The source version and the target version.  The source version tells what version your source code is written in.  Whereas the target version tells what version of Java you want your class files in.</p>
<p>If for instance you have a project written in Java 1.4 source style, but you have to run it on a Java 5 you&#8217;d set the source version to 1.4 and the target to 1.5. You are now compiling Java 1.4 source into Java 5 class files.  Unfortunately you&#8217;re not able to do the opposite, compile Java 5 source code into Java 1.4 class files.  This is probably due to API incompatibilities, Java 5 has a larger API than Java 1.4.</p>
<p>Now, in Eclipse you have two settings in three places that controls the source and target versions of your compilations.  Under Window-&gt;Preferences-&gt;Java-&gt;Compiler (Eclipse 3.4) you&#8217;re able to set the versions for the whole IDE.</p>
<p>When you create a new project you&#8217;re able to determine what version of Java (source and target you want) and right clicking on a project and choosing Properties-&gt;Java Compiler, you have the same dialog as before.</p>
<p>You set the target level in the select box &#8220;Compiler compliance level&#8221;, and optionally by unchecking the &#8220;Use default compliance settings&#8221; you&#8217;re able to change the target (&#8220;Generated .class files compatibility&#8221;) and source respectively.</p>
<p>If you experience other problems you may want to &#8220;clean&#8221; your project(s).  Cleaning a project means all compiled files are removed and all source files are recompiled (something the IDE will do by itself when you change compilation versions, but if you want to be sure, you can do it manually).  This is done by choosing Project-&gt;Clean.  In the dialog you can chose to clean all projects or just those you select.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F11%2Fcompiling-to-different-versions-of-java-in-eclipse&amp;title=Compiling%20to%20different%20versions%20of%20Java%20in%20Eclipse" id="wpa2a_14"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/11/compiling-to-different-versions-of-java-in-eclipse/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Injections, the two most common types</title>
		<link>http://www.talkwards.com/2008/11/sql-injections-the-two-most-common-types</link>
		<comments>http://www.talkwards.com/2008/11/sql-injections-the-two-most-common-types#comments</comments>
		<pubDate>Fri, 14 Nov 2008 22:00:03 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computer Architecture]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL-injections]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=434</guid>
		<description><![CDATA[What is an SQL-injection. How can it affect my site. How does it happen and how can I avoid it? Since Firefox (2 and 3) and MSIE 7 started using Google&#8217;s (and others) system for blocking sites that produce harmful web pages the problem with SQL-injections have been put on the spot. What happens is [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_471" class="wp-caption alignright" style="width: 310px"><a href="http://www.talkwards.com/wp-content/uploads/2008/11/reported-attack-site.png"><img class="size-medium wp-image-471" title="Reported Attack Site" src="http://www.talkwards.com/wp-content/uploads/2008/11/reported-attack-site-300x203.png" alt="Opening a site Google has listed as spreading malicious software via the browser." width="300" height="203" /></a><p class="wp-caption-text">Opening a site Google has listed as spreading malicious software via the browser.</p></div>
<p>What is an SQL-injection.  How can it affect my site.  How does it happen and how can I avoid it?</p>
<p>Since Firefox (2 and 3) and MSIE 7 started using Google&#8217;s (and others) system for blocking sites that produce harmful web pages the problem with SQL-injections have been put on the spot.</p>
<p>What happens is that an attacker hacks a site by placing their own SQL-code into the database of the victim system.  Instead of just performing a DOS (<a href="http://en.wikipedia.org/wiki/Denial_of_service" target="_blank">denial of service</a>) attack bringing the whole site down by for instance deleting all the tables or doing something else harmful to the site the attacker plants client side browser code in the database making all visitors run client side code that will infect their computer with a virus.  This virus may do everything from listening in on traffic between the client (web browser) and bank applications, to connecting the client system to a <a href="http://en.wikipedia.org/wiki/Bot_net" target="_blank">botnet</a>.</p>
<p>Needless to say, the SQL-injection attack has become a problem not so much for the owner of the originally defunct site as for the visitors to said site.  (Although users of the web should not underestimate the consequence of a good virus protection, system update policy and secure browsing policy).</p>
<p>Since the owner of the vulnerable software won&#8217;t notice any detour from business as usual (and neither will most infected clients), nobody is the wiser to the problem.</p>
<p>This is why Google (and others) have started evaluating (and flagging) sites with bad content, and why Firefox and MSIE (and probably others) have started blocking them.</p>
<p><span id="more-434"></span></p>
<h4>What is an SQL-injection?</h4>
<p>The short explanation (hinted above) is that an <a href="http://en.wikipedia.org/wiki/SQL_injection" target="_blank">SQL-injection</a> is an attack where the attacker inserts their own SQL code into the attacked system, and thus alters the database content of the attacked system.  Either wrecks havoc by destroying part of or the whole system, or by inserting virus spreading code onto the pages of the attacked site (if their content is stored in the database).</p>
<h4>How is an SQL-injection attack performed?</h4>
<p>There are two major ways of doing this (and in order to follow this part of the conversation you will need to know a bit of SQL).</p>
<p>The first method of performing an SQL-injection is by manipulating the input to different kinds of forms on the site (search forms, contact forms, and other places where the user can put information into the system).</p>
<p>To understand this attack you need a basic understanding of SQL.</p>
<p>Imagine we have a database table with products, each having a color, and we want to list all products that are &#8216;green&#8217;.  This would be done with the following question:</p>
<blockquote>
<pre>SELECT * FROM products WHERE color = 'green';</pre>
</blockquote>
<p>Each database command is ended with a semicolon (;), and all literal strings are enclosed by single quotes (&#8216;).  So issuing two commands in a row would look something like:</p>
<blockquote>
<pre>SELECT * FROM products WHERE color = 'green';
UPDATE products SET hasBeenSearchedFor = 'true' WHERE color = 'green';</pre>
</blockquote>
<p>Notice the semicolons and the single quotes.  You do not need to understand what the commands do in order to understand the rest.</p>
<p>Now imagine that we get the value &#8216;green&#8217; from an application the user can input data into.  As long as the user types things like green, red, blue everything is safe, but what would happen if the user typed in the following as a color?</p>
<blockquote>
<pre>'; do harmful thing to database; '</pre>
</blockquote>
<p>In an unprotected system the SQL-string is usually tacked together one part after the other without checking if the search parameter is valid or sane.  Imagine the search command is built in the following way (double quotes are used in most systems to create strings, they are not to be confused with the single quotes of the database query):</p>
<blockquote>
<pre>sql = "SELECT * FROM products WHERE color = '" + colorValue + "'";</pre>
</blockquote>
<p>Now if a user would put the above value into the color search (placing it in &#8220;colorValue&#8221;) the value of the sql string (and what would be passed on to the database would be):</p>
<blockquote>
<pre>"SELECT * FROM products WHERE color = '" +
          "'; do harmful thing to database; '" + "'"</pre>
</blockquote>
<p>This in turn would evaluate to:</p>
<blockquote>
<pre>SELECT * FROM products WHERE color = ''; do harmful thing to database; ''</pre>
</blockquote>
<p>I.e. select all products with an empty color value, then &#8220;do harmful thing to database&#8221;.  After that the SQL-server will encounter the empty quotes and issue an error.</p>
<p>If the database question is executed in a transaction all changes will be rolled back, however this is a rather weak defense against SQL-injections since it is possible to input values that will create three valid commands easily.  (I&#8217;ll leave that up to the fantasy of the reader!)</p>
<p>The second way of performing an SQL-injection attack is to tack on values to numerical input to the system.  Pages that display products, user profiles, or any other information easily mapped to a row in a database table are usually candidates for this kind of attack.</p>
<p>Imagine a page that displays a product profile.  It might be called with the following URL:</p>
<blockquote>
<pre>http://www.mysite.com/showProduct?productid=123</pre>
</blockquote>
<p>The &#8220;productid&#8221; value will then be passed on to make the following database question:</p>
<blockquote>
<pre>sql = "SELECT * FROM products WHERE id = " + productid;</pre>
</blockquote>
<p>Here the attacker does not even have to add a single quote to get an extra SQL-command.  All they need to do is add a trailing &#8220;;&#8221; and they&#8217;re in.  The only complicating factor is that the URL used to call the system will have to be URL-encoded in order for this attack to work, but that&#8217;s far from a problem even for an unskilled attacker.</p>
<h4>How do you protect against SQL-injections?</h4>
<p>The key concept is: never, NEVER, <strong>NEVER</strong>, trust input from a user!</p>
<p>That&#8217;s right.  NEVER TRUST THE USER.</p>
<p>Don&#8217;t ask what-if a user tries to gain access to our system.</p>
<p>Say WHEN the user tries to gain access to our system, then we&#8217;re gonna&#8230;.</p>
<p>The short, technical answer (for Java, .NET and similar languages) is to NEVER build SQL-strings like shown above.  Use &#8220;prepared statements&#8221; or similar constructs where the input variables can be tested by JDBC (or ADODB or LINQ or similar framworks).</p>
<p>Another safe way to go is to use stored procedures.  These are not just optimized for speed and performance, they are also, almost always strongly typed, disallowing the kind of problems displayed above.</p>
<p>If neither of these are feasible always make sure the input&#8217;s single quotes are filtered away or &#8220;escaped&#8221;.  Escaping a single quote means that all databases have support for using single quotes as values in a table column, if you prepend them with a backslash (\) or use double single quotes (&#8221;, that&#8217;s two single quotes).  Do this programatically before sending the data on to the database.</p>
<p>Protecting against attacks on pages with numerical input is even simpler.  If there&#8217;s a number input value, make sure it is numerical by translating it into a number before passing it on to the database (input from web applications are almost always sent as strings, but if a value should be a number, make sure it is!)</p>
<p>Part from this a sound backup and restore policy is a sure way to not only protect hours of time invested in putting information into the system but the users trust in the system, and the time it will take to get a blocked site back up on its feet.</p>
<p>Read more about SQL-injections here: <a href="http://en.wikipedia.org/wiki/SQL_injection" target="_blank">http://en.wikipedia.org/wiki/SQL_injection</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F11%2Fsql-injections-the-two-most-common-types&amp;title=SQL%20Injections%2C%20the%20two%20most%20common%20types" id="wpa2a_16"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/11/sql-injections-the-two-most-common-types/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search and Replace in MySQL</title>
		<link>http://www.talkwards.com/2008/11/search-and-replace-in-mysql</link>
		<comments>http://www.talkwards.com/2008/11/search-and-replace-in-mysql#comments</comments>
		<pubDate>Fri, 07 Nov 2008 22:00:24 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[DBMS]]></category>
		<category><![CDATA[DML]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=417</guid>
		<description><![CDATA[I&#8217;ve come across a problem in one of my projects at work. It consists of searching and replacing data in a MySQL server. The data to be replaced is an old URL used in lots of text fields all over the place, it is the customers own site URL but since they moved, they now [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve come across a problem in one of my projects at work.  It consists of searching and replacing data in a MySQL server.  The data to be replaced is an old URL used in lots of text fields all over the place, it is the customers own site URL but since they moved, they now want all URLs to point to their new location.</p>
<p>Searching the web and checking up the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace" target="_blank">MySQL function database</a> returns the following useful command:</p>
<blockquote>
<pre>REPLACE(str, from_str, to_str)</pre>
</blockquote>
<p>It would in my case be used like this:</p>
<blockquote>
<pre>UPDATE myTable SET theTextField =
REPLACE(theTextField, 'http://the.old.site', 'http://the.new.site');</pre>
</blockquote>
<p><code>myTable</code> is the table containing the data I want to replace, <code>theTextField</code> is the exact field in which this data is located.  Obviously &#8220;http://the.old.site&#8221; is the existing information, that I want to replace, and &#8220;http://the.new.site&#8221; is the information this string should be replaced with.</p>
<p>Very simple, very elegant.  Now all I have to do is try it out as well.  (Expect more reports on the progress of this work!)</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F11%2Fsearch-and-replace-in-mysql&amp;title=Search%20and%20Replace%20in%20MySQL" id="wpa2a_18"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/11/search-and-replace-in-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change a lost MS SQL Server password</title>
		<link>http://www.talkwards.com/2008/11/how-to-retrieve-a-lost-ms-sql-server-password</link>
		<comments>http://www.talkwards.com/2008/11/how-to-retrieve-a-lost-ms-sql-server-password#comments</comments>
		<pubDate>Fri, 31 Oct 2008 22:00:55 +0000</pubDate>
		<dc:creator>Hoakz</dc:creator>
				<category><![CDATA[Computer Applications and Programs]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://www.talkwards.com/?p=409</guid>
		<description><![CDATA[I recently lost the password to the MS SQL Server installed on my local machine. A search on possible solutions returned the usual business B$ about paying for software to do the job. However, browsing a little deeper and asking a colleague gave me the following handy solution: Log in to the machine where the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently lost the password to the MS SQL Server installed on my local machine.  A search on possible solutions returned the usual business B$ about paying for software to do the job.  However, browsing a little deeper and asking a colleague gave me the following handy solution:</p>
<ol>
<li>Log in to the machine where the SQL Server is installed via Remote Desktop (not needed in my case, since it was my local machine).</li>
<li>Start SQL Server client (Microsoft SQL Managment Studio) and log in to the local machine using Windows Authentication.</li>
<li>You&#8217;re in.</li>
<li>(Optionally) With your admin account you can now change the password to something you&#8217;ll remember this time! ;o)</li>
</ol>
<p>1) You find Remote Desktop on the Start Menu in &#8220;All Programs &gt; Accessories &gt; Remote Desktop Connection&#8221;.  Most windows servers will have Remote Desktop installed from the start.  If, however you are refused a connection because too many people are logged in, <a href="?p=282" target="_self">see my previous post about how to solve that problem</a>.</p>
<div id="attachment_410" class="wp-caption alignright" style="width: 310px"><a href="http://www.talkwards.com/wp-content/uploads/2008/10/sql-server-login.png"><img class="size-medium wp-image-410" title="SQL Server login dialog" src="http://www.talkwards.com/wp-content/uploads/2008/10/sql-server-login-300x222.png" alt="Logging in to the local database using Windows authentication in SQL Server Management Studio." width="300" height="222" /></a><p class="wp-caption-text">Logging in to the local database using Windows authentication in SQL Server Management Studio.</p></div>
<p>2) To log in on the local database first open SQL Management Studio (All Programs &gt; Microsoft SQL Server 2005 &gt; SQL Server Management Studio), select the name of the local computer in the &#8220;Server name&#8221;-text field and select &#8220;Windows Authentication&#8221; in the &#8220;Authentication&#8221;-text field.  Your user name (the one you used to log in via Remote Desktop) will be displayed in the &#8220;User name&#8221;-text field and this field and the &#8220;Password&#8221;-text field will both be disabled.  Click connect and you should be logged in as an administrator.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.talkwards.com%2F2008%2F11%2Fhow-to-retrieve-a-lost-ms-sql-server-password&amp;title=How%20to%20change%20a%20lost%20MS%20SQL%20Server%20password" id="wpa2a_20"><img src="http://www.talkwards.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.talkwards.com/2008/11/how-to-retrieve-a-lost-ms-sql-server-password/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

