Display ColdFusion JDBC Drivers on Windows

Categories: HTML/ColdFusion

Today I ran across an interesting post on cfSearching on how to display the ColdFusion JDBC driver versions on Windows. Knowing this could be useful debugging information, I decided to save the code snippet for future use. However, I quickly released it was targeted directly for ColdFusion MX 7 and also had some hard coded paths that would need to be changed in order to run it on every system.

Since I wanted to be able to run this on any version of ColdFusion, I decided to modify the code a bit so it would work with any version of ColdFusion v6.1 or higher and it shouldn't require changing any of the path information.

Here's my modified version of the code:

<!---//
    getJDBCDriverInfo.cfm
    Description:
    This template will display the JDBC information contained in your ColdFusion
    installation.
//--->

<h1>
    <cfoutput>
        #Server.ColdFusion.ProductName#
        #Server.ColdFusion.ProductLevel#
        v#replace(Server.ColdFusion.ProductVersion, ",", ".", "all")#
    </cfoutput>
</h1>
<cfset driverInfo = arrayNew(1) >
<cfset pathToJava = Server.ColdFusion.RootDir & "\runtime\jre\bin">
<cfset pathToDriverJar = Server.ColdFusion.RootDir & "\lib\macromedia_drivers.jar">
<cfset drivernames = "macromedia.jdbc.oracle.OracleDriver, macromedia.jdbc.db2.DB2Driver, macromedia.jdbc.informix.InformixDriver, macromedia.jdbc.sequelink.SequeLinkDriver, macromedia.jdbc.sqlserver.SQLServerDriver, macromedia.jdbc.sybase.SybaseDriver">
<cfloop list="#driverNames#" index="driver">
    <cfexecute
        name="cmd.exe"
        arguments="/c #pathToJava#\java -cp #pathToDriverJar# #driver# 2>&1"
        variable="out"
        timeout="6"
            />

    <cfif IsDefined("out")>
        <cfset data = structNew()>
        <cfset data.class = driver>
        <cfset data.version = out>
        <cfset arrayAppend(driverInfo, data)>
    </cfif>
</cfloop>
<cfdump var="#driverInfo#">

I also modified the original code to output the version of ColdFusion that's running on the server. Credit goes to cfSearching for the original code.

Comments

Michael White's Gravatar Cool, it works without modification!
cfSearching's Gravatar Nice improvement to the code! I hard coded the paths for demonstration purposes. But I like that your modification improves portability. I will update the entry to mention your improvements.

Cheers

Add Comment

Leave this field empty


If you subscribe, any new posts to this thread will be sent to your email address.