<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Rob Brooks-Bilson&apos;s Blog - Database</title>
			<link>http://www.brooks-bilson.com/blogs/rob/index.cfm</link>
			<description>A blog for ColdFusion and other topics by Rob Brooks-Bilson, author of the O&apos;Reilly book Programming ColdFusion MX</description>
			<language>en-us</language>
			<pubDate>Thu, 09 Sep 2010 11:44:19 -0400</pubDate>
			<lastBuildDate>Mon, 10 Jul 2006 18:09:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>rbils@amkor.com</managingEditor>
			<webMaster>rbils@amkor.com</webMaster>
			
			
			
			
			
			<item>
				<title>Querying the DB2/400 System Catalog</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2006/7/10/Querying-the-DB2400-System-Catalog</link>
				<description>
				
				DB2 stores information about database objects in what it calls the System Catalog.  There are a number of views in the system catalog you can use to obtain metadata about your database such as columns, key relationships, schemas, stored procs, etc.

Today, I was working on a report where I wanted to display statistics about a number of staging files we use in our applications.  I wanted to list things like number of records, number of columns, column names, etc.  Things like the number of columns were easy to do just by selecting count(*) from the source table.  To get the number of columns, though, I didn&apos;t want to use a hack like selecting a single record and getting the column list from that.  What I wanted to do was query the system catalog.  Unlike SQL Server, Oracle, and just about every other DB platform out there, documentation for DB2/400 is rather scarce.

After a lot of googling, I found a DB2/400 reference that had the information on the system catalog I needed.  For those interested, the full documentation set can be found &lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/db2/rbafzmstcatalog.htm&quot;&gt;here&lt;/a&gt;.  As IBM documentation has a tendency to disappear, here&apos;s the SYSIBM.SQLCOLUMNS library/view I used to query column information from the system catalog:

&lt;code&gt;
&lt;cfquery name=&quot;getColumnCount&quot; datasource=&quot;myDSN&quot;&gt;
SELECT count(*) as totalRows
FROM SYSIBM.SQLCOLUMNS
WHERE TABLE_NAME = &apos;yourTable&apos;  
&lt;/cfquery&gt;
&lt;/code&gt;

If you want to get a list of all columns, along with a lot of additional info about each column, just do a SELECT * instead of the count.

There are several other useful SQL views you can use:

SQLCOLPRIVILEGES, SQLFOREIGNKEYS, SQLPRIMARYKEYS, SQLPROCEDURECOLS, SQLPROCEDURES, SQLSCHEMAS, SQLSPECIALCOLUMNS, SQLSTATISTICS, SQLTABLEPRIVILEGES, SQLTABLES, SQLTYPEINFO, SQLUDTS
				
				</description>
						
				
				<category>DB2</category>				
				
				<category>JDBC</category>				
				
				<category>JTOpen</category>				
				
				<category>Database</category>				
				
				<category>iSeries</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Mon, 10 Jul 2006 18:09:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2006/7/10/Querying-the-DB2400-System-Catalog</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JTOpen 5.1.1 Released</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2006/5/3/JTOpen-511-Released</link>
				<description>
				
				For all you ColdFusion junkies working with DB2 on iSeries/AS400&apos;s out there, IBM has just released version 5.1.1 of their open source JTOpen JDBC driver.  You can &lt;a href=&quot;https://sourceforge.net/project/showfiles.php?group_id=128806&quot;&gt;download  it from SourceForge&lt;/a&gt;.
				
				</description>
						
				
				<category>DB2</category>				
				
				<category>JDBC</category>				
				
				<category>JTOpen</category>				
				
				<category>Database</category>				
				
				<category>iSeries</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Wed, 03 May 2006 12:25:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2006/5/3/JTOpen-511-Released</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JTOpen 5.0 Released</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2006/1/17/JTOpen-50-Released</link>
				<description>
				
				For anyone out there using ColdFusion MX with DB2 running on an AS400, iSeries, or i5, you may be interested to know that JTOpen 5.0 has just been released.  JTOpen is the open source JDBC driver and toolkit from IBM for working with both DB2 and OS/i5 / OS/400.  You can &lt;a href=&quot;http://jt400.sourceforge.net/&quot;&gt;download JTOpen 5.0&lt;/a&gt; from Sourceforge.
				
				</description>
						
				
				<category>DB2</category>				
				
				<category>JDBC</category>				
				
				<category>JTOpen</category>				
				
				<category>Database</category>				
				
				<category>iSeries</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Tue, 17 Jan 2006 09:36:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2006/1/17/JTOpen-50-Released</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Back To Basics:  An SQL Gotcha</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/4/27/87</link>
				<description>
				
				I took a call from our help desk last night around midnight.  One of our users in Asia had called in reporting an error in one of our applications.  I checked our error logs, and sure enough there was an error - an SQL error:  SQL0117 - Statement contains wrong number of values.  This server happens to be an old ColdFusion server still running ODBC.  We&apos;re in the process of upgrading t to MX, but that&apos;s another story.  Anyhow, at first, I was puzzled by the error as we hadn&apos;t made any changes to the code in quite some time.  Then it hit me.  Earlier in the day, we added a new column to one of the database tables used by the application in order to facilitate the upgrade.  Harmless enough, right?  Wrong.

