Display ColdFusion JDBC Drivers on Windows

Posted by Dan on Jan 15, 2008 @ 10:05 AM

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.

Categories: HTML/ColdFusion

3 Comments

  • Cool, it works without modification!
  • 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
  • Thank you for this, we had a very strange error in Oracle after connecting from CF10. I used your code above, changing the runtime folder name to jetty and it returned the information that my DBA needed.

Comments for this entry have been disabled.