<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-11805603</id><updated>2011-11-27T17:52:12.603-06:00</updated><title type='text'>Daryl's ColdFusion Notes</title><subtitle type='html'>Notes from the field on ColdFusion (or related) technical issues.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-11805603.post-5385736941003946179</id><published>2011-06-23T17:21:00.000-05:00</published><updated>2011-06-23T17:21:05.839-05:00</updated><title type='text'>SQL Server db_executor Role</title><content type='html'>OK, so SQL Server &lt;i&gt;still&lt;/i&gt; doesn't have a db_executor role.&lt;br /&gt;&lt;br /&gt;Here's a way to add one to any given database:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&amp;nbsp;&lt;br /&gt;if not exists (select * from sys.database_principals where name='db_executor' and type='R')&lt;br /&gt; create role db_executor&lt;br /&gt;&lt;br /&gt;declare @name sysname&lt;br /&gt;declare @sql nvarchar(250)&lt;br /&gt;&lt;br /&gt;declare cur cursor for&lt;br /&gt; select name&lt;br /&gt; from sys.procedures&lt;br /&gt; order by name&lt;br /&gt;&lt;br /&gt;open cur&lt;br /&gt;fetch next from cur into @name&lt;br /&gt;while @@FETCH_STATUS = 0 begin&lt;br /&gt; set @sql = N'grant execute on OBJECT::'+@name+N' to db_executor'&lt;br /&gt; print @sql&lt;br /&gt; exec sp_executesql @sql&lt;br /&gt; fetch next from cur into @name&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;close cur&lt;br /&gt;deallocate cur&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You'll need to re-run this every time you create a new stored procedure.  You could expand on this to loop through all non-Master databases, or to use the DDL trigger feature of SQL Server 2005+, like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&amp;nbsp;&lt;br /&gt;create trigger add_executor_role&lt;br /&gt;on database&lt;br /&gt;for create_procedure&lt;br /&gt;as begin&lt;br /&gt; [sql from above goes here]&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;(For more on DDL triggers, see &lt;a href="http://www.sqlteam.com/article/using-ddl-triggers-in-sql-server-2005-to-capture-schema-changes"&gt;Using DDL Triggers in SQL Server 2005 to Capture Schema Changes&lt;/a&gt;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-5385736941003946179?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/5385736941003946179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2011/06/sql-server-dbexecutor-role.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/5385736941003946179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/5385736941003946179'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2011/06/sql-server-dbexecutor-role.html' title='SQL Server db_executor Role'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-1585368667842169300</id><published>2010-06-01T11:00:00.002-05:00</published><updated>2010-06-01T11:16:27.759-05:00</updated><title type='text'>CreateODBCDate Retains Time Data</title><content type='html'>Had an interesting "WTF moment" over the weekend.  I tried to prevent a batch job from running on Memorial Day by using the following code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfif dateCompare(createOBDCDate(now()), "May 31, 2010") is 0&gt;&lt;br /&gt;    &amp;lt;cfabort /&gt;&lt;br /&gt;&amp;lt;/cfif&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But this failed to stop the job from running..?  So I investigated further:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfoutput&gt;&lt;br /&gt;&amp;lt;cfset today = createOBDCDate(now()) /&gt;&lt;br /&gt;#today#&amp;lt;br /&gt;&lt;br /&gt;#createODBCDate("May 31, 2010")#&amp;lt;br /&gt;&lt;br /&gt;#datecompare(today, "May 31, 2010")#&lt;br /&gt;&amp;lt;/cfoutput&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Which produced:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;{d '2010-05-31'}&lt;br /&gt;{d '2010-05-31'}&lt;br /&gt;1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Okay... so those dates are different.  WTF?&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfoutput&gt;&lt;br /&gt;&amp;lt;cfset today = createOBDCDate(now()) /&gt;&lt;br /&gt;#today#&amp;lt;br /&gt;&lt;br /&gt;#timeformat(today)#&amp;lt;br /&gt;&lt;br /&gt;#createODBCDate("May 31, 2010")#&amp;lt;br /&gt;&lt;br /&gt;#datecompare(today, createODBCDate("May 31, 2010"))#&lt;br /&gt;&amp;lt;/cfoutput&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This returned:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;{d '2010-05-31'}&lt;br /&gt;12:11 PM&lt;br /&gt;{d '2010-05-31'}&lt;br /&gt;1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So... while CreateODBCDate() returns a formatted SQL date-only string, it invisibly retains the time information.  Wow.&lt;br /&gt;&lt;br /&gt;I wound up doing it the hard way:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset today = createDate(year(now()), month(now()), day(now()))&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;sigh /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-1585368667842169300?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/1585368667842169300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2010/06/createodbcdate-retains-time-data.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/1585368667842169300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/1585368667842169300'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2010/06/createodbcdate-retains-time-data.html' title='CreateODBCDate Retains Time Data'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-6773715455377805164</id><published>2009-01-26T09:08:00.002-06:00</published><updated>2009-01-26T09:21:10.957-06:00</updated><title type='text'>ListFirst, ListRest in SQL Server</title><content type='html'>So, this has probably been done a million times before, but I needed ColdFusion-style ListFirst and ListRest functions for creating a stored procedure in a database that violates First Normal Form.  &amp;lt;sigh/&gt;&lt;br /&gt;&lt;br /&gt;Note that the behavior varies slightly from CF.  The delimiter is forced to be a comma, and multiple consecutive delimiters are treated as multiple elements.  (CF eating 3 commas at a time always annoyed me.)&lt;br /&gt;&lt;br /&gt;So, here's the DDL for them:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;CREATE FUNCTION [dbo].[listFirst] (@list nvarchar(4000))&lt;br /&gt;RETURNS nvarchar(4000)&lt;br /&gt;AS BEGIN&lt;br /&gt;   DECLARE @pos int&lt;br /&gt;   DECLARE @ret nvarchar(4000)&lt;br /&gt;   SET @pos = charindex(',', @list)&lt;br /&gt;   IF @pos &gt; 0&lt;br /&gt;       SET @ret = left(@list, @pos-1)&lt;br /&gt;   ELSE&lt;br /&gt;       set @ret = @list&lt;br /&gt;   RETURN @ret&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE FUNCTION [dbo].[listRest] (@list nvarchar(4000))&lt;br /&gt;RETURNS nvarchar(4000)&lt;br /&gt;AS BEGIN&lt;br /&gt;   DECLARE @pos int&lt;br /&gt;   DECLARE @ret nvarchar(4000)&lt;br /&gt;   SET @pos = charindex(',', @list)&lt;br /&gt;   IF @pos &gt; 0&lt;br /&gt;       SET @ret = substring(@list, @pos+1, len(@list)-@pos)&lt;br /&gt;   ELSE&lt;br /&gt;       SET @ret = ''&lt;br /&gt;   RETURN @ret&lt;br /&gt;END&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As a side note, it just occurred to me that you can probably work around the multiple consecutive delimiter thing by adding whitespace, then trimming:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfloop list="#replace(myList, ",", ", ", "ALL")#" index="item"&gt;&lt;br /&gt;   &amp;lt;cfset item=trim(item) /&gt;&lt;br /&gt;   ...&lt;br /&gt;&amp;lt;/cfloop&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Why didn't I think of that years ago?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-6773715455377805164?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/6773715455377805164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2009/01/listfirst-listrest-in-sql-server.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/6773715455377805164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/6773715455377805164'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2009/01/listfirst-listrest-in-sql-server.html' title='ListFirst, ListRest in SQL Server'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-465190704019962519</id><published>2009-01-21T13:56:00.004-06:00</published><updated>2009-01-21T14:09:14.516-06:00</updated><title type='text'>Automatically Fix Case Sensitivity Issues</title><content type='html'>&lt;div&gt;When you're converting from Windows, with a case-insensitive file system, to just about any other operating system, you'll likely run into file naming issues.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you have a file named MyInclude.cfm, and you try to use it in ColdFusion as &amp;lt;cfinclude template="myInclude.cfm" /&gt; (note the lowercase "m"), this will work fine in Windows, but then fail on the new OS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I've written a small template to automagically repair most of these problems. and you can download it here: &lt;a href="http://www.cfprimer.com/download.cfm?ffFile=_referenceFixer.cfm"&gt;http://www.cfprimer.com/download.cfm?ffFile=_referenceFixer.cfm&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To plagarize mercilessly from its comments:&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Purpose:&lt;br /&gt;&lt;br /&gt; Fix file and directory name references in files, for transitioning from Windows (with case&lt;br /&gt; insensitive filenames) to another OS (eg Linux) with case sensitive file names.&lt;br /&gt;&lt;br /&gt; NOTE: If you have two different files (perhaps in different directories) with the same name,&lt;br /&gt; but different case, this will not work as well as hoped.  (All references will get set to &lt;br /&gt; one or the other case.)&lt;br /&gt; &lt;br /&gt;Use:&lt;br /&gt;&lt;br /&gt; Place _referenceFixer.cfm in a document directory and load.&lt;br /&gt; Template will start from its current directory and proceed to find all file and directory &lt;br /&gt; names in that directory and its subdirectories.&lt;br /&gt; &lt;br /&gt; If "updateFiles" is set to True, the files will be rewritten and references fixed.&lt;br /&gt; &lt;br /&gt; "fileExtensions" should be set to list the files whose references should be checked&lt;br /&gt; and (if updateFiles is true) fixed, eg. ".cfm,.html".&lt;br /&gt; &lt;br /&gt; Templates beginning with an underscore character ("_") will be skipped.&lt;br /&gt; &lt;br /&gt; Do NOT leave this on production servers..!&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-465190704019962519?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/465190704019962519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2009/01/automatically-fix-case-sensitivity.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/465190704019962519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/465190704019962519'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2009/01/automatically-fix-case-sensitivity.html' title='Automatically Fix Case Sensitivity Issues'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-652141062831636588</id><published>2009-01-20T14:46:00.011-06:00</published><updated>2009-02-05T15:40:56.131-06:00</updated><title type='text'>ColdFusion 8 Professional with Windows IIS7 64-Bit</title><content type='html'>&lt;div&gt;ColdFusion 8 will run on 64-bit Windows with a 64-bit JRE, but only if you pay for Enterprise.  While the ColdFusion 8 32-bit installer will run on Windows 64, the IIS connector fails miserably.  I worked around this problem by using the IIS Connector from the 64-bit installation with a ColdFusion instance running with its 32-bit installation.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fist, install the "normal" ColdFusion &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;32-bit&lt;/span&gt; version, but select "Built-in web server (Development use only)" on the Configure Web Servers/Websites screen:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_SBTyqgmbWpE/SXY53M8ILKI/AAAAAAAAACs/cZrTdEh6Yqs/s1600-h/builtinwebserver.PNG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 281px;" src="http://1.bp.blogspot.com/_SBTyqgmbWpE/SXY53M8ILKI/AAAAAAAAACs/cZrTdEh6Yqs/s400/builtinwebserver.PNG" border="0" alt="" id="BLOGGER_PHOTO_ID_5293482032549604514" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next, install the &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;64-bit&lt;/span&gt; version of ColdFusion, with the following options:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;On the "Install Type" screen, choose "Developer Edition":&lt;br /&gt;&lt;img src="http://2.bp.blogspot.com/_SBTyqgmbWpE/SXY7nGjNTgI/AAAAAAAAAC0/i-0gLPAri9A/s400/InstallType64.PNG" style="cursor:pointer; cursor:hand;width: 400px; height: 281px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5293483954979819010" /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On the "Subcomponent Installation" screen, install no complementary services.&lt;br /&gt;&lt;img src="http://3.bp.blogspot.com/_SBTyqgmbWpE/SXY7-2b7q2I/AAAAAAAAAC8/Z91SqDQYcLM/s400/Subcomponent64.PNG" style="cursor:pointer; cursor:hand;width: 400px; height: 281px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5293484362971196258" /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On the Installation Directory screen, choose "ColdFusion64" (or any dir other than where you installed 32-bit ColdFusion)&lt;br /&gt;&lt;img src="http://1.bp.blogspot.com/_SBTyqgmbWpE/SXY8rRT_uDI/AAAAAAAAADE/AlXTbthHCy8/s400/InstallDir64.PNG" style="cursor:pointer; cursor:hand;width: 400px; height: 281px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5293485126099908658" /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On the Configure Web Servers/Websites screen, select "All IIS websites" (which is the default).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;At this point, you may be able to hit http://127.0.0.1/CFIDE/administrator/index.cfm to configure your ColdFusion instance.  If not, check the following items:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Run regedt32, and verify that the ImagePath attribute in the ColdFusion 8 Application Server service (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ColdFusion 8 Application Server) is set to "C:\ColdFusion8\runtime\bin\jrunsvc.exe"&lt;/li&gt;&lt;li&gt;Ensure that the "ColdFusion 8 Application Server" service is started.  If there's a problem, open a command prompt, CD \Coldfusion8\bin, and run CFSTART.  Look for errors.&lt;/li&gt;&lt;li&gt;Open C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\jrun.xml.  Search for "JRunProxyService"; make sure the "deactivated" attribute is "false" and that the "port" attribute is "51011".  (If you need to fix either of these, ColdFusion must be restarted.)&lt;/li&gt;&lt;li&gt;Make sure the 64-bit connector is also pointing to 51011: in the file C:\ColdFusion64\runtime\lib\wsconfig\1\jrun_iis6_wildcard.ini file, the "bootstrap" entry should be set to "bootstrap=127.0.0.1:51011".  If you need to fix this, IIS must be restarted.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Note that you'll never actually start the 64-bit instance, but it must be left in place because you're using its web server connector.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As a side note-- if you try to start ColdFusion 8 Professional in a 64-bit JVM (with either installation type), ColdFusion will revert to a "Developer" license.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Update: If the above doesn't work for you, see &lt;a href="http://www.jasonholden.com/blog/index.cfm/2008/5/6/Coldfusion-8-on-Windows-Server-2008"&gt;Jason Holden's Post&lt;/a&gt; on the same subject.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-652141062831636588?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/652141062831636588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2009/01/coldfusion-8-professional-with-windows.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/652141062831636588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/652141062831636588'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2009/01/coldfusion-8-professional-with-windows.html' title='ColdFusion 8 Professional with Windows IIS7 64-Bit'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_SBTyqgmbWpE/SXY53M8ILKI/AAAAAAAAACs/cZrTdEh6Yqs/s72-c/builtinwebserver.PNG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-4720626404787611478</id><published>2009-01-16T12:25:00.007-06:00</published><updated>2009-01-20T15:57:04.114-06:00</updated><title type='text'>ColdFusion: Fast Query to File Export</title><content type='html'>&lt;div id="doc-contents"&gt;&lt;span style="font-family:'Times New Roman';"&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;A semi-common data processing task is to take the result of a query and write it to a file.  People usually do this in ColdFusion something like this:&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;span style="font-family:-webkit-monospace;"&gt;&lt;pre class="de1"  style="color: black; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: white; border-right-color: white; border-bottom-color: white; border-left-color: white; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: none; background-repeat: initial; background- vertical-align: topcolor:initial;"&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfsetting&lt;/b&gt;&lt;/span&gt; requesttimeout&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"1200"&lt;/span&gt; enablecfoutputonly&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"yes"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfset&lt;/b&gt;&lt;/span&gt; tab &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt; &lt;span class="kw5" style="color: rgb(0, 0, 255)"&gt;chr&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;(&lt;/span&gt;&lt;span class="nu0" style="color: rgb(255, 0, 0)"&gt;9&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfquery&lt;/b&gt;&lt;/span&gt; &lt;span class="kw6" style="color: rgb(0, 0, 255)"&gt;datasource&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"Northwind"&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 0, 255)"&gt;name&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"qProducts"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  SELECT p1.ProductID, p1.ProductName, case when p2.productname&gt; 'B' then p2.productName else null end productName2&lt;br /&gt;  FROM Products p1&lt;br /&gt;  CROSS JOIN Products p2&lt;br /&gt;  CROSS JOIN Products p3&lt;br /&gt;  CROSS JOIN Products p4&lt;br /&gt;  WHERE p1.ProductName &lt;span class="sc4" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&gt;&lt;/span&gt;&lt;/span&gt; 'foo'&lt;br /&gt;  ORDER BY p1.ProductID&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfquery&lt;/b&gt;&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfloop&lt;/b&gt;&lt;/span&gt; &lt;span class="kw6" style="color: rgb(0, 0, 255)"&gt;query&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"qProducts"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfset&lt;/b&gt;&lt;/span&gt; line &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt; ProductID&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; tab &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; ProductName&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; tab &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; ProductName2&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cffile&lt;/b&gt;&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 0, 255)"&gt;action&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"append"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        file&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"/out.txt"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        output&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"#line#"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        addNewLine&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"yes"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;    &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfloop&lt;/b&gt;&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfsetting&lt;/b&gt;&lt;/span&gt; enablecfoutputonly&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"no"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;hr /&gt;&lt;br /&gt;This works fine for small result sets.  In my case, however, I Cartesian-joined the Northwind "Products" table to itself a few times, so that this query returns 35 million rows; the page above runs for ~3 minutes on my laptop and then dies with a java.lang.OutOfMemoryError.&lt;br /&gt;&lt;br /&gt;I'd previously written a &lt;a href="http://www.cfprimer.com/download.cfm?ffFile=jdbcquery.zip"&gt;set of ColdFusion tags&lt;/a&gt; that could access JDBC directly from ColdFusion and process the resultset one row at a time, thereby avoiding out-of-memory errors:&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;span style="font-family:-webkit-monospace;"&gt;&lt;pre class="de1"  style="color: black; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: white; border-right-color: white; border-bottom-color: white; border-left-color: white; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: none; background-repeat: initial; background- vertical-align: topcolor:initial;"&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfsetting&lt;/b&gt;&lt;/span&gt; requesttimeout&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"1200"&lt;/span&gt; enablecfoutputonly&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"yes"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfset&lt;/b&gt;&lt;/span&gt; tab &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt; &lt;span class="kw5" style="color: rgb(0, 0, 255)"&gt;chr&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;(&lt;/span&gt;&lt;span class="nu0" style="color: rgb(255, 0, 0)"&gt;9&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="sc0" style="color: rgb(128, 128, 128)"&gt;&lt;i&gt;&amp;lt;!--- cf_jdbcQuery will return a java ResultSet object instead of a ColdFusion Query object ---&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;cf_jdbcquery &lt;span class="kw6" style="color: rgb(0, 0, 255)"&gt;datasource&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"Northwind"&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 0, 255)"&gt;name&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"qProducts"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfoutput&lt;/b&gt;&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  SELECT p1.ProductID, p1.ProductName, case when p2.productname&gt; 'B' then p2.productName else null end productName2&lt;br /&gt;  FROM Products p1&lt;br /&gt;  CROSS JOIN Products p2&lt;br /&gt;  CROSS JOIN Products p3&lt;br /&gt;  CROSS JOIN Products p4&lt;br /&gt;  WHERE p1.ProductName &lt;span class="sc4" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&gt;&lt;/span&gt;&lt;/span&gt; 'foo'&lt;br /&gt;  ORDER BY p1.ProductID&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfoutput&lt;/b&gt;&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;/&lt;/span&gt;cf_jdbcquery&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;cf_jdbcqueryloop &lt;span class="kw6" style="color: rgb(0, 0, 255)"&gt;query&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"qProducts"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfset&lt;/b&gt;&lt;/span&gt; line &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt; qProducts.ProductID&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; tab &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; qProducts.ProductName&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; tab &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;amp;&lt;/span&gt; qProducts.ProductName2&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cffile&lt;/b&gt;&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 0, 255)"&gt;action&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"append"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        file&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"/out.txt"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        output&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"#line#"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;        addNewLine&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"yes"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;    &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;/&lt;/span&gt;cf_jdbcqueryloop&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfsetting&lt;/b&gt;&lt;/span&gt; enablecfoutputonly&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"no"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;hr /&gt;&lt;br /&gt;This ran for 20mins (until it hit the timeout),writing about 37MB to the output file.  Still... 20 minutes?  I think we can do better.&lt;br /&gt;&lt;br /&gt;So, I wrote a Java class to do this in a very small loop, to see the difference in speed.  The Java source file ("FastResultsetToFile.java") is this:&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;span style="font-family:-webkit-monospace;"&gt;&lt;pre class="de1"  style="color: black; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: white; border-right-color: white; border-bottom-color: white; border-left-color: white; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: none; background-repeat: initial; background- vertical-align: topcolor:initial;"&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.io.BufferedOutputStream&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.io.File&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.io.FileOutputStream&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.io.IOException&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.sql.ResultSet&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.sql.ResultSetMetaData&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt; &lt;span class="co2" style="color: rgb(0, 102, 153)"&gt;java.sql.SQLException&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="co3" style="color: rgb(0, 128, 0)"&gt;&lt;b&gt;&lt;i&gt;/**&lt;br /&gt;* @author Daryl Banttari&lt;br /&gt;* Released to the public domain.  Do with it what you will!&lt;br /&gt;*/&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;public&lt;/b&gt;&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;class&lt;/b&gt;&lt;/span&gt; FastResultsetToFile &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;public&lt;/b&gt;&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;static&lt;/b&gt;&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;final&lt;/b&gt;&lt;/span&gt; &lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;byte&lt;/b&gt;&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;[&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;]&lt;/span&gt; CRLF &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt; &lt;span class="nu0" style="color: rgb(204, 102, 204)"&gt;13&lt;/span&gt;, &lt;span class="nu0" style="color: rgb(204, 102, 204)"&gt;10&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class="co3" style="color: rgb(0, 128, 0)"&gt;&lt;b&gt;&lt;i&gt;/**&lt;br /&gt;   * Very quickly sends data from an any size query to an output file.&lt;br /&gt;   *&lt;br /&gt;   * @throws IOException&lt;br /&gt;   * @throws SQLException&lt;br /&gt;   */&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;public&lt;/b&gt;&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;static&lt;/b&gt;&lt;/span&gt; &lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/span&gt; exportResultsetToFile&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;ResultSet&lt;/span&gt; rs, &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;String&lt;/span&gt; fileName, &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;String&lt;/span&gt; delim, &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;String&lt;/span&gt; charset&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;throws&lt;/b&gt;&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;IOException&lt;/span&gt;, &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;SQLException&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/span&gt; rowcount &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; &lt;span class="nu0" style="color: rgb(204, 102, 204)"&gt;0&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;File&lt;/span&gt; file &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;File&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;fileName&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;byte&lt;/b&gt;&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;[&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;]&lt;/span&gt; delimBytes &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; delim.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;getBytes&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;charset&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;byte&lt;/b&gt;&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;[&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;]&lt;/span&gt; CRLF &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; &lt;span class="st0" style="color: rgb(0, 0, 255)"&gt;"&lt;span class="es0" style="color: rgb(0, 0, 153)"&gt;&lt;b&gt;\r&lt;/b&gt;&lt;/span&gt;&lt;span class="es0" style="color: rgb(0, 0, 153)"&gt;&lt;b&gt;\n&lt;/b&gt;&lt;/span&gt;"&lt;/span&gt;.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;getBytes&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;charset&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;BufferedOutputStream&lt;/span&gt; out &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;BufferedOutputStream&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;FileOutputStream&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;file&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;try&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;ResultSetMetaData&lt;/span&gt; rsmd &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; rs.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;getMetaData&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/span&gt; numCols &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; rsmd.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;getColumnCount&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span class="co1" style="color: rgb(102, 102, 102)"&gt;&lt;i&gt;// iterate over resultset&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;while&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;rs.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;next&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;              &lt;span class="co1" style="color: rgb(102, 102, 102)"&gt;&lt;i&gt;// write each column&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;              &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="kw4" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/span&gt; i &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; &lt;span class="nu0" style="color: rgb(204, 102, 204)"&gt;1&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt; i &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;&amp;lt;=&lt;/span&gt; numCols&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt; &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;++&lt;/span&gt;i&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;                  &lt;span class="kw3" style="color: rgb(0, 51, 153)"&gt;String&lt;/span&gt; s &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;=&lt;/span&gt; rs.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;getString&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;i&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;                  &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;s &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;!=&lt;/span&gt; &lt;span class="kw2" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;                      out.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;write&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;s.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;getBytes&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;charset&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;                  &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;                  &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;i &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;==&lt;/span&gt; numCols&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;                      &lt;span class="co1" style="color: rgb(102, 102, 102)"&gt;&lt;i&gt;// end of row, write CRLF&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;                      out.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;write&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;CRLF&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;                  &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;                  &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;                      &lt;span class="co1" style="color: rgb(102, 102, 102)"&gt;&lt;i&gt;// write delimiter between data&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;                      out.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;write&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;delimBytes&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;                  &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;              &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;              rowcount&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;++;&lt;/span&gt;&lt;br /&gt;          &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;finally&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;out &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;!=&lt;/span&gt; &lt;span class="kw2" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;              out.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;flush&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;              out.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;close&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;          &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;rs &lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;!=&lt;/span&gt; &lt;span class="kw2" style="color: rgb(0, 0, 102)"&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt; &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;{&lt;/span&gt;&lt;br /&gt;              rs.&lt;span class="me1" style="color: rgb(0, 102, 51)"&gt;close&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;(&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class="kw1" style="color: rgb(0, 0, 0)"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/span&gt; rowcount&lt;span class="sy0" style="color: rgb(51, 153, 51)"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="br0" style="color: rgb(0, 153, 0)"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;hr /&gt;&lt;br /&gt;To compile this, save the FastResultsetToFile.java to disk, then type "javac FastResultsetToFile.java".  This will produce a file called FastResultsetToFile.class.  Depending on how you have ColdFusion installed, the file should be placed in either:&lt;br /&gt;&lt;br /&gt;\coldfusionmx\wwwroot\WEB-INF\classes&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\classes&lt;br /&gt;&lt;br /&gt;The ColdFusion page looks like this:&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;span style="font-family:-webkit-monospace;"&gt;&lt;pre class="de1"  style="color: black; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: white; border-right-color: white; border-bottom-color: white; border-left-color: white; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: none; background-repeat: initial; background- vertical-align: topcolor:initial;"&gt;&lt;span class="sc0" style="color: rgb(128, 128, 128)"&gt;&lt;i&gt;&amp;lt;!--- cf_jdbcQuery will return a java ResultSet object instead of a ColdFusion Query object ---&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;cf_jdbcQuery &lt;span class="kw6" style="color: rgb(0, 0, 255)"&gt;datasource&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"Northwind"&lt;/span&gt; &lt;span class="kw3" style="color: rgb(0, 0, 255)"&gt;name&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"qProducts"&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  SELECT p1.ProductID, p1.ProductName, case when p2.productname&gt; 'B' then p2.productName else null end productName2&lt;br /&gt;  FROM Products p1&lt;br /&gt;  CROSS JOIN Products p2&lt;br /&gt;  CROSS JOIN Products p3&lt;br /&gt;  CROSS JOIN Products p4&lt;br /&gt;  WHERE p1.ProductName &lt;span class="sc4" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&gt;&lt;/span&gt;&lt;/span&gt; 'foo'&lt;br /&gt;  ORDER BY p1.ProductID&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;/&lt;/span&gt;cf_jdbcQuery&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfset&lt;/b&gt;&lt;/span&gt; application.fastFileWriter &lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;=&lt;/span&gt; &lt;span class="kw5" style="color: rgb(0, 0, 255)"&gt;createObject&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;(&lt;/span&gt;&lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"java"&lt;/span&gt;, &lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"FastResultsetToFile"&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sc5" style="color: rgb(51, 51, 51)"&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kw1" style="color: rgb(153, 0, 0)"&gt;&lt;b&gt;cfset&lt;/b&gt;&lt;/span&gt; application.fastFileWriter.exportResultsetToFile&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;(&lt;/span&gt;qProducts, &lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"/out.txt"&lt;/span&gt;, &lt;span class="kw5" style="color: rgb(0, 0, 255)"&gt;chr&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;(&lt;/span&gt;&lt;span class="nu0" style="color: rgb(255, 0, 0)"&gt;9&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;)&lt;/span&gt;, &lt;span class="st0" style="color: rgb(0, 153, 0)"&gt;"UTF-8"&lt;/span&gt;&lt;span class="br0" style="color: rgb(0, 0, 255)"&gt;)&lt;/span&gt;&lt;span class="sy0" style="color: rgb(0, 0, 255)"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Done.&lt;/pre&gt;&lt;/span&gt;&lt;hr /&gt;&lt;br /&gt;This completes, writing all 35,153,041 rows into a 1.3 GB file in about 5 minutes.  Not bad!  If we'd let cf_jdbcQueryLoop complete, it'd have taken nearly 12 hours (based on time and file size ratio).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;While you can do a lot right inside ColdFusion, it's important to remember that it's not the right tool for every job.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-4720626404787611478?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/4720626404787611478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2009/01/coldfusion-fast-query-to-file-export.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/4720626404787611478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/4720626404787611478'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2009/01/coldfusion-fast-query-to-file-export.html' title='ColdFusion: Fast Query to File Export'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-7113243589506755504</id><published>2009-01-16T10:39:00.000-06:00</published><updated>2009-01-16T10:40:25.497-06:00</updated><title type='text'>Multiple ColdFusion Instances NEQ "Faster"</title><content type='html'>&lt;div&gt;There's an oft-cited technote indicating that running with multiple instances somehow performs much better than running with a single instance, but no testing methodology is cited on the technote.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In my experience load testing, in the general case, the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;opposite&lt;/span&gt; is true-- you get better performance with fewer instances.  In the specific case where you're doing a very large number of very small requests, the single-threaded nature of the datasource connection pool becomes a bottleneck, but it's easier (and less resource intensive) to work around that specific issue by using a modest number of identically-configured datasources, and choosing a datasource randomly at the start of the request.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you're actually memory constrained, then you're better off using a single large 64-bit instance vs. a bunch of small 32-bit instances.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;(I proved via load testing to one customer that their app had 10-15% better throughput when three of their four instances were disabled, and the techie that had pushed for Enterprise + multiple instances said, and I quote, "I don't believe you."  Believe?  A result that changes consistently and predictably when one variable changes somehow involves "belief"?  What's happened to /science/ in this country?)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-7113243589506755504?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/7113243589506755504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2009/01/multiple-coldfusion-instances-neq.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/7113243589506755504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/7113243589506755504'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2009/01/multiple-coldfusion-instances-neq.html' title='Multiple ColdFusion Instances NEQ &quot;Faster&quot;'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111971311681683677</id><published>2005-06-25T10:13:00.000-05:00</published><updated>2005-06-25T10:37:38.776-05:00</updated><title type='text'>Oracle Connection Lock Timeout and ColdFusion 5</title><content type='html'>If you're getting Connection Lock Timeouts or just generally poor performance with ColdFusion 5 using Oracle OCI drivers, here's why:&lt;br /&gt;&lt;br /&gt;When ColdFusion 5 was being released, there was a bug in the Oracle OCI driver set that made simultaneous execution of  multiple statements quite unreliable.  (However, retrieving multiple resultsets could be done concurrently; this only applies to the time between when a statement is submitted for execution and when the first result row is available.)  In the interest of stability, ColdFusion was made to single-thread it's access to that part of the driver; however, an undocumented switch was left behind for when that Oracle bug was fixed.&lt;br /&gt;&lt;br /&gt;If you're running the OCI driver set, version 8.1.7 or newer, then you can remove this restriction.&lt;br /&gt;&lt;br /&gt;The undocumented registry key that can be added to probably eliminate the "Oracle Connection Lock Timeout" and "Oracle Statement Lock Timeout" errors is:&lt;br /&gt;&lt;br /&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\Server\ UseApplicationLockingForOracle8&lt;br /&gt;&lt;br /&gt;Create this key and set it to a STRING value of "0" (zero) to remove statement locking. This feature is only available with ColdFusion 5, and the lock only applies versions of ColdFusion prior to ColdFusion MX.  On Unix versions of ColdFusion 5, you need to stop ColdFusion, then carefully edit the cf.registry file to add this key to the correct place.  (Or just use CFREGISTRY to add the key, then restart cfserver.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111971311681683677?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111971311681683677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/06/oracle-connection-lock-timeout-and.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111971311681683677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111971311681683677'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/06/oracle-connection-lock-timeout-and.html' title='Oracle Connection Lock Timeout and ColdFusion 5'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111945647600238716</id><published>2005-06-22T11:07:00.000-05:00</published><updated>2005-06-25T10:12:33.890-05:00</updated><title type='text'>JRun Clustering with Windows 2003 NLB</title><content type='html'>There are a couple of tricky points to clustering ColdFusion or JRun with Windows Network Load Balancing enabled.&lt;br /&gt;&lt;br /&gt;First, see Brandon Purcell's article for general information on JRun clustering with ColdFusion 6.1:&lt;br /&gt;&lt;a href="http://www.bpurcell.org/viewContent.cfm?ContentID=121"&gt;http://www.bpurcell.org/viewContent.cfm?ContentID=121&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For ColdFusion 7 in Multi-Instance mode, use the ColdFusion Administrator to create the instances to cluster. Remember, each instance in a cluster has to have a unique name; I like to use the last part of the IP address in the name, e.g. "cfusion66". Once all instances are created, choose one ColdFusion 7 server to be your "cluster manager", and use the Administrator on that machine to create the cluster by registering the remote instances running on the other machines, then creating the actual cluster. Once that's done, you must restart all instances involved in the cluster, then use the WSCONFIG utility to re-install the Web server connector on every Web server involved. In order to access the "cfusion" instance to manage instances and clusters after that, you must go to the jrun4/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/jrun-web.xml and add an entry to point to your CFIDE folder, which may look like this:&lt;br /&gt;&lt;br /&gt;&amp;lt;virtual-mapping&gt;&lt;br /&gt; &amp;lt;resource-path&gt;/CFIDE&amp;lt;/resource-path&gt;&lt;br /&gt; &amp;lt;system-path&gt;C:/inetpub/wwwroot/CFIDE&amp;lt;/system-path&gt;&lt;br /&gt;&amp;lt;/virtual-mapping&gt;&lt;br /&gt;&lt;br /&gt;Then, you can access the cluster-manager ColdFusion 7 Administrator by pointing your browser to port 8300 on the server you want to manage.&lt;br /&gt;&lt;br /&gt;I found the easiest / most reliable way to get this working is to use one interface in Multicast mode, and if necessary, add a static ARP entry to the router:&lt;br /&gt;&lt;blockquote&gt;"Some routers require a static ARP entry because they do not support the resolution of unicast IP addresses to multicast media access control addresses. For example, Cisco routers require an ARP (address resolution protocol) entry for every virtual IP address. While Network Load Balancing uses Level 2 Multicast for the delivery of packets, Cisco's interpretation of the RFCs is that Multicast is for IP Multicast. So, when the router doesn't see a Multicast IP address, it does not automatically create an ARP entry, and one has to manually have to add it on the router."&lt;/blockquote&gt;&lt;br /&gt;(Source: &lt;a href="http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/clustering/nlbbp.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/clustering/nlbbp.mspx&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;If you DO have two interfaces, make sure they're both attached to the same LAN segment, and that the NLB interfaces are the &lt;b&gt;secondary&lt;/b&gt; interfaces.&lt;br /&gt;&lt;br /&gt;If they're not on the same LAN segment, then the cluster will usually fail to synchronize with the other members, and you'll have severe problems getting session failover working reliably.&lt;br /&gt;&lt;br /&gt;If the NLB interface is left as the primary interface, then connections to the JNDI port fail (the TCP connections are closed as right after they are opened, with no actual data transferred), and the instance manager shows "network error" for remote instances.&lt;br /&gt;&lt;br /&gt;With multiple interfaces active, it may also be necessary to add one or more UnicastPeer attribute(s) in the ClusterManager section of jrun4\servers\{instance}\SERVER-INF\jrun.xml&lt;br /&gt;&lt;br /&gt;That being said, I found that disabling the secondary NIC and using Multicast mode worked well, each and every time, without having to do anything beyond registering the remote instance and adding it to the cluster.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Thanks to Matt Stevanus for finding the network order dependency.&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111945647600238716?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111945647600238716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/06/jrun-clustering-with-windows-2003-nlb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111945647600238716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111945647600238716'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/06/jrun-clustering-with-windows-2003-nlb.html' title='JRun Clustering with Windows 2003 NLB'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111971367882740896</id><published>2005-06-20T10:26:00.000-05:00</published><updated>2005-06-25T10:34:38.826-05:00</updated><title type='text'>"Daryl" neq "Macromedia"</title><content type='html'>Last Friday, 17 June 2005, was the final day of employment for me at Macromedia.  On that day, I received a Fedex box containing my final paycheck, and my 5-year "thanks for staying" watch.&lt;br /&gt;&lt;br /&gt;Seems someone at Macromedia is not without a sense of irony.&lt;br /&gt;&lt;br /&gt;I'm now working for &lt;a href="http://www.webapper.com/"&gt;Webapper Services, LLC&lt;/a&gt;, the makers of &lt;a href="http://www.seefusion.com/"&gt;SeeFusion&lt;/a&gt;, an excellent tool for monitoring what's going on inside your ColdFusion server at any given moment.  Initially, I'm going to be doing onsite consulting, but the plan is that I'm going to get more and more involved in the SeeFusion product line, which I very much look forward to.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111971367882740896?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111971367882740896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/06/daryl-neq-macromedia.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111971367882740896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111971367882740896'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/06/daryl-neq-macromedia.html' title='&quot;Daryl&quot; neq &quot;Macromedia&quot;'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111237566974292651</id><published>2005-04-01T11:11:00.000-06:00</published><updated>2005-04-01T11:14:29.743-06:00</updated><title type='text'>Macromedia Announces Plan to Make ColdFusion Harder</title><content type='html'>In an effort to compete 'on a more level playing field', Macromedia announced today that it would be making ColdFusion substantially more difficult to use.&lt;br /&gt;&lt;br /&gt;This unusual move was prompted, said Damon Jordahl, a product manager at Macromedia, by ColdFusion's continuing bad reputation as a 'toy' language.  'We've been getting a bad reputation for years,' he said, 'because people would look at ColdFusion, produce a working database driven report page in a couple of minutes, and discard it as being way to easy and fast to be considered as a "serious" language.'&lt;br /&gt;&lt;br /&gt;Larry Wall, founder of the Perl language, applauded the move.  'For the longest time, Perl has been alone as the world's only self-encrypting language.  I'm hoping that Macromedia will give me some real competition in this space.'&lt;br /&gt;&lt;br /&gt;The success of ASP.NET was also a factor in the decision, when interviews with ASP developers revealed that one of the main reasons they use the language is its inefficiency.  One anonymous ASP developer was cited as saying, 'Well, it takes weeks to get anything useful done in ASP.  With ColdFusion, I can get entire working sites done in hours or maybe a few days.  Where's the job security?'&lt;br /&gt;&lt;br /&gt;Complexity also provides a convenient barrier to entry.  'Let's face it', concluded Jordahl, 'we've been attracting the novice developer for years.  People who had never before written a line of machine instruction in their life.  And novice programmers just don't have the experience to make scalable sites.  Half the time they don't even index their database tables, and that's just a recipe for scalability disaster.  But the programmers and the DBAs don't get the bad reputation.  People always want to blame ColdFusion.  We think that adding substantial complexity to the language will exclude these entry level people from the game, and allow ColdFusion to get the good reputation it deserves.'&lt;br /&gt;&lt;br /&gt;Macromedia plans to ship the newly obfuscated ColdFusion language in its next release version.&lt;br /&gt;&lt;br /&gt;(Happy April Fool's Day!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111237566974292651?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111237566974292651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/04/macromedia-announces-plan-to-make.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111237566974292651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111237566974292651'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/04/macromedia-announces-plan-to-make.html' title='Macromedia Announces Plan to Make ColdFusion Harder'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111221859113209788</id><published>2005-03-30T15:20:00.000-06:00</published><updated>2005-03-30T15:36:31.136-06:00</updated><title type='text'>CFDirectory can be Slow with Many Files</title><content type='html'>CFDirectory can be rather slow when working with directories containing very many files (as in, thousands or tens of thousands of files.)&lt;br /&gt;&lt;br /&gt;The underlying method used, java.io.File.listFiles(), does not allow a Java application to pass a filter to the underlying operating system, but rather forces the application to filter the directory listing on a case-by-case basis by creating a FileFilter object.&lt;br /&gt;&lt;br /&gt;If the thousands of file names exist across a network share, the problem is compounded by the added latency of the network file system.&lt;br /&gt;&lt;br /&gt;If you're only looking for, say, a date stamp for a single file, the &lt;i&gt;entire directory&lt;/i&gt; is iterated looking for the file, and only then are the details of the file made available to the ColdFusion application.&lt;br /&gt;&lt;br /&gt;If you only want information about a single file, it's fairly easy to get that directly via direct calls to Java from within ColdFusion.  Here is a ColdFusion function that will efficiently get the date stamp from a single file:&lt;br /&gt;&lt;br /&gt;&amp;lt;cfscript&gt;&lt;br /&gt;function getFileDate(fn) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;theFile = createObject("java","java.io.File");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;theFile.init(fn);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( theFile.exists() ){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;theDate=createObject("java","java.util.Date");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;theDate.init(theFile.lastModified());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dateString = 1+theDate.getMonth() &amp; "/" &amp; theDate.getDate() &amp; "/" &amp; 1900+theDate.getYear() &amp; " " &amp; theDate.getHours() &amp; ":" &amp; theDate.getMinutes() &amp; ":" &amp; theDate.getSeconds();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dateString="";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return dateString;&lt;br /&gt;}&lt;br /&gt;function getFileSize(fn) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;theFile = createObject("java","java.io.File");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;theFile.init(fn);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( theFile.exists() ){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return theFile.length();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dateString="";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return dateString;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/cfscript&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111221859113209788?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111221859113209788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/03/cfdirectory-can-be-slow-with-many.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111221859113209788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111221859113209788'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/03/cfdirectory-can-be-slow-with-many.html' title='CFDirectory can be Slow with Many Files'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111221398988060252</id><published>2005-03-30T14:05:00.000-06:00</published><updated>2005-03-30T15:50:32.246-06:00</updated><title type='text'>TCP/IP Efficiency</title><content type='html'>Ran into an interesting problem the other day.&lt;br /&gt;&lt;br /&gt;Seems that the TCP connection between JRun (which underpins ColdFusion) and its Web server connector can get somewhat overwhelmed by the bursty nature of ColdFusion pages.&lt;br /&gt;&lt;br /&gt;(Normally, ColdFusion doesn't send any data back to the Web server until the page is completely finished, as the last line of a template could be a CFLOCATION or CFHEADER tag, and once the HTTP header is sent, it can't be altered nor retracted.)&lt;br /&gt;&lt;br /&gt;Using &lt;a href="http://www.ethereal.com/"&gt;Ethereal&lt;/a&gt; to &lt;a href="http://www.ipprimer.com/packets.cfm"&gt;analyze the communication&lt;/a&gt;, it became clear that the JRPP connections (JRPP is the protocol used for JRun's Web server connectors to talk to JRun itself) were stalling because of something called "Silly Window Syndrome" avoidance (see &lt;a href="http://www.faqs.org/rfcs/rfc1122.html"&gt;RFC 1122&lt;/a&gt;), when the receive TCP buffer at the Web server was getting quickly filled.  The stalling was prevented by increasing the TCP max window size in Windows by making a few registry settings.&lt;br /&gt;&lt;br /&gt;Here's the contents of the registry file that adjusts the TCP max window size to roughly 128k (instead of the default ~17k):&lt;blockquote&gt;Windows Registry Editor Version 5.00&lt;br /&gt;&lt;br /&gt;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]&lt;br /&gt;"GlobalMaxTcpWindowSize"=dword:00020148&lt;br /&gt;"TcpWindowSize"=dword:00020148&lt;br /&gt;"Tcp1323Opts"=dword:00000003&lt;br /&gt;&lt;/blockquote&gt;This also helped &lt;a href="http://rdweb.cns.vt.edu/public/notes/win2k-tcpip.htm"&gt;speed up my Internet downloads&lt;/a&gt; for my home PC.  I'd recommend applying the change to any Windows box with more than 256MB RAM.&lt;br /&gt;&lt;br /&gt;For more on TCP options under Windows, see &lt;a href="http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx"&gt;&lt;br /&gt;this TechNet article.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111221398988060252?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111221398988060252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/03/tcpip-efficiency.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111221398988060252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111221398988060252'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/03/tcpip-efficiency.html' title='TCP/IP Efficiency'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11805603.post-111221272715041304</id><published>2005-03-30T13:46:00.000-06:00</published><updated>2005-04-07T13:36:45.680-05:00</updated><title type='text'>Avoid Evaluate()</title><content type='html'>The ColdFusion Evaluate() function is often used to resolve dynamically named variables, such as form variables.&lt;br /&gt;&lt;br /&gt;The evaluate function, however, forces ColdFusion to compile the expression being evaluated every time you call it, which can be a strain on performance, especially since parts of the compilation process are necessarily single-threaded.&lt;br /&gt;&lt;br /&gt;Almost all instances of Evaluate() can be avoided by using structure syntax; instead of writing:&lt;br /&gt;&lt;br /&gt;&amp;lt;cfset value=evaluate("form.field#i#")&amp;gt;&lt;br /&gt;&lt;br /&gt;You can write:&lt;br /&gt;&lt;br /&gt;&amp;lt;cfset value=form["field#i#"]&amp;gt;&lt;br /&gt;&lt;br /&gt;Which is much faster, and better yet, simpler.&lt;br /&gt;&lt;br /&gt;This doesn't work quite so well when looping over a query, however.  If you use structure syntax to access a query column, you must also specify the row number.  So, where this would work:&lt;br /&gt;&lt;br /&gt;&amp;lt;cfoutput query="q"&gt;&lt;br /&gt;#evaluate("q.#fieldname#")#&amp;lt;br&gt;&lt;br /&gt;&amp;lt;/cfoutput&gt;&lt;br /&gt;&lt;br /&gt;You'd have to use q.currentrow to get the correct row when avoiding evaluate():&lt;br /&gt;&amp;lt;cfoutput query="q"&gt;&lt;br /&gt; #q[fieldname][q.currentrow]#&amp;lt;br&gt;&lt;br /&gt; &amp;lt;/cfoutput&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update: 7Apr2005&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Classes created for evaluate() [and de() and setVariable()] are cached on a literal string basis (sorta like cached queries work for the exact string of the query), so the performance impact isn't quite so bad, so long as the literal string for evaluate() doesn't change every time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11805603-111221272715041304?l=cfprimer.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfprimer.blogspot.com/feeds/111221272715041304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cfprimer.blogspot.com/2005/03/avoid-evaluate.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111221272715041304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11805603/posts/default/111221272715041304'/><link rel='alternate' type='text/html' href='http://cfprimer.blogspot.com/2005/03/avoid-evaluate.html' title='Avoid Evaluate()'/><author><name>Daryl the Data Plumber</name><uri>http://www.blogger.com/profile/01281918394349579472</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry></feed>
