<?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>devbox@COMPUTEC</title>
	<atom:link href="http://devbox.computec.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://devbox.computec.de</link>
	<description>The Computec development blog</description>
	<lastBuildDate>Tue, 24 Aug 2010 08:45:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='devbox.computec.de' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>ColdFusion vs. Railo on &lt;cftransaction action=&#8221;rollback&#8221;&gt;</title>
		<link>http://devbox.computec.de/2010/08/coldfusion-vs-railo-on-cftransaction-actionrollback/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-vs-railo-on-cftransaction-actionrollback</link>
		<comments>http://devbox.computec.de/2010/08/coldfusion-vs-railo-on-cftransaction-actionrollback/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 08:44:43 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=553</guid>
		<description><![CDATA[While migrating one of our ColdFusion 8 servers to Railo I stumbled over a small problem with the cftransaction tag today. Consider this snippet of code:

&#60;cftransaction action=&#34;begin&#34;&#62;
	&#60;cftry&#62;
		&#60;cfquery name=&#34;variables.qTestQuery&#34; 
				datasource=&#34;#variables.strDs#&#34;&#62;
			SELECT version();
		&#60;/cfquery&#62;
		&#60;cfcatch type=&#34;database&#34;&#62;
			&#60;cftransaction action=&#34;rollback&#34;&#62;			
		&#60;/cfcatch&#62;
	&#60;/cftry&#62;
&#60;/cftransaction&#62;
Done.

This was running fine on ColdFusion 8.0.1, Railo 3.1.2.019 on the other hand complained:

Start and End Tag has not the same Name [cftransaction-cfcatch]
5: &#60;/cfquery&#62;
6: [...]]]></description>
			<content:encoded><![CDATA[<p>While migrating one of our ColdFusion 8 servers to Railo I stumbled over a small problem with the cftransaction tag today. Consider this snippet of code:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftransaction</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;begin&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftry</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.qTestQuery&quot;</span> </span>
<span style="color: #333333;">				<span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#variables.strDs#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			SELECT version();
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfcatch</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;database&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftransaction</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;rollback&quot;</span><span style="color: #0000FF;">&gt;</span></span>			
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfcatch</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftry</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftransaction</span><span style="color: #0000FF;">&gt;</span></span>
Done.</pre></div></div>

<p>This was running fine on ColdFusion 8.0.1, Railo 3.1.2.019 on the other hand complained:</p>
<blockquote><p>
Start and End Tag has not the same Name [cftransaction-cfcatch]<br />
5: &lt;/cfquery&gt;<br />
6: &lt;cfcatch type="database"&gt;<br />
7: <strong>&lt;cftransaction action="rollback"&gt;</strong><br />
8: &lt;/cfcatch&gt;<br />
9: &lt;/cftry&gt;
</p></blockquote>
<p>The issue is easily resolved - and probably won't hit you as long as you're using a more recent IDE with better Code Assist thank DreamWeaver MX 2004, as this will automatically provide a closing tag for the &lt;cftransaction action="rollback"&gt;. To make Railo happy, just use</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftransaction</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;rollback&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p> or</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftransaction</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;rollback&quot;</span><span style="color: #0000FF;">&gt;</span></span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftransaction</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>The version with the self-closing tag makes more sense to me, though ColdFusion Builder will provide you with the latter variation.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;bodytext=While%20migrating%20one%20of%20our%20ColdFusion%208%20servers%20to%20Railo%20I%20stumbled%20over%20a%20small%20problem%20with%20the%20cftransaction%20tag%20today.%20Consider%20this%20snippet%20of%20code%3A%0D%0A%0D%0A%0D%0A%0D%0A%09%0D%0A%09%09%0D%0A%09%09%09SELECT%20version%28%29%3B%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09%09%09%09%09%0D%0A%09%09%0D%0A%09%0D%0A%0D%0ADone.%0D%0A%0D%0A%0D%0AThis%20was%20running%20fine%20on" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;notes=While%20migrating%20one%20of%20our%20ColdFusion%208%20servers%20to%20Railo%20I%20stumbled%20over%20a%20small%20problem%20with%20the%20cftransaction%20tag%20today.%20Consider%20this%20snippet%20of%20code%3A%0D%0A%0D%0A%0D%0A%0D%0A%09%0D%0A%09%09%0D%0A%09%09%09SELECT%20version%28%29%3B%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09%09%09%09%09%0D%0A%09%09%0D%0A%09%0D%0A%0D%0ADone.%0D%0A%0D%0A%0D%0AThis%20was%20running%20fine%20on" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;t=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;annotation=While%20migrating%20one%20of%20our%20ColdFusion%208%20servers%20to%20Railo%20I%20stumbled%20over%20a%20small%20problem%20with%20the%20cftransaction%20tag%20today.%20Consider%20this%20snippet%20of%20code%3A%0D%0A%0D%0A%0D%0A%0D%0A%09%0D%0A%09%09%0D%0A%09%09%09SELECT%20version%28%29%3B%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09%09%09%09%09%0D%0A%09%09%0D%0A%09%0D%0A%0D%0ADone.%0D%0A%0D%0A%0D%0AThis%20was%20running%20fine%20on" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=While%20migrating%20one%20of%20our%20ColdFusion%208%20servers%20to%20Railo%20I%20stumbled%20over%20a%20small%20problem%20with%20the%20cftransaction%20tag%20today.%20Consider%20this%20snippet%20of%20code%3A%0D%0A%0D%0A%0D%0A%0D%0A%09%0D%0A%09%09%0D%0A%09%09%09SELECT%20version%28%29%3B%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09%09%09%09%09%0D%0A%09%09%0D%0A%09%0D%0A%0D%0ADone.%0D%0A%0D%0A%0D%0AThis%20was%20running%20fine%20on" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;bm_description=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;t=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&opener=bm&amp;ei=UTF-8&amp;d=While%20migrating%20one%20of%20our%20ColdFusion%208%20servers%20to%20Railo%20I%20stumbled%20over%20a%20small%20problem%20with%20the%20cftransaction%20tag%20today.%20Consider%20this%20snippet%20of%20code%3A%0D%0A%0D%0A%0D%0A%0D%0A%09%0D%0A%09%09%0D%0A%09%09%09SELECT%20version%28%29%3B%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09%09%09%09%09%0D%0A%09%09%0D%0A%09%0D%0A%0D%0ADone.%0D%0A%0D%0A%0D%0AThis%20was%20running%20fine%20on" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;t=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;submitHeadline=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;submitSummary=While%20migrating%20one%20of%20our%20ColdFusion%208%20servers%20to%20Railo%20I%20stumbled%20over%20a%20small%20problem%20with%20the%20cftransaction%20tag%20today.%20Consider%20this%20snippet%20of%20code%3A%0D%0A%0D%0A%0D%0A%0D%0A%09%0D%0A%09%09%0D%0A%09%09%09SELECT%20version%28%29%3B%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09%09%09%09%09%0D%0A%09%09%0D%0A%09%0D%0A%0D%0ADone.%0D%0A%0D%0A%0D%0AThis%20was%20running%20fine%20on&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;exttitle=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F08%2Fcoldfusion-vs-railo-on-cftransaction-actionrollback%2F&amp;bm_description=ColdFusion%20vs.%20Railo%20on%20%26lt%3Bcftransaction%20action%3D%22rollback%22%26gt%3B&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/08/coldfusion-vs-railo-on-cftransaction-actionrollback/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Coldfusion UDF to create &amp; CHMOD a full directory path</title>
		<link>http://devbox.computec.de/2010/07/coldfusion-udf-to-create-chmod-a-full-directory-path/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-udf-to-create-chmod-a-full-directory-path</link>
		<comments>http://devbox.computec.de/2010/07/coldfusion-udf-to-create-chmod-a-full-directory-path/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 09:10:28 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=544</guid>
		<description><![CDATA[The following problem has come up during a file caching implementation: We've got a directory /var/www/MYCACHE; our filecaching mechanism uses a key-based directory structure to store files there. So let's suppose our key would be 123456789, we'd like to store the file 123456789.cache under /var/www/MYCACHE/123/123456/123456789.cache. This would make sure that no directory needs to hold [...]]]></description>
			<content:encoded><![CDATA[<p>The following problem has come up during a file caching implementation: We've got a directory <code>/var/www/MYCACHE</code>; our filecaching mechanism uses a key-based directory structure to store files there. So let's suppose our key would be <code>123456789</code>, we'd like to store the file <code>123456789.cache</code> under <code>/var/www/MYCACHE/123/123456/123456789.cache</code>. This would make sure that no directory needs to hold more than 1,000 nodes.</p>
<p>All would be well if we could be sure that the user jrun (i.e. the user that owns our ColdFusion process) was indeed the only user ever to access this directory structure. In our case we want to be able to access this structure with PHP, too, which runs as mod_php on the webserver, thus as user www-data. To avoid permission problems, we want to assign a permission of 0777 to all directories in the structure upon creation.</p>
<p><span id="more-544"></span>You'll need at least JDK 1.6 for this to work:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;createWRXPath&quot;</span> </span>
<span style="color: #333333;">	<span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> </span>
<span style="color: #333333;">	returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;boolean&quot;</span> </span>
<span style="color: #333333;">	output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;no&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;strPath&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;an absolute physical path </span>
<span style="color: #333333;">		to a directory, not a file&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;iMinDepth&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;numeric&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;no&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">default</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;4&quot;</span> </span>
<span style="color: #333333;">		<span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;minimum depth to set permissions&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
		var local = structNew();
&nbsp;
		local.strPath = GetDirectoryFromPath(
			JavaCast('string',arguments.strPath));
&nbsp;
		local.objFile = CreateObject('java'
			,'java.io.File').init(local.strPath);
&nbsp;
		if (arguments.iMinDepth gt 4) {
			local.iMinDepth = arguments.iMinDepth;
			} else {
			local.iMinDepth = 4;			
		} // end if (arguments.iMinDepth gt 4)
&nbsp;
		// create the path
		local.objFile.mkdirs();
&nbsp;
		// if that hasn't succeeded, return false
		if (not DirectoryExists(local.strPath)) return false;
&nbsp;
		local.l = ListLen(local.strPath,'/');
&nbsp;
		local.strPartPath = '/';
&nbsp;
		// now descend into the path from top down, 
		//   set permissions for every directory lower 
		//  than level iMinDepth
&nbsp;
		for (local.i=1; local.i lte local.l; local.i++) {
&nbsp;
			local.strPartPath &amp;= 
				ListGetAt(local.strPath,local.i,'/') &amp; '/';
&nbsp;
			if (local.i gte local.iMinDepth) {				
				local.objFile = CreateObject('java'
					,'java.io.File').init(
					    local.strPartPath);
&nbsp;
				local.objFile.setReadable(TRUE,FALSE);				
				local.objFile.setWritable(TRUE,FALSE);
				local.objFile.setExecutable(TRUE,FALSE);
&nbsp;
			} // end if (local.i gte local.iMinDepth)
&nbsp;
		} // end for (local.i=1; local.i lte local.l; local.i++)
&nbsp;
		return TRUE;
&nbsp;
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Example for usage:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>	
	variables.strFile  = '/var/www/MYCACHE/123/123456/123456789.cache';
	variables.strPath  = GetDirectoryFromPath(variables.strFile);
	variables.bSuccess = createWRXPath(variables.strPath,4);	
	writeOutput(variables.bSuccess);
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>




Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;bodytext=The%20following%20problem%20has%20come%20up%20during%20a%20file%20caching%20implementation%3A%20We%27ve%20got%20a%20directory%20%2Fvar%2Fwww%2FMYCACHE%3B%20our%20filecaching%20mechanism%20uses%20a%20key-based%20directory%20structure%20to%20store%20files%20there.%20So%20let%27s%20suppose%20our%20key%20would%20be%20123456789%2C%20we%27d%20lik" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;notes=The%20following%20problem%20has%20come%20up%20during%20a%20file%20caching%20implementation%3A%20We%27ve%20got%20a%20directory%20%2Fvar%2Fwww%2FMYCACHE%3B%20our%20filecaching%20mechanism%20uses%20a%20key-based%20directory%20structure%20to%20store%20files%20there.%20So%20let%27s%20suppose%20our%20key%20would%20be%20123456789%2C%20we%27d%20lik" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;t=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;annotation=The%20following%20problem%20has%20come%20up%20during%20a%20file%20caching%20implementation%3A%20We%27ve%20got%20a%20directory%20%2Fvar%2Fwww%2FMYCACHE%3B%20our%20filecaching%20mechanism%20uses%20a%20key-based%20directory%20structure%20to%20store%20files%20there.%20So%20let%27s%20suppose%20our%20key%20would%20be%20123456789%2C%20we%27d%20lik" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=The%20following%20problem%20has%20come%20up%20during%20a%20file%20caching%20implementation%3A%20We%27ve%20got%20a%20directory%20%2Fvar%2Fwww%2FMYCACHE%3B%20our%20filecaching%20mechanism%20uses%20a%20key-based%20directory%20structure%20to%20store%20files%20there.%20So%20let%27s%20suppose%20our%20key%20would%20be%20123456789%2C%20we%27d%20lik" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;bm_description=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;t=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&opener=bm&amp;ei=UTF-8&amp;d=The%20following%20problem%20has%20come%20up%20during%20a%20file%20caching%20implementation%3A%20We%27ve%20got%20a%20directory%20%2Fvar%2Fwww%2FMYCACHE%3B%20our%20filecaching%20mechanism%20uses%20a%20key-based%20directory%20structure%20to%20store%20files%20there.%20So%20let%27s%20suppose%20our%20key%20would%20be%20123456789%2C%20we%27d%20lik" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;t=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;submitHeadline=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;submitSummary=The%20following%20problem%20has%20come%20up%20during%20a%20file%20caching%20implementation%3A%20We%27ve%20got%20a%20directory%20%2Fvar%2Fwww%2FMYCACHE%3B%20our%20filecaching%20mechanism%20uses%20a%20key-based%20directory%20structure%20to%20store%20files%20there.%20So%20let%27s%20suppose%20our%20key%20would%20be%20123456789%2C%20we%27d%20lik&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;exttitle=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-udf-to-create-chmod-a-full-directory-path%2F&amp;bm_description=Coldfusion%20UDF%20to%20create%20%26%20CHMOD%20a%20full%20directory%20path&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/07/coldfusion-udf-to-create-chmod-a-full-directory-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion 8 CHF4 [doesn&#039;t] break CFIMAGE [UPDATE]</title>
		<link>http://devbox.computec.de/2010/07/coldfusion-8-chf4-breaks-cfimage/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-8-chf4-breaks-cfimage</link>
		<comments>http://devbox.computec.de/2010/07/coldfusion-8-chf4-breaks-cfimage/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 09:56:48 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=529</guid>
		<description><![CDATA[UPDATE 2: There is actually an issue with ColdFusion Cumulative Hotfix 4, though it's not the Hotfix itself, it's the installation instructions explicitly telling you to skip installing another hotfix if you're not on JVM 1.5. Don't skip installing hf801-71557, even when you're on JVM 1.6 - that has fixed it with our installation.

There seems [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE 2: There is actually an issue with ColdFusion Cumulative Hotfix 4, though it's not the Hotfix itself, it's the installation instructions explicitly telling you to skip installing another hotfix if you're not on JVM 1.5. <strong>Don't</strong> skip installing <a href="http://kb2.adobe.com/cps/403/kb403411.html" target="_blank">hf801-71557</a>, even when you're on JVM 1.6 - that has fixed it with our installation.<br />
<span id="more-529"></span><br />
<del datetime="2010-07-09T15:50:56+00:00">There seems to be an issue with <code>&lt;cfimage action="resize" overwrite="yes" ... /&gt;</code> after the update to ColdFusion 8 cumulative hotfix 4 when source and destination file path are identical. From what I have seen so far, it seems like CFIMAGE opens a filehandle and "forgets" to close it after it is done. We haven't found a workaround yet. It'd be nice if somebody could confirm the issue. Does it exist with CF9, too?</del></p>
<p>Here's how to reproduce:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> fSource <span style="color: #0000FF;">=</span> <span style="color: #009900;">'/var/www/somepathto/test.jpg'</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span>cfimage <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;resize&quot;</span> source<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#fSource#&quot;</span> destination<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#fSource#&quot;</span> overwrite<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span> <span style="color: #0000FF;">height</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;100&quot;</span> <span style="color: #0000FF;">width</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;200&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>This will throw an exception:</p>
<blockquote><p>
An exception occured while trying to write the image. Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : java.io.FileNotFoundException: /var/www/somepathto/test.jpg (No such file or directory)
</p></blockquote>
<p>After that, the original file <code>/var/www/somepathto/test.jpg</code> is gone.</p>
<p>We tried to workaround the issue by creating a temporary file and then moving this to the original destination. This doesn't work reliably either:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> fSource <span style="color: #0000FF;">=</span> <span style="color: #009900;">'/var/www/somepathto/test.jpg'</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> fTemp <span style="color: #0000FF;">=</span> <span style="color: #009900;">'/var/www/somepathto/'</span> <span style="color: #0000FF;">&amp;</span> <span style="color: #0000FF;">createUUID</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">&amp;</span> <span style="color: #009900;">'.'</span> <span style="color: #0000FF;">&amp;</span> <span style="color: #0000FF;">ListLast</span><span style="color: #0000FF;">&#40;</span>fSource,<span style="color: #009900;">'.'</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span>cfimage <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;resize&quot;</span> source<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#fSource#&quot;</span> destination<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#fTemp#&quot;</span> overwrite<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span> <span style="color: #0000FF;">height</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;100&quot;</span> <span style="color: #0000FF;">width</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;200&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffile</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;move&quot;</span> source<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#fTemp#&quot;</span> destination<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#fSource#&quot;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>This does sometimes work, sometimes it leaves a stale NFS handle like <code>.nfs0000000000998aa000000</code> in the directory. Same thing (stale NFS file handles) happens when we copy the file and delete the temporary file with CFFILE.</p>
<p><del datetime="2010-07-09T15:50:56+00:00">We didn't use to see this kind of behaviour before the update, so I guess that there must be some kind of correlation. The stale filehandles disappear as soon as the ColdFusion server is being stopped or restarted.</del></p>
<p>For now we'll probably replace CFIMAGE with calls to ImageMagick - but this is tedious and we'd very much like to continue using CFIMAGE for such tasks.</p>
<p>Any ideas?</p>
<p><a name="update"><strong>UPDATE</strong>:</a>We noticed that the issue only affects specific JPG files. ImageMagick doesn't run into issues with any of those files, but CFIMAGE does. We haven't yet found out the exact nature of the problem, but it seems like Adobe Photoshop may be the culprit. Here's one of the files that cause CFIMAGE to throw the exception and delete the file:<br />
<a href="http://devbox.computec.de/wp-content/uploads/2010/07/broken.jpg"><img src="http://devbox.computec.de/wp-content/uploads/2010/07/broken.jpg" alt="This image causes problems for CFIMAGE" title="This image causes problems for CFIMAGE" width="500" height="281" class="aligncenter size-full wp-image-535" /></a><br />
<a href="http://devbox.computec.de/wp-content/uploads/2010/07/broken2.jpg">Here's another image causing problems.</a></p>
<p>The first image has Exif data indicating it has been created with Adobe Photoshop CS3, the second bears a similar mark, only this time it's Adobe Photoshop 7.0. A colleague of the graphics artist persuasion has opened and then saved the images in Photoshop as "Web JPG" - these converted files do not show any problems. There is however another option to save images as JPG, or so I am told, which actually produces the broken images. Broken for CFIMAGE, that is, as ImageMagick doesn't complain. So I still see this as a bug in CFIMAGE, and what's more disturbing, it seems to be some incompatibility with Adobe's very own Photoshop, if I am not too much mistaken.</p>
<p>I'd still be very happy if somebody could shed a little more light on the issue, though. Are there any workarounds that allow us to deal with the issue, other than switching from CFIMAGE back to ImageMagick?</p>
<p><a name="update2"><strong>UPDATE 2</strong>:</a> I think I have now identified the cause of the issue - it seems to be an <a href="http://kb2.adobe.com/cps/529/cpsid_52915.html" target="_blank">error in the installation instructions of Cumulative Hotfix 4</a>. See "Installing the hot fixes", Step 2: </p>
<blockquote><p> 2. (Applies only if you are using JDK 1.5, else ignore the step) Do the following:...</p></blockquote>
<p>What you really should ignore is the bit inside the brackets, or so it seems. After installing hf801-71557, the images that used to cause CFIMAGE to crash are now being processed without any problems.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;bodytext=UPDATE%202%3A%20There%20is%20actually%20an%20issue%20with%20ColdFusion%20Cumulative%20Hotfix%204%2C%20though%20it%27s%20not%20the%20Hotfix%20itself%2C%20it%27s%20the%20installation%20instructions%20explicitly%20telling%20you%20to%20skip%20installing%20another%20hotfix%20if%20you%27re%20not%20on%20JVM%201.5.%20Don%27t%20skip%20installing%20h" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;notes=UPDATE%202%3A%20There%20is%20actually%20an%20issue%20with%20ColdFusion%20Cumulative%20Hotfix%204%2C%20though%20it%27s%20not%20the%20Hotfix%20itself%2C%20it%27s%20the%20installation%20instructions%20explicitly%20telling%20you%20to%20skip%20installing%20another%20hotfix%20if%20you%27re%20not%20on%20JVM%201.5.%20Don%27t%20skip%20installing%20h" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;t=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;annotation=UPDATE%202%3A%20There%20is%20actually%20an%20issue%20with%20ColdFusion%20Cumulative%20Hotfix%204%2C%20though%20it%27s%20not%20the%20Hotfix%20itself%2C%20it%27s%20the%20installation%20instructions%20explicitly%20telling%20you%20to%20skip%20installing%20another%20hotfix%20if%20you%27re%20not%20on%20JVM%201.5.%20Don%27t%20skip%20installing%20h" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=UPDATE%202%3A%20There%20is%20actually%20an%20issue%20with%20ColdFusion%20Cumulative%20Hotfix%204%2C%20though%20it%27s%20not%20the%20Hotfix%20itself%2C%20it%27s%20the%20installation%20instructions%20explicitly%20telling%20you%20to%20skip%20installing%20another%20hotfix%20if%20you%27re%20not%20on%20JVM%201.5.%20Don%27t%20skip%20installing%20h" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;bm_description=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;t=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&opener=bm&amp;ei=UTF-8&amp;d=UPDATE%202%3A%20There%20is%20actually%20an%20issue%20with%20ColdFusion%20Cumulative%20Hotfix%204%2C%20though%20it%27s%20not%20the%20Hotfix%20itself%2C%20it%27s%20the%20installation%20instructions%20explicitly%20telling%20you%20to%20skip%20installing%20another%20hotfix%20if%20you%27re%20not%20on%20JVM%201.5.%20Don%27t%20skip%20installing%20h" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;t=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;submitHeadline=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;submitSummary=UPDATE%202%3A%20There%20is%20actually%20an%20issue%20with%20ColdFusion%20Cumulative%20Hotfix%204%2C%20though%20it%27s%20not%20the%20Hotfix%20itself%2C%20it%27s%20the%20installation%20instructions%20explicitly%20telling%20you%20to%20skip%20installing%20another%20hotfix%20if%20you%27re%20not%20on%20JVM%201.5.%20Don%27t%20skip%20installing%20h&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;exttitle=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-8-chf4-breaks-cfimage%2F&amp;bm_description=ColdFusion%208%20CHF4%20%5Bdoesn%27t%5D%20break%20CFIMAGE%20%5BUPDATE%5D&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/07/coldfusion-8-chf4-breaks-cfimage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion: Get date from Unix timestamp</title>
		<link>http://devbox.computec.de/2010/07/coldfusion-oneliner-to-get-a-date-from-a-unix-timestamp/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-oneliner-to-get-a-date-from-a-unix-timestamp</link>
		<comments>http://devbox.computec.de/2010/07/coldfusion-oneliner-to-get-a-date-from-a-unix-timestamp/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 14:45:12 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[unix timestamp]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=521</guid>
		<description><![CDATA[A quick followup on a previous post ColdFusion UDF to get Unix timestamp from date: Here's a oneliner that provides you with the complimentary function to get a date from a Unix timestamp - as I've discovered that the dateAdd() route mostly recommended on the net not only suffers from being quite clumsy, the result [...]]]></description>
			<content:encoded><![CDATA[<p>A quick followup on a previous post <a href="http://devbox.computec.de/2010/05/coldfusion-udf-to-get-unix-timestamp-from-date/">ColdFusion UDF to get Unix timestamp from date</a>: Here's a oneliner that provides you with the complimentary function to get a date from a Unix timestamp - as I've discovered that the <code>dateAdd()</code> route mostly recommended on the net not only suffers from being quite clumsy, the result is off by one hour, too - at least when DST is on.</p>
<p>So to get a date from a Unix timestamp in ColdFusion, you can use this oneliner:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> dtMyDate <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">'java'</span>,<span style="color: #009900;">'java.util.Date'</span><span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">javaCast</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">'long'</span>,iUnixTS*<span style="color: #FF0000;">1000</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>




Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;bodytext=A%20quick%20followup%20on%20a%20previous%20post%20ColdFusion%20UDF%20to%20get%20Unix%20timestamp%20from%20date%3A%20Here%27s%20a%20oneliner%20that%20provides%20you%20with%20the%20complimentary%20function%20to%20get%20a%20date%20from%20a%20Unix%20timestamp%20-%20as%20I%27ve%20discovered%20that%20the%20dateAdd%28%29%20route%20mostly%20recommend" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;notes=A%20quick%20followup%20on%20a%20previous%20post%20ColdFusion%20UDF%20to%20get%20Unix%20timestamp%20from%20date%3A%20Here%27s%20a%20oneliner%20that%20provides%20you%20with%20the%20complimentary%20function%20to%20get%20a%20date%20from%20a%20Unix%20timestamp%20-%20as%20I%27ve%20discovered%20that%20the%20dateAdd%28%29%20route%20mostly%20recommend" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;t=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;annotation=A%20quick%20followup%20on%20a%20previous%20post%20ColdFusion%20UDF%20to%20get%20Unix%20timestamp%20from%20date%3A%20Here%27s%20a%20oneliner%20that%20provides%20you%20with%20the%20complimentary%20function%20to%20get%20a%20date%20from%20a%20Unix%20timestamp%20-%20as%20I%27ve%20discovered%20that%20the%20dateAdd%28%29%20route%20mostly%20recommend" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=A%20quick%20followup%20on%20a%20previous%20post%20ColdFusion%20UDF%20to%20get%20Unix%20timestamp%20from%20date%3A%20Here%27s%20a%20oneliner%20that%20provides%20you%20with%20the%20complimentary%20function%20to%20get%20a%20date%20from%20a%20Unix%20timestamp%20-%20as%20I%27ve%20discovered%20that%20the%20dateAdd%28%29%20route%20mostly%20recommend" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;bm_description=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;t=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&opener=bm&amp;ei=UTF-8&amp;d=A%20quick%20followup%20on%20a%20previous%20post%20ColdFusion%20UDF%20to%20get%20Unix%20timestamp%20from%20date%3A%20Here%27s%20a%20oneliner%20that%20provides%20you%20with%20the%20complimentary%20function%20to%20get%20a%20date%20from%20a%20Unix%20timestamp%20-%20as%20I%27ve%20discovered%20that%20the%20dateAdd%28%29%20route%20mostly%20recommend" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;t=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;submitHeadline=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;submitSummary=A%20quick%20followup%20on%20a%20previous%20post%20ColdFusion%20UDF%20to%20get%20Unix%20timestamp%20from%20date%3A%20Here%27s%20a%20oneliner%20that%20provides%20you%20with%20the%20complimentary%20function%20to%20get%20a%20date%20from%20a%20Unix%20timestamp%20-%20as%20I%27ve%20discovered%20that%20the%20dateAdd%28%29%20route%20mostly%20recommend&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;exttitle=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fcoldfusion-oneliner-to-get-a-date-from-a-unix-timestamp%2F&amp;bm_description=ColdFusion%3A%20Get%20date%20from%20Unix%20timestamp&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/07/coldfusion-oneliner-to-get-a-date-from-a-unix-timestamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String methods: ColdFusion vs. Java</title>
		<link>http://devbox.computec.de/2010/07/string-methods-coldfusion-vs-java/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=string-methods-coldfusion-vs-java</link>
		<comments>http://devbox.computec.de/2010/07/string-methods-coldfusion-vs-java/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 08:50:57 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=507</guid>
		<description><![CDATA[You may know from previous blog posts that I strongly advise every ColdFusion developer to familiarize himself/herself with the thing that actually makes ColdFusion tick, i.e. with Java. Everybody who writes a single line of CFML should know about the possibilities of extending ColdFusion by directly accessing the underlying Java methods of certain objects. One [...]]]></description>
			<content:encoded><![CDATA[<p>You may know from previous blog posts that I strongly advise every ColdFusion developer to familiarize himself/herself with the thing that actually makes ColdFusion tick, i.e. with Java. Everybody who writes a single line of CFML should know about the possibilities of extending ColdFusion by directly accessing the underlying Java methods of certain objects. One of the datatypes where actually using Java may make a lot of sense is the string object. </p>
<p>ColdFusion string literals are just plain old <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html" target="_blank">Java strings</a>. If you grab a string from e.g. a query object like <code>variables.qMyQuery.myTextColumn</code>, you need to be careful though - even if you think you just have one tuple returned, you've got something other than a string object on your hands. In such a case you need to either specifically target a certain row (like <code>variables.qMyQuery.myTextColumn[1]</code>) or you wrap it up in a JavaCast like <code>Javacast('string',variables.qMyQuery.myTextColumn)</code>.</p>
<p>I finally found a moment to actually do some benchmarking on some of the built-in ColdFusion functions against their Java counterparts. This is not a benchmark of Java vs. ColdFusion performance, mind you, it's about deciding whether to use Java-methods inside of ColdFusion vs. ColdFusion's built-in string functions.<br />
<span id="more-507"></span><br />
The test subject here is a string of 2848 characters length, pulled from our live article database, which should provide a realistic use case. The JavaCast has already been done, so if we're working with string data that may not be represented by actual Java string objects at the time of access, we may need to account for some additional processing cycles to do the JavaCast in order to be able to use Java methods on it. I ran the tests several times on the same machine, making sure the results where actually reproducable on each run. The tests have been performed on ColdFusion 8 Enterprise running in a 64-bit multi-instance configuration. If you're running CF9, your mileage may vary, though I wouldn't expect the results to point in a very much different direction.</p>
<p>On to the tests.</p>
<h2>len() vs. length()</h2>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;coldfusion len&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.iCfLen <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">len</span><span style="color: #0000FF;">&#40;</span>variables.strText<span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span><span style="color: #0000FF;">#variables.iCfLen#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;java length&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.iJLength <span style="color: #0000FF;">=</span> variables.strText.length<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span><span style="color: #0000FF;">#variables.iJLength#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Results: ColdFusion 76ms vs. Java 104ms.</p>
<h2>Find() vs. indexOf()</h2>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;coldfusion find&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.iCfFind <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">Find</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">'Singularity'</span>,variables.strText<span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span><span style="color: #0000FF;">#variables.iCfFind#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;java indexOf&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.iJindexOf <span style="color: #0000FF;">=</span> variables.strText.indexOf<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">'Singularity'</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>#variables.iJindexOf+1#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Results: ColdFusion 67ms vs. Java 115ms.</p>
<h2>&#038; vs. concat()</h2>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;coldfusion &amp;&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strCFconcat <span style="color: #0000FF;">=</span>  variables.strText <span style="color: #0000FF;">&amp;</span> variables.strText<span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;java concat()&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strJconcat <span style="color: #0000FF;">=</span> variables.strText.concat<span style="color: #0000FF;">&#40;</span>variables.strText<span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Results: ColdFusion 120ms vs. Java 172ms.</p>
<h2>ReReplace() vs. replaceFirst()</h2>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;coldfusion ReReplace&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strCfReReplace <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">ReReplace</span><span style="color: #0000FF;">&#40;</span>variables.strText,<span style="color: #009900;">'Singularity'</span>,<span style="color: #009900;">'Singularity 2'</span>, <span style="color: #009900;">'ONE'</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;java replaceFirst&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strJreplaceFirst <span style="color: #0000FF;">=</span> variables.strText.replaceFirst<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">'Singularity'</span>,<span style="color: #009900;">'Singularity 2'</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Results: ColdFusion 331ms vs. Java 228ms.</p>
<h2>ReReplace() vs. replaceAll()</h2>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;coldfusion ReReplace&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strCfReReplace <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">ReReplace</span><span style="color: #0000FF;">&#40;</span>variables.strText,<span style="color: #009900;">'Singularity'</span>,<span style="color: #009900;">'Singularity 2'</span>, <span style="color: #009900;">'ALL'</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftimer</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;outline&quot;</span> <span style="color: #0000FF;">label</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;java replaceAll&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;10000&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;variables.i&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strJreplaceFirst <span style="color: #0000FF;">=</span> variables.strText.replaceAll<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">'Singularity'</span>,<span style="color: #009900;">'Singularity 2'</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftimer</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Results: ColdFusion 543ms vs. Java 629ms.</p>
<h2>Conclusion</h2>
<p>There seems to be a certain overhead involved in using the underlying Java methods instead of the build-in ColdFusion functions (or operators in case of the &#038;). The difference is actually not that much, and depending on the data you work on, the Java approach might actually gain the upper hand in some cases.</p>
<p>However, based on these findings I would suggest you stick with ColdFusion for such simple cases; your CFML code will be more independent of the underlying VM (which may even be .NET) and easier to write, too, as most ColdFusion IDEs will not support mixed code completion for both CFML and Java.</p>
<p>This is no reason not to take a look behind the curtain, though. Where Java really shines from a ColdFusion developers view is in solving problems that couldn't be as elegantly solved in plain CFML. For example, you'll be able to implement a buffered stream writer instead of <code>&lt;cffile action="append" /&gt;</code>, you'll have <code>java.util.Calendar</code> to do your bidding working with date/time-data, and you'll be able to use a wide range of external Java libraries from within ColdFusion, solving both trivial and most complex problems without you doing all the legwork coding the solutions.</p>
<p>On the other hand, when you actually have discovered some of the gems that are hidden in the Java foundation of ColdFusion, don't just blindly adopt everything you find there. You still need to do some testing to find the tool that fits your needs best.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;bodytext=You%20may%20know%20from%20previous%20blog%20posts%20that%20I%20strongly%20advise%20every%20ColdFusion%20developer%20to%20familiarize%20himself%2Fherself%20with%20the%20thing%20that%20actually%20makes%20ColdFusion%20tick%2C%20i.e.%20with%20Java.%20Everybody%20who%20writes%20a%20single%20line%20of%20CFML%20should%20know%20about%20th" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;notes=You%20may%20know%20from%20previous%20blog%20posts%20that%20I%20strongly%20advise%20every%20ColdFusion%20developer%20to%20familiarize%20himself%2Fherself%20with%20the%20thing%20that%20actually%20makes%20ColdFusion%20tick%2C%20i.e.%20with%20Java.%20Everybody%20who%20writes%20a%20single%20line%20of%20CFML%20should%20know%20about%20th" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;t=String%20methods%3A%20ColdFusion%20vs.%20Java" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;annotation=You%20may%20know%20from%20previous%20blog%20posts%20that%20I%20strongly%20advise%20every%20ColdFusion%20developer%20to%20familiarize%20himself%2Fherself%20with%20the%20thing%20that%20actually%20makes%20ColdFusion%20tick%2C%20i.e.%20with%20Java.%20Everybody%20who%20writes%20a%20single%20line%20of%20CFML%20should%20know%20about%20th" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=You%20may%20know%20from%20previous%20blog%20posts%20that%20I%20strongly%20advise%20every%20ColdFusion%20developer%20to%20familiarize%20himself%2Fherself%20with%20the%20thing%20that%20actually%20makes%20ColdFusion%20tick%2C%20i.e.%20with%20Java.%20Everybody%20who%20writes%20a%20single%20line%20of%20CFML%20should%20know%20about%20th" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;bm_description=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=String%20methods%3A%20ColdFusion%20vs.%20Java%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;t=String%20methods%3A%20ColdFusion%20vs.%20Java&opener=bm&amp;ei=UTF-8&amp;d=You%20may%20know%20from%20previous%20blog%20posts%20that%20I%20strongly%20advise%20every%20ColdFusion%20developer%20to%20familiarize%20himself%2Fherself%20with%20the%20thing%20that%20actually%20makes%20ColdFusion%20tick%2C%20i.e.%20with%20Java.%20Everybody%20who%20writes%20a%20single%20line%20of%20CFML%20should%20know%20about%20th" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;t=String%20methods%3A%20ColdFusion%20vs.%20Java" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;submitHeadline=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;submitSummary=You%20may%20know%20from%20previous%20blog%20posts%20that%20I%20strongly%20advise%20every%20ColdFusion%20developer%20to%20familiarize%20himself%2Fherself%20with%20the%20thing%20that%20actually%20makes%20ColdFusion%20tick%2C%20i.e.%20with%20Java.%20Everybody%20who%20writes%20a%20single%20line%20of%20CFML%20should%20know%20about%20th&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;exttitle=String%20methods%3A%20ColdFusion%20vs.%20Java" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;title=String%20methods%3A%20ColdFusion%20vs.%20Java" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F07%2Fstring-methods-coldfusion-vs-java%2F&amp;bm_description=String%20methods%3A%20ColdFusion%20vs.%20Java&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/07/string-methods-coldfusion-vs-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion 8 and MySQL 5.1 via JDBC: Help needed! [Solved]</title>
		<link>http://devbox.computec.de/2010/06/coldfusion-8-and-mysql-5-1-via-jdbc-help-needed/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-8-and-mysql-5-1-via-jdbc-help-needed</link>
		<comments>http://devbox.computec.de/2010/06/coldfusion-8-and-mysql-5-1-via-jdbc-help-needed/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 09:13:04 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[Admin-Stuff]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[java.lang.NullPointerException]]></category>
		<category><![CDATA[jdbc]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=489</guid>
		<description><![CDATA[UPDATE: We have now found the cause of the issue. Please scroll to the end of the article for explanation and workaround.
In one of our latest projects we need to access a MySQL 5.1 server (5.1.45) from ColdFusion 8 (8,0,1,195765). Creating the datasource was no problem, the datasource does verify okay - but there obviously [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>UPDATE</strong>: We have now found the cause of the issue. Please <a href="http://devbox.computec.de/2010/06/coldfusion-8-and-mysql-5-1-via-jdbc-help-needed/#solved">scroll to the end of the article for explanation and workaround</a>.</em></p>
<p>In one of our latest projects we need to access a MySQL 5.1 server (5.1.45) from ColdFusion 8 (8,0,1,195765). Creating the datasource was no problem, the datasource does verify okay - but there obviously is some bug or incompatibility in ColdFusion that causes the connection to be anything but reliable.<br />
<span id="more-489"></span><br />
Here's my testcode:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfsetting</span> requesttimeout<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;120&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.iStart <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">getTickCount</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables.strMyDS <span style="color: #0000FF;">=</span> <span style="color: #009900;">'myMysqlDB'</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;doCheckQuery&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> qCheckDB <span style="color: #0000FF;">=</span> <span style="color: #009900;">''</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftry</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;qCheckDB&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#variables.strMyDS#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			SELECT now();
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdump</span> <span style="color: #000000; font-weight: bold;">var</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#qCheckDB#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfcatch</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;any&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
			#getTickCount()-variables.iStart# ms
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">br</span> <span style="color: #0000FF;">/&gt;</span></span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfdump</span> <span style="color: #000000; font-weight: bold;">var</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#CFCATCH#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfabort</span><span style="color: #0000FF;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfcatch</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftry</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
	doCheckQuery();
	sleep(10000);
	doCheckQuery();
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>In a perfect world, there's just nothing here that could go wrong, right? Okay, as long as the <code>sleep</code>-statements remains at something like under 15 seconds, output is as expected:<br />
<img src="http://devbox.computec.de/wp-content/uploads/2010/06/CFMySQL51working.png" alt="Test working" title="CFMySQL51working" width="270" height="325" class="aligncenter size-full wp-image-495" /></p>
<p>As soon as the <code>sleep</code> time is longer than 15 seconds, the second query fails. The exact time is somewhat inconclusive, sometimes 15000ms does work, sometimes it doesn't. 10 seconds seems to always work, whereas 20 seconds seems to always fail.</p>
<p>The stack trace shows the cause of the error to be a <code>java.lang.NullPointerException</code>:</p>
<pre>
java.lang.NullPointerException
	at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178)
	at coldfusion.server.j2ee.sql.JRunStatement.setMaxRows(JRunStatement.java:214)
	at coldfusion.sql.Executive.executeQuery(Executive.java:1276)
	at coldfusion.sql.Executive.executeQuery(Executive.java:1008)
	at coldfusion.sql.Executive.executeQuery(Executive.java:939)
	at coldfusion.sql.SqlImpl.execute(SqlImpl.java:325)
	at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:831)
	at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:521)
...
</pre>
<p>Funny thing is that we already do use MySQL with ColdFusion - connecting to version 5.0.51a-19~bpo40+1-log doesn't seem to suffer from the same symptoms.</p>
<p>After spending some time with Google I found this <a href="http://forums.adobe.com/thread/56954?start=0&#038;tstart=0">Thread "[CF8] java.lang.NullPointerException"</a> on the Adobe Support forums.</p>
<p>Unfortunately none of the suggestions in there has helped us with the issue. I tried to create the datasource with both the MySQL 4/5 option and the "other" option using a JDBC URL. I tried switching "Maintain Connections" on and off - neither does make a difference. I tried adding <code>&#038;autoReconnectForPools=true&#038;zeroDateTimeBehavior=convertToNull</code> to the JDBC-URL like this:</p>
<pre>
jdbc:mysql://123.123.123.123:3306/mytestdb?prepareThreshold=3&#038;charSet=UTF-8&#038;autoReconnectForPools=true&#038;zeroDateTimeBehavior=convertToNull
</pre>
<p>Doesn't help either. I replaced the <em>mysql-connector-java-commercial-5.0.5-bin.jar</em> that came with CF8 with the latest <em>mysql-connector-java-5.1.12-bin.jar</em>, restarted the instance, checked the classpath and tried again - same outcome.</p>
<p>The <code>wait_timeout</code> on the MySQL server is currently set to 60 (i.e. 60 seconds), which leads me to believe that this isn't the cause of the issue either - as do some posts of people who have tried to increase the value without any positive effect.</p>
<p>Now upgrading all of our CF8 servers to CF9, though a compelling idea it might be, is just not an option, especially when the latest post in the aforementioned thread seems to suggest that the supposed bug fix in CF9 just reveals some underlying bug that might or might not be an issue for us, too.</p>
<p>Could anyone share their experiences with accessing a MySQL 5.1 DB from CF 8? What did you do, which version of the JDBC driver did you use, which version of MySQL are you using, which connection parameters do you set in your JDBC URL?</p>
<p>Any help on this would be greatly appreciated!</p>
<p><a name="solved"></a><strong>UPDATE</strong>: After some further experimenting on this issue, I stumbled over a misconception on my behalf; I thought I had checked the <code>wait_timout</code> setting on the affected MySQL server:</p>
<pre>
mysql>  show variables where variable_name like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 60    |
+---------------+-------+
1 row in set (0.00 sec)
</pre>
<p></p>
<p>So I couldn't exactly draw the line between the 60 seconds here and the 15 seconds problem found with my sample code. Now <code>show variables</code> in fact shows session variables, not the global setting. I don't know exactly what the "session variable" <code>wait_timeout</code> means exactly, I suspect nothing much, because the global variable actually wins, but here's how to determine the real setting:</p>
<pre>
mysql>  SELECT @@GLOBAL.wait_timeout;
+-----------------------+
| @@GLOBAL.wait_timeout |
+-----------------------+
|                    15 |
+-----------------------+
</pre>
<p></p>
<p>Ooookay - here are my 15 seconds. Now what I think happens here is that MySQL just closes the connection after 15 seconds of inactivity and ColdFusion/Jrun doesn't notice. Instead of removing the dead connection from the connection pool, it stays there zombified, ready to jump the next request with a null pointer exception.</p>
<p>The easiest workaround, and the one which we'll choose for now because I have actually tested it, is to set the value to something higher than 1200 seconds in your <code>my.cnf</code> like this:</p>
<pre>
[mysqld]
...
wait_timeout = 1300
</pre>
<p></p>
<p>... and restart the MySQL server. The default connection timeout in ColdFusion ist 1200 seconds, so if you set the value higher, you should be safe. I couldn't reproduce the error with my 5.1.48-MySQL text server after setting it to 1500, so I assume that this does in fact do the trick.</p>
<p>If for some reason you cannot change the MySQL timeout setting, you may have some luck changing the setting on the ColdFusion server side. To do so, you need to find and manually edit your <code>neo-datasource.xml</code> where all the datasources are configured; in a multi-instance configuration this file would be located at <code>{jrun-dir}/servers/{instance-name}/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/neo-datasource.xml</code>, in a standalone install you'll find it under <code>{cf-dir}/lib/neo-datasource.xml</code>.</p>
<p>You'd better use an XML editor that doesn't mess with the code and <strong>make a backup of the file before fiddling with the settings in there!</strong></p>
<p>When you open that file, search for the datasource element that contains the configuration for the affected datasource. There you will find a snippet that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;var</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">'timeout'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1200.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/number<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/var<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Stop the ColdFusion-server/instance, change the timeout-setting here to some value less than that of your MySQL server's <code>wait_timeout</code>, restart the server/the instance and hope for the best - because I haven't tried that one yet and I don't know if it would have some negative impact in performance or stability of ColdFusion.</p>
<p>What I do know though is that if you decide to edit this file manually, you cannot ever use the ColdFusion administrator to change any settings of the changed datasource without the risk that ColdFusion will then overwrite your custom setting with the built-in default. So as I said before: Changing the settings on the MySQL server side just makes more sense if that is an option for you.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;bodytext=UPDATE%3A%20We%20have%20now%20found%20the%20cause%20of%20the%20issue.%20Please%20scroll%20to%20the%20end%20of%20the%20article%20for%20explanation%20and%20workaround.%0D%0A%0D%0AIn%20one%20of%20our%20latest%20projects%20we%20need%20to%20access%20a%20MySQL%205.1%20server%20%285.1.45%29%20from%20ColdFusion%208%20%288%2C0%2C1%2C195765%29.%20Creating%20the%20da" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;notes=UPDATE%3A%20We%20have%20now%20found%20the%20cause%20of%20the%20issue.%20Please%20scroll%20to%20the%20end%20of%20the%20article%20for%20explanation%20and%20workaround.%0D%0A%0D%0AIn%20one%20of%20our%20latest%20projects%20we%20need%20to%20access%20a%20MySQL%205.1%20server%20%285.1.45%29%20from%20ColdFusion%208%20%288%2C0%2C1%2C195765%29.%20Creating%20the%20da" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;t=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;annotation=UPDATE%3A%20We%20have%20now%20found%20the%20cause%20of%20the%20issue.%20Please%20scroll%20to%20the%20end%20of%20the%20article%20for%20explanation%20and%20workaround.%0D%0A%0D%0AIn%20one%20of%20our%20latest%20projects%20we%20need%20to%20access%20a%20MySQL%205.1%20server%20%285.1.45%29%20from%20ColdFusion%208%20%288%2C0%2C1%2C195765%29.%20Creating%20the%20da" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=UPDATE%3A%20We%20have%20now%20found%20the%20cause%20of%20the%20issue.%20Please%20scroll%20to%20the%20end%20of%20the%20article%20for%20explanation%20and%20workaround.%0D%0A%0D%0AIn%20one%20of%20our%20latest%20projects%20we%20need%20to%20access%20a%20MySQL%205.1%20server%20%285.1.45%29%20from%20ColdFusion%208%20%288%2C0%2C1%2C195765%29.%20Creating%20the%20da" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;bm_description=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;t=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&opener=bm&amp;ei=UTF-8&amp;d=UPDATE%3A%20We%20have%20now%20found%20the%20cause%20of%20the%20issue.%20Please%20scroll%20to%20the%20end%20of%20the%20article%20for%20explanation%20and%20workaround.%0D%0A%0D%0AIn%20one%20of%20our%20latest%20projects%20we%20need%20to%20access%20a%20MySQL%205.1%20server%20%285.1.45%29%20from%20ColdFusion%208%20%288%2C0%2C1%2C195765%29.%20Creating%20the%20da" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;t=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;submitHeadline=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;submitSummary=UPDATE%3A%20We%20have%20now%20found%20the%20cause%20of%20the%20issue.%20Please%20scroll%20to%20the%20end%20of%20the%20article%20for%20explanation%20and%20workaround.%0D%0A%0D%0AIn%20one%20of%20our%20latest%20projects%20we%20need%20to%20access%20a%20MySQL%205.1%20server%20%285.1.45%29%20from%20ColdFusion%208%20%288%2C0%2C1%2C195765%29.%20Creating%20the%20da&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;exttitle=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F06%2Fcoldfusion-8-and-mysql-5-1-via-jdbc-help-needed%2F&amp;bm_description=ColdFusion%208%20and%20MySQL%205.1%20via%20JDBC%3A%20Help%20needed%21%20%5BSolved%5D&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/06/coldfusion-8-and-mysql-5-1-via-jdbc-help-needed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ColdFusion UDF to get Unix Timestamp from Date</title>
		<link>http://devbox.computec.de/2010/05/coldfusion-udf-to-get-unix-timestamp-from-date/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-udf-to-get-unix-timestamp-from-date</link>
		<comments>http://devbox.computec.de/2010/05/coldfusion-udf-to-get-unix-timestamp-from-date/#comments</comments>
		<pubDate>Fri, 28 May 2010 13:44:16 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datediff]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[unix timestamp]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=474</guid>
		<description><![CDATA[For some legacy MySQL database application I really need Unix timestamps - and I need them in ColdFusion, so MySQL's UNIX_TIMESTAMP just wasn't sufficient for the job. At first I though I could get away with a simple DateDiff - and the result did look plausible. A closer look revealed however that there is probably [...]]]></description>
			<content:encoded><![CDATA[<p>For some legacy MySQL database application I really need Unix timestamps - and I need them in ColdFusion, so MySQL's UNIX_TIMESTAMP just wasn't sufficient for the job. At first I though I could get away with a simple DateDiff - and the result did look plausible. A closer look revealed however that there is probably something fishy going on with DateDiff in ColdFusion. I strongly suspect Daylight Saving Time, though I can't really say at this moment.<br />
<span id="more-474"></span><br />
So as always when I get stuck with ColdFusion, I give Java a chance at solving the problem. Here's what I came up with:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;CF2UnixTS&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;no&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;numeric&quot;</span></span>
<span style="color: #333333;">	<span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;calculates a Unix Timestamp from a DateTime value&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;tsTheDate&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;date&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
	var local=structNew();
	local.objCalendar = createObject('java'
				,'java.util.Calendar').getInstance();
	local.objCalendar.clear();
	local.objCalendar.set(year(arguments.tsTheDate)
			,month(arguments.tsTheDate)-1
			,day(arguments.tsTheDate)
			,hour(arguments.tsTheDate)
			,minute(arguments.tsTheDate)
			,second(arguments.tsTheDate));
	local.iUnixTS = int(local.objCalendar.getTimeInMillis()/1000);
	return local.iUnixTS;	
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
	dtLocal = DateAdd('M',7,now());
	iUnixTS = CF2UnixTS(dtLocal);
	iDateDiff = DateDiff('s',CreateDate(1970,1,1),dtLocal);
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;getTS&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#APPLICATION.strSomeDS#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
	SELECT UNIX_TIMESTAMP(<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfqueryparam</span> cfsqltype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> </span>
<span style="color: #333333;">			<span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#DateFormat(dtLocal, 'yyyy-MM-dd' ) </span>
<span style="color: #333333;">			&amp; ' ' &amp; TimeFormat(dtLocal, 'HH:mm:ss' )#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
			) AS uxts;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
	dtLocal : <span style="color: #0000FF;">#dtLocal#</span> <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">br</span> <span style="color: #0000FF;">/&gt;</span></span>
	iUnixTS : <span style="color: #0000FF;">#iUnixTS#</span> <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">br</span> <span style="color: #0000FF;">/&gt;</span></span>
	getTS.uxts: <span style="color: #0000FF;">#getTS.uxts#</span> <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">br</span> <span style="color: #0000FF;">/&gt;</span></span>
	DateDiff: <span style="color: #0000FF;">#iDateDiff#</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>This gives me
<pre>
dtLocal : {ts '2010-12-28 15:33:14'}
iUnixTS : 1293546794
getTS.uxts: 1293546794
DateDiff: 1293550394
</pre>
<p></p>
<p>The values from the UDF and the one generated by MySQL are the same. The DateDiff-value is off by minus one hour exactly.</p>
<p>Maybe I am doing something overly complicated here. Is there some easier way to get at the Unix timestamp of a date in ColdFusion?</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;bodytext=For%20some%20legacy%20MySQL%20database%20application%20I%20really%20need%20Unix%20timestamps%20-%20and%20I%20need%20them%20in%20ColdFusion%2C%20so%20MySQL%27s%20UNIX_TIMESTAMP%20just%20wasn%27t%20sufficient%20for%20the%20job.%20At%20first%20I%20though%20I%20could%20get%20away%20with%20a%20simple%20DateDiff%20-%20and%20the%20result%20did%20loo" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;notes=For%20some%20legacy%20MySQL%20database%20application%20I%20really%20need%20Unix%20timestamps%20-%20and%20I%20need%20them%20in%20ColdFusion%2C%20so%20MySQL%27s%20UNIX_TIMESTAMP%20just%20wasn%27t%20sufficient%20for%20the%20job.%20At%20first%20I%20though%20I%20could%20get%20away%20with%20a%20simple%20DateDiff%20-%20and%20the%20result%20did%20loo" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;t=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;annotation=For%20some%20legacy%20MySQL%20database%20application%20I%20really%20need%20Unix%20timestamps%20-%20and%20I%20need%20them%20in%20ColdFusion%2C%20so%20MySQL%27s%20UNIX_TIMESTAMP%20just%20wasn%27t%20sufficient%20for%20the%20job.%20At%20first%20I%20though%20I%20could%20get%20away%20with%20a%20simple%20DateDiff%20-%20and%20the%20result%20did%20loo" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=For%20some%20legacy%20MySQL%20database%20application%20I%20really%20need%20Unix%20timestamps%20-%20and%20I%20need%20them%20in%20ColdFusion%2C%20so%20MySQL%27s%20UNIX_TIMESTAMP%20just%20wasn%27t%20sufficient%20for%20the%20job.%20At%20first%20I%20though%20I%20could%20get%20away%20with%20a%20simple%20DateDiff%20-%20and%20the%20result%20did%20loo" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;bm_description=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;t=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&opener=bm&amp;ei=UTF-8&amp;d=For%20some%20legacy%20MySQL%20database%20application%20I%20really%20need%20Unix%20timestamps%20-%20and%20I%20need%20them%20in%20ColdFusion%2C%20so%20MySQL%27s%20UNIX_TIMESTAMP%20just%20wasn%27t%20sufficient%20for%20the%20job.%20At%20first%20I%20though%20I%20could%20get%20away%20with%20a%20simple%20DateDiff%20-%20and%20the%20result%20did%20loo" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;t=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;submitHeadline=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;submitSummary=For%20some%20legacy%20MySQL%20database%20application%20I%20really%20need%20Unix%20timestamps%20-%20and%20I%20need%20them%20in%20ColdFusion%2C%20so%20MySQL%27s%20UNIX_TIMESTAMP%20just%20wasn%27t%20sufficient%20for%20the%20job.%20At%20first%20I%20though%20I%20could%20get%20away%20with%20a%20simple%20DateDiff%20-%20and%20the%20result%20did%20loo&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;exttitle=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-get-unix-timestamp-from-date%2F&amp;bm_description=ColdFusion%20UDF%20to%20get%20Unix%20Timestamp%20from%20Date&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/05/coldfusion-udf-to-get-unix-timestamp-from-date/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ColdFusion UDF to generate SEO-friendly URL strings</title>
		<link>http://devbox.computec.de/2010/05/coldfusion-udf-to-generate-seo-friendly-url-strings/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coldfusion-udf-to-generate-seo-friendly-url-strings</link>
		<comments>http://devbox.computec.de/2010/05/coldfusion-udf-to-generate-seo-friendly-url-strings/#comments</comments>
		<pubDate>Thu, 20 May 2010 15:22:01 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[diacritic]]></category>
		<category><![CDATA[i8n]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=470</guid>
		<description><![CDATA[This function might be convenient if you need to create a seo-friendly URL from a headline that could contain special characters such as German umlauts or accented letters; spaces would be replaced by dashes as recommended by Matt Cutts of Google. Unrecognized characters in a certain Unicode range will finally be replaced by x's, everything [...]]]></description>
			<content:encoded><![CDATA[<p>This function might be convenient if you need to create a seo-friendly URL from a headline that could contain special characters such as German umlauts or accented letters; spaces would be replaced by dashes as recommended by Matt Cutts of Google. Unrecognized characters in a certain Unicode range will finally be replaced by x's, everything that's still not recognized will simply be dropped.<br />
<span id="more-470"></span></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;parse4URL&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;returns a URL safe string&quot;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000FF;">default</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
var returnString = arguments.string;
var InvalidChars = &quot;à,ô,ď,ḟ,ë,š,ơ,ß,ă,ř,ț,ň,ā,ķ,ŝ,ỳ,ņ,ĺ,ħ,ṗ,ó,ú,ě,é,ç,ẁ,ċ,õ,ṡ,ø,ģ,ŧ,ș,ė,ĉ,ś,î,ű,ć,ę,ŵ,ṫ,ū,č,ö,è,ŷ,ą,ł,ų,ů,ş,ğ,ļ,ƒ,ž,ẃ,ḃ,å,ì,ï,ḋ,ť,ŗ,ä,í,ŕ,ê,ü,ò,ē,ñ,ń,ĥ,ĝ,đ,ĵ,ÿ,ũ,ŭ,ư,ţ,ý,ő,â,ľ,ẅ,ż,ī,ã,ġ,ṁ,ō,ĩ,ù,į,ź,á,û,þ,ð,æ,µ,ĕ,À,Ô,Ď,Ḟ,Ë,Š,Ơ,Ă,Ř,Ț,Ň,Ā,Ķ,Ŝ,Ỳ,Ņ,Ĺ,Ħ,Ṗ,Ó,Ú,Ě,É,Ç,Ẁ,Ċ,Õ,Ṡ,Ø,Ģ,Ŧ,Ș,Ė,Ĉ,Ś,Î,Ű,Ć,Ę,Ŵ,Ṫ,Ū,Č,Ö,È,Ŷ,Ą,Ł,Ų,Ů,Ş,Ğ,Ļ,Ƒ,Ž,Ẃ,Ḃ,Å,Ì,Ï,Ḋ,Ť,Ŗ,Ä,Í,Ŕ,Ê,Ü,Ò,Ē,Ñ,Ń,Ĥ,Ĝ,Đ,Ĵ,Ÿ,Ũ,Ŭ,Ư,Ţ,Ý,Ő,Â,Ľ,Ẅ,Ż,Ī,Ã,Ġ,Ṁ,Ō,Ĩ,Ù,Į,Ź,Á,Û,Þ,Ð,Æ,Μ,Ĕ&quot;;
var ValidChars 	 = &quot;a,o,d,f,e,s,o,ss,a,r,t,n,a,k,s,y,n,l,h,p,o,u,e,e,c,w,c,o,s,o,g,t,s,e,c,s,i,u,c,e,w,t,u,c,oe,e,y,a,l,u,u,s,g,l,f,z,w,b,a,i,i,d,t,r,ae,i,r,e,ue,o,e,n,n,h,g,d,j,y,u,u,u,t,y,o,a,l,w,z,i,a,g,m,o,i,u,i,z,a,u,th,dh,ae,u,e,A,O,D,F,E,S,O,A,R,T,N,A,K,S,Y,N,L,H,P,O,U,E,E,C,W,C,O,S,O,G,T,S,E,C,S,I,U,C,E,W,T,U,C,Oe,E,Y,A,L,U,U,S,G,L,F,Z,W,B,A,I,I,D,T,R,Ae,I,R,E,Ue,O,E,N,N,H,G,D,J,Y,U,U,U,T,Y,O,A,L,W,Z,I,A,G,M,O,I,U,I,Z,A,U,TH,Dh,Ae,U,E&quot;;
&nbsp;
// trim the string
returnString = Trim(returnString);
returnString = StripCR(returnString);
// replace known characters with the corresponding safe characters
returnString = ReplaceList(returnString,InvalidChars,ValidChars);
// replace unknown characters in the x00-x7F-range with x's
returnString = returnString.ReplaceAll('[^\x00-\x7F]','x');
&nbsp;
// Replace one or many comma with a dash
returnString = returnString.ReplaceAll(',+', '-');
// Other substitutions
returnString = Replace(returnString, &quot;%&quot;, &quot;percent&quot;,&quot;ALL&quot;);
returnString = Replace(returnString, &quot;&amp;amp;&quot;, &quot; and &quot;,&quot;ALL&quot;);
returnString = Replace(returnString, &quot;&amp;&quot;, &quot; and &quot;,&quot;ALL&quot;);
returnString = returnString.ReplaceAll('[:,/]', '-');
// Replace one or more whitespace characters with a dash
returnString = returnString.ReplaceAll('[\s]+', '-');
// And everything else simply has to go
returnString = returnString.ReplaceAll('[^A-Za-z0-9\/-]','');
// finally replace multiple dash characters with just one
returnString = returnString.ReplaceAll('-+','-');
// we're done
return returnString;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>This should probably cover most of your needs if you need to deal with European languages.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;bodytext=This%20function%20might%20be%20convenient%20if%20you%20need%20to%20create%20a%20seo-friendly%20URL%20from%20a%20headline%20that%20could%20contain%20special%20characters%20such%20as%20German%20umlauts%20or%20accented%20letters%3B%20spaces%20would%20be%20replaced%20by%20dashes%20as%20recommended%20by%20Matt%20Cutts%20of%20Google.%20Un" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;notes=This%20function%20might%20be%20convenient%20if%20you%20need%20to%20create%20a%20seo-friendly%20URL%20from%20a%20headline%20that%20could%20contain%20special%20characters%20such%20as%20German%20umlauts%20or%20accented%20letters%3B%20spaces%20would%20be%20replaced%20by%20dashes%20as%20recommended%20by%20Matt%20Cutts%20of%20Google.%20Un" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;t=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;annotation=This%20function%20might%20be%20convenient%20if%20you%20need%20to%20create%20a%20seo-friendly%20URL%20from%20a%20headline%20that%20could%20contain%20special%20characters%20such%20as%20German%20umlauts%20or%20accented%20letters%3B%20spaces%20would%20be%20replaced%20by%20dashes%20as%20recommended%20by%20Matt%20Cutts%20of%20Google.%20Un" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=This%20function%20might%20be%20convenient%20if%20you%20need%20to%20create%20a%20seo-friendly%20URL%20from%20a%20headline%20that%20could%20contain%20special%20characters%20such%20as%20German%20umlauts%20or%20accented%20letters%3B%20spaces%20would%20be%20replaced%20by%20dashes%20as%20recommended%20by%20Matt%20Cutts%20of%20Google.%20Un" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;bm_description=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;t=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&opener=bm&amp;ei=UTF-8&amp;d=This%20function%20might%20be%20convenient%20if%20you%20need%20to%20create%20a%20seo-friendly%20URL%20from%20a%20headline%20that%20could%20contain%20special%20characters%20such%20as%20German%20umlauts%20or%20accented%20letters%3B%20spaces%20would%20be%20replaced%20by%20dashes%20as%20recommended%20by%20Matt%20Cutts%20of%20Google.%20Un" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;t=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;submitHeadline=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;submitSummary=This%20function%20might%20be%20convenient%20if%20you%20need%20to%20create%20a%20seo-friendly%20URL%20from%20a%20headline%20that%20could%20contain%20special%20characters%20such%20as%20German%20umlauts%20or%20accented%20letters%3B%20spaces%20would%20be%20replaced%20by%20dashes%20as%20recommended%20by%20Matt%20Cutts%20of%20Google.%20Un&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;exttitle=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fcoldfusion-udf-to-generate-seo-friendly-url-strings%2F&amp;bm_description=ColdFusion%20UDF%20to%20generate%20SEO-friendly%20URL%20strings&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/05/coldfusion-udf-to-generate-seo-friendly-url-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL DBA Snippet: Largest Tables in a Database</title>
		<link>http://devbox.computec.de/2010/05/postgresql-dba-snippet-largest-tables-in-a-database/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=postgresql-dba-snippet-largest-tables-in-a-database</link>
		<comments>http://devbox.computec.de/2010/05/postgresql-dba-snippet-largest-tables-in-a-database/#comments</comments>
		<pubDate>Tue, 18 May 2010 14:47:27 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[Admin-Stuff]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[dba]]></category>
		<category><![CDATA[pgsql]]></category>
		<category><![CDATA[size]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=466</guid>
		<description><![CDATA[For my own reference - this little query will list all the tables in the current database with their respective physical size, including indexes and TOAST:

SELECT table_schema
       , table_name
       , pg_size_pretty&#40;pg_total_relation_size&#40;table_schema &#124;&#124; '.' &#124;&#124; table_name&#41;&#41;
      , pg_total_relation_size&#40;table_schema &#124;&#124; [...]]]></description>
			<content:encoded><![CDATA[<p>For my own reference - this little query will list all the tables in the current database with their respective physical size, including indexes and TOAST:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> table_schema
       <span style="color: #66cc66;">,</span> table_name
       <span style="color: #66cc66;">,</span> pg_size_pretty<span style="color: #66cc66;">&#40;</span>pg_total_relation_size<span style="color: #66cc66;">&#40;</span>table_schema <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">||</span> table_name<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">,</span> pg_total_relation_size<span style="color: #66cc66;">&#40;</span>table_schema <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">||</span> table_name<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">FROM</span> information_schema<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">TABLES</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> table_type <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'BASE TABLE'</span> 
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> pg_total_relation_size <span style="color: #993333; font-weight: bold;">DESC</span>;</pre></div></div>




Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;bodytext=For%20my%20own%20reference%20-%20this%20little%20query%20will%20list%20all%20the%20tables%20in%20the%20current%20database%20with%20their%20respective%20physical%20size%2C%20including%20indexes%20and%20TOAST%3A%0D%0A%0D%0A%0D%0ASELECT%20table_schema%0D%0A%20%20%20%20%20%20%20%2C%20table_name%0D%0A%20%20%20%20%20%20%20%2C%20pg_size_pretty%28pg_total_relation_size%28" title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;notes=For%20my%20own%20reference%20-%20this%20little%20query%20will%20list%20all%20the%20tables%20in%20the%20current%20database%20with%20their%20respective%20physical%20size%2C%20including%20indexes%20and%20TOAST%3A%0D%0A%0D%0A%0D%0ASELECT%20table_schema%0D%0A%20%20%20%20%20%20%20%2C%20table_name%0D%0A%20%20%20%20%20%20%20%2C%20pg_size_pretty%28pg_total_relation_size%28" title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;t=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;annotation=For%20my%20own%20reference%20-%20this%20little%20query%20will%20list%20all%20the%20tables%20in%20the%20current%20database%20with%20their%20respective%20physical%20size%2C%20including%20indexes%20and%20TOAST%3A%0D%0A%0D%0A%0D%0ASELECT%20table_schema%0D%0A%20%20%20%20%20%20%20%2C%20table_name%0D%0A%20%20%20%20%20%20%20%2C%20pg_size_pretty%28pg_total_relation_size%28" title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=For%20my%20own%20reference%20-%20this%20little%20query%20will%20list%20all%20the%20tables%20in%20the%20current%20database%20with%20their%20respective%20physical%20size%2C%20including%20indexes%20and%20TOAST%3A%0D%0A%0D%0A%0D%0ASELECT%20table_schema%0D%0A%20%20%20%20%20%20%20%2C%20table_name%0D%0A%20%20%20%20%20%20%20%2C%20pg_size_pretty%28pg_total_relation_size%28" title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;bm_description=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;t=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&opener=bm&amp;ei=UTF-8&amp;d=For%20my%20own%20reference%20-%20this%20little%20query%20will%20list%20all%20the%20tables%20in%20the%20current%20database%20with%20their%20respective%20physical%20size%2C%20including%20indexes%20and%20TOAST%3A%0D%0A%0D%0A%0D%0ASELECT%20table_schema%0D%0A%20%20%20%20%20%20%20%2C%20table_name%0D%0A%20%20%20%20%20%20%20%2C%20pg_size_pretty%28pg_total_relation_size%28" title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;t=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;submitHeadline=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;submitSummary=For%20my%20own%20reference%20-%20this%20little%20query%20will%20list%20all%20the%20tables%20in%20the%20current%20database%20with%20their%20respective%20physical%20size%2C%20including%20indexes%20and%20TOAST%3A%0D%0A%0D%0A%0D%0ASELECT%20table_schema%0D%0A%20%20%20%20%20%20%20%2C%20table_name%0D%0A%20%20%20%20%20%20%20%2C%20pg_size_pretty%28pg_total_relation_size%28&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;exttitle=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Fpostgresql-dba-snippet-largest-tables-in-a-database%2F&amp;bm_description=PostgreSQL%20DBA%20Snippet%3A%20Largest%20Tables%20in%20a%20Database&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/05/postgresql-dba-snippet-largest-tables-in-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Full-text search with ColdFusion using Sphinx</title>
		<link>http://devbox.computec.de/2010/05/full-text-search-with-coldfusion-using-sphinx/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=full-text-search-with-coldfusion-using-sphinx</link>
		<comments>http://devbox.computec.de/2010/05/full-text-search-with-coldfusion-using-sphinx/#comments</comments>
		<pubDate>Wed, 05 May 2010 11:18:30 +0000</pubDate>
		<dc:creator>Markus Wollny</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[cfc]]></category>
		<category><![CDATA[fulltext]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[sphinx]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://devbox.computec.de/?p=392</guid>
		<description><![CDATA[A thorough tutorial on using the Sphinx search engine for ColdFusion developers, from compilation and setup to using the Java Sphinx API in a CFC.]]></description>
			<content:encoded><![CDATA[<p>Full text searching is and probably will be for a long time an interesting challenge for any database driven application. Of course ColdFusion already offers a couple of options, though I found most of them somewhat lacking in features or quite complicated to set up.<br />
<!--pagetitle:Introduction--><br />
As we're running mostly on <a href="http://www.postgresql.org/">PostgreSQL</a> as database backend, we used to rely solely on the built-in <a href="http://www.postgresql.org/docs/current/static/tsearch2.html">TSearch2</a> full text search methods of that database. But over the years we have accumulated so much data, some of which is nicely distributed over several tables (the dark side of normalization), that we were really yearning for a less table based and more document focused indexing mechanism - and more speed than TSearch2 could deliver.</p>
<p>Verity never really quite met all of our needs and was a real pain to set up and maintain. CF 9's <a href="http://lucene.apache.org/solr/">Solr</a>, which is based on <a href="http://lucene.apache.org/java/docs/index.html">Lucene</a>, might be a mighty step forward, but we're still running on ColdFusion 8, so I really cannot say a lot about handling and performance of the new indexing beast.</p>
<p>For our use cases (i.e. indexing of articles, products in our CMS as well as our forums), <a href="http://sphinxsearch.com/">Sphinx</a> (for <b>S</b>QL <b>Ph</b>rase <b>In</b>de<b>x</b>) has shown some amazing results - and we're using it for a couple of months now. In this article I'll show you how to compile, set up and use Sphinx in your ColdFusion application to retrieve search results from documents stored in a PostgreSQL or MySQL database.<br />
<span id="more-392"></span><br />
At the time of writing this article, the current version of Sphinx is 0.9.9-release. I assume you intend to deploy the Sphinx server on a Linux box (I'm using Debian Lenny) and are familiar with compiling code - if you're on Windows, you should get the binary distribution and see docs for installation.</p>
<p>The server you'll want to run Sphinx may or may not be the same as your ColdFusion box, though I'd recommend you set up a separate machine with a generous amount of RAM - Sphinx will store indexes completely in memory which explains the amazing search speed, so the more data you wish to index, the more RAM you should provide.</p>
<p><a href="http://devbox.computec.de/2010/05/full-text-search-with-coldfusion-using-sphinx/2/">Next page: Compiling Sphinx</a></p>



Share and Enjoy:


	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;partner=sociable" title="Print"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;bodytext=A%20thorough%20tutorial%20on%20using%20the%20Sphinx%20search%20engine%20for%20ColdFusion%20developers%2C%20from%20compilation%20and%20setup%20to%20using%20the%20Java%20Sphinx%20API%20in%20a%20CFC." title="Digg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;notes=A%20thorough%20tutorial%20on%20using%20the%20Sphinx%20search%20engine%20for%20ColdFusion%20developers%2C%20from%20compilation%20and%20setup%20to%20using%20the%20Java%20Sphinx%20API%20in%20a%20CFC." title="del.icio.us"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;t=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="Facebook"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;annotation=A%20thorough%20tutorial%20on%20using%20the%20Sphinx%20search%20engine%20for%20ColdFusion%20developers%2C%20from%20compilation%20and%20setup%20to%20using%20the%20Java%20Sphinx%20API%20in%20a%20CFC." title="Google Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;source=devbox%40COMPUTEC+The+Computec+development+blog&amp;summary=A%20thorough%20tutorial%20on%20using%20the%20Sphinx%20search%20engine%20for%20ColdFusion%20developers%2C%20from%20compilation%20and%20setup%20to%20using%20the%20Java%20Sphinx%20API%20in%20a%20CFC." title="LinkedIn"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.de/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;bm_description=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;plugin=soc" title="MisterWong.DE"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong.DE" alt="MisterWong.DE" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F" title="Netvibes"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="Reddit"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://slashdot.org/bookmark.pl?title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F" title="Slashdot"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="StumbleUpon"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F" title="Technorati"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Full-text%20search%20with%20ColdFusion%20using%20Sphinx%20-%20http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F" title="Twitter"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;t=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&opener=bm&amp;ei=UTF-8&amp;d=A%20thorough%20tutorial%20on%20using%20the%20Sphinx%20search%20engine%20for%20ColdFusion%20developers%2C%20from%20compilation%20and%20setup%20to%20using%20the%20Java%20Sphinx%20API%20in%20a%20CFC." title="Yahoo! Bookmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://linkarena.com/bookmarks/addlink/?url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="LinkArena"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/linkarena.png" title="LinkArena" alt="LinkArena" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="Live"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;t=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="MySpace"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;submitHeadline=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;submitSummary=A%20thorough%20tutorial%20on%20using%20the%20Sphinx%20search%20engine%20for%20ColdFusion%20developers%2C%20from%20compilation%20and%20setup%20to%20using%20the%20Java%20Sphinx%20API%20in%20a%20CFC.&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://yigg.de/neu?exturl=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;exttitle=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="Yigg"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="blogmarks"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://faves.com/Authoring.aspx?u=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx" title="Faves"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/bluedot.png" title="Faves" alt="Faves" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;link=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F" title="FriendFeed"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fdevbox.computec.de%2F2010%2F05%2Ffull-text-search-with-coldfusion-using-sphinx%2F&amp;bm_description=Full-text%20search%20with%20ColdFusion%20using%20Sphinx&amp;plugin=soc" title="MisterWong"><img src="http://devbox.computec.de/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://devbox.computec.de/2010/05/full-text-search-with-coldfusion-using-sphinx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