Turns out the application in question had an SQL insert that looked something like this:

INSER INTO myTable
VALUES(&apos;#foo#&apos;, goo, &apos;#boo#&apos;)

Now granted this code was written about 6 years ago, but the developer who wrote it took a shortcut that came back to bite us.  Instead of explicitly declaring the fields to be inserted, he or she simply expressed the values to insert.  This only works when the number of values exactly matches the number of fields in the database table.  In my case, the extra field we added caused the application to break.  Now granted this is something that could have been caught in testing/qa, but we didn&apos;t have that luxury in this particular instance.

The moral of the story here is that in order to future proof your application, it&apos;s best to always declare the columns you intend to insert:

INSER INTO myTable (foo, goo, boo)
VALUES(&apos;#foo#&apos;, goo, &apos;#boo#&apos;)
				
				</description>
						
				
				<category>Database</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Tue, 27 Apr 2004 07:00:18 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/4/27/87</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JTOpen 4.3 Released</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/4/13/86</link>
				<description>
				
				IBM released &lt;a href=&quot;http://www-124.ibm.com/developerworks/downloads/index.php?group_id=29&quot;&gt;JTOpen 4.3&lt;/a&gt; today.  JTOpen is an opensource Type IV JDBC driver for accessing DB2 running on the IBM iSeries midrange computer.  Version 4.3 adds several bug fixes, performance enhancements, etc.
				
				</description>
						
				
				<category>Database</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Tue, 13 Apr 2004 08:18:12 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/4/13/86</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JTOpen 4.2 Is Out</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/1/27/82</link>
				<description>
				
				Although this isn&apos;t really *new* (the driver was released about a month ago), I never got around to blogging it.  For those of you who connect ot an AS400/iSeries with CFMX, you might be interested to know that IBM released version 4.2 of JTOpen, their open source JDBC driver for DB2/400.  You can download the driver &lt;a href=&quot;http://www-124.ibm.com/developerworks/downloads/index.php?group_id=29&quot;&gt;here&lt;/a&gt;.
				
				</description>
						
				
				<category>Database</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Tue, 27 Jan 2004 08:21:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/1/27/82</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Anyone Connecting to DB2 on OS/390?</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/1/12/80</link>
				<description>
				
				A fellow ColdFusion developer is having database connectivity issues connecting CFMX 6.1 to DB2 on an IBM OS/390.  I was wondering if any of you other ColdFusion developers out there were connecting to that platform and could offer up some help as far as what drivers you use, connection strings, and any other advice.  Contact me via the comments or at rbils@amkor.com if you can help.
				
				</description>
						
				
				<category>Database</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Mon, 12 Jan 2004 14:39:13 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2004/1/12/80</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Using the JTOpen JDBC Driver with Multiple CFMX 6.1 Instances</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2003/12/10/76</link>
				<description>
				
				I recently setup a new development box running multiple instances of ColdFusion MX 6.1.  I posted a question to the CFGURU mailing list asking about the best place to put my 3rd party JDBC driver.  Sean Corfield and Simon Horwith both chimed in that they recommended placing it in:

{jrun.home}/servers/lib/

In my previous non J2EE installations of ColdFusion, I always placed my driver in c:\jt400\jtopen\bin.  Whenever I setup a new server, I also had to add this location to the JAva CLASSPATH in the ColdFusion Administrator.  What&apos;s my point?  Well, using Sean/Simon&apos;s location, I no longer have to add the CLASSPATH to my ColdFusion server as the location is already known to the JRun/ColdFusion server.  Very convenient!

Also for you iSeries fans out there, a new article by Jeremy Lyon is in this month&apos;s ColdFusion Developer Journal.  The article, &quot;MX to iSeries Demystified - A world-class database platform paired up with a world-class Web application server&quot; gives some decent information on using CFMX to query data from DB2 on that platform.
				
				</description>
						
				
				<category>DB2</category>				
				
				<category>JDBC</category>				
				
				<category>JTOpen</category>				
				
				<category>Database</category>				
				
				<category>iSeries</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Wed, 10 Dec 2003 13:29:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2003/12/10/76</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>FIX:  Handling Bad Database Username/Passwords with CFMX and DB2/400</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2003/9/5/56</link>
				<description>
				
				A problem that&apos;s been plaguing a lot of us that use CF MX and IBM&apos;s JTOpen JDBC driver to connect to DB2 running on IBM&apos;s iSeries (AS400) has to do with CF MX hanging when a bad username or password is passed to the database.  It&apos;s really frustrating on so many levels, especially since the only way to free the hang is to restart the CFMX service.  Sometimes even this isn&apos;t enough, and the server must eb rebooted.  Obviously, this isn&apos;t good in a production environment.

Jeremy Lyon emailed me today to let me know that there&apos;s a JDBC URL parameter that you can set to fix this problem.  Basically, there&apos;s a parameter called &lt;i&gt;prompt&lt;/i&gt;.  The JavaDoc definition for prompt is:

&quot;Specifies whether the user should be prompted if a user name or password is needed to connect to the server. If a connection can not be made without prompting the user, and this property is set to &quot;false&quot;, then an attempt to connect will fail.&quot;

What this means is that by default, prompt is set to True.  If you pass a bad username or password, the system attempts to &quot;prompt&quot; the user for a username/password.  Since you aren&apos;t using an interactive application to make your connection, you never see this prompt, and the system &quot;hangs&quot; indefinitely.  

The fix is to &lt;b&gt;ALWAYS&lt;/b&gt; specify prompt=false in your JDBC url.  This way, id a bad username/password is passed, the JDBC driver will report this back to ColdFuion, and an exception can be thrown.
				
				</description>
						
				
				<category>DB2</category>				
				
				<category>JDBC</category>				
				
				<category>JTOpen</category>				
				
				<category>Database</category>				
				
				<category>iSeries</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Fri, 05 Sep 2003 07:55:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2003/9/5/56</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JT400 4.1 Released/Back from Vacation</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C2059226-D608-AED8-7E7B15DC673EC28A</link>
				<description>
				
				After a nice long week off, I&apos;m back from vacation.  Man, I can&apos;t wait for retirement ;-)  Of more important note is the release of JTOpen 4.1 by IBM (an open source JDBC driver for iSeries [AS400] DB2).  This is basically a maintenance release that fixes all sorts of minor issues, as well as adds some enhancements to the driver.  You can &lt;a href=&quot;http://www-124.ibm.com/developerworks/projects/jt400&quot; target=&quot;_new&quot;&gt;download&lt;/a&gt; it from IBM.  I&apos;ve already installed it on two machines, and it&apos;s been working for a few hours on a rather large application with no apparent issues.
				
				</description>
						
				
				<category>Database</category>				
				
				<pubDate>Mon, 18 Aug 2003 08:16:31 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C2059226-D608-AED8-7E7B15DC673EC28A</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Better Error Messages in JTOpen</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm/2003/5/30/Better-Error-Messages-in-JTOpen</link>
				<description>
				
				I&apos;ve often found the ODBC/JDBC error messages returned by DB2/400 to be less than helpful.  While reading the JavaDoc for the JTOpen 4.0 driver today, I came across a property I hadn&apos;t noticed before.  Apparently, you can instruct the driver whether to return a full or basic error description when an error occurs.  Of course, the default value is basic.  So, if you use JTopen with ColdFusion MX to connect to DB2 on an AS400, you can cause the driver to return the full error (often along with a fix recommendation) by adding errors=full to the JDBC URL you setup in the ColdFusion Administrator.

Stay tuned for more JTOpen/CF MX tidbits as I try to figure out why DB2/400 seems to perform like an old dog when compared to the likes of SQL Server and Oracle (Solaris).  If you&apos;re currently a JTOpen user, or connect ColdFusion to DB2/400 in another way, I&apos;d love to hear your comments!
				
				</description>
						
				
				<category>DB2</category>				
				
				<category>JDBC</category>				
				
				<category>JTOpen</category>				
				
				<category>Database</category>				
				
				<category>iSeries</category>				
				
				<pubDate>Fri, 30 May 2003 12:00:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm/2003/5/30/Better-Error-Messages-in-JTOpen</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JTOpen 4.0 (DB2/400 JDBC Driver) Released</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C20581CC-D608-AED8-7EA7D4AD00F76128</link>
				<description>
				
				IBM just released version 4.0 of their open source JDBC (TYPE IV) driver for DB2/400.  I&apos;ve been using JTOpen since CFMX was in beta, and have been generally happy with the results (sans a few bugs).  This release boasts dozens of fixes and improvements.  I plan to install and test the new driver next week to see how it performs.

If you connect to DB2/400 from CF MX, I highly recommend you check out JTOpen.  You can download the latest build here:

&lt;a href=&quot;http://www-124.ibm.com/developerworks/downloads/index.php?group_id=29&quot; target=&quot;_new&quot;&gt;http://www-124.ibm.com/developerworks/downloads/index.php?group_id=29&lt;/a&gt;
				
				</description>
						
				
				<category>Database</category>				
				
				<pubDate>Wed, 30 Apr 2003 08:23:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C20581CC-D608-AED8-7EA7D4AD00F76128</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JTOpen 3.3 Released</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C2057D77-D608-AED8-7BF8A80449743A57</link>
				<description>
				
				IBM recently released JTOpen 3.3, an open source JDBC driver for connecting ColdFusion to DB2/400.  Believe it or not, I&apos;m not the only person out there using DB2/400 as a backend database.  Anyhow, you can download the latest version from &lt;a href=&quot;http://oss.software.ibm.com/developerworks/opensource/jt400/downloads.html&quot;&gt;http://oss.software.ibm.com/developerworks/opensource/jt400/downloads.html&lt;/a&gt;.  Note that registration is required.
				
				</description>
						
				
				<category>Database</category>				
				
				<pubDate>Wed, 27 Nov 2002 15:01:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C2057D77-D608-AED8-7BF8A80449743A57</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>More on JTOpen 3.2 JDBC Driver Problem with CFMX</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C2057A58-D608-AED8-7BB741BA486D7BB7</link>
				<description>
				
				Well, after another day of experimenting, it looks like the empty recordset I described on 9/26/2002 is a problem with the 3.2 version of JTOpen.  The issue only happens during certain complex SP operations, and shouldn&apos;t cause problems for relatively simple SPs (selects, selects with multiple joins, etc.).  I&apos;ve posted the problem to the JTOpen project site and will blog another update as soon as I have more info.
				
				</description>
						
				
				<category>Database</category>				
				
				<pubDate>Sat, 28 Sep 2002 20:42:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C2057A58-D608-AED8-7BB741BA486D7BB7</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>New Version of JTOpen (3.2) JDBC Driver Available for DB2/400</title>
				<link>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C20578F0-D608-AED8-7E3EC1312EC5C5FF</link>
				<description>
				
				If you use CFMX to connect to DB2 on an AS400, you might be interested to know that IBM recently released a new version of the Open Source JTOpen JDBC driver.  I have been using version 3.1 for a while now and it&apos;s been working fairly well (except for an issue when I run a SP that pulls back no records, the query object that gets created doesn&apos;t contain any of the column headers or the recordcount variable, but I&apos;m not sure if this is a driver or a CF issue).  I haven&apos;t tried 3.2 yet, but I&apos;m planning to install it soon and give it a whirl.  If you want JTOpen, you can get it &lt;a href=&quot;http://oss.software.ibm.com/developerworks/opensource/jt400/downloads.html&quot;&gt;here&lt;/a&gt; (registration required).
				
				</description>
						
				
				<category>Database</category>				
				
				<pubDate>Thu, 26 Sep 2002 13:47:00 -0400</pubDate>
				<guid>http://www.brooks-bilson.com/blogs/rob/index.cfm?mode=entry&amp;entry=C20578F0-D608-AED8-7E3EC1312EC5C5FF</guid>
				
			</item>
			
		 	
			</channel></rss>