<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Rob Brooks-Bilson&apos;s Blog - DB2</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:45:33 -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>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>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>
			
		 	
			</channel></rss>