Determining Your JDBC Driver Version: Pick from 3 ways
This news has been shared in various blog entries over the past couple of years. I'd like to reprise them here for your edification. Just pay close attention to whether you mean to have them look at CFMX or CFMX 7. They each point to a directory such as C:\CFusionMX\lib or C:\CFusionMX7\lib. Make sure you use the value appropriate to your configuration:
- Pete Freitag showed some CFML code that gives you the answer on screen:
- Brandon Purcell showed a CFML approach that writes its output to the the CFMX log files instead (as of tonight, that blog entry is failing, but you can find its info thanks to the Google cache entry for that page)
- Finally, Sarge showed how to get the info via the command line (this is a version of the page recovered using the good 'ol internet archive/wayback machine)




http://www.adobe.com...
When I ran it on CF7, though, it got an error trying to check the MySQL driver. So I modified it with an extra try/ctach to detect such an error. Here is that code with the revision. (There are many other ways the try/catch could have been done. This way works and is good enough to get the answer we need.)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Macromedia Drivers Version</title>
</head>
<body>
<h2 align="center">DataDirect Driver Listing</h2>
<table border="1" align="center" bordercolordark="black">
<tr bgcolor="#808080"><th>driver</th><th width="100">version</th></tr>
<cfscript>
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,org.gjt.mm.mysql.Driver,com.mysql.jdbc.Driver";
drivernames=Replace(drivernames," ","","ALL"); //<!--- replace all spaces --->
a_drivernames = ListToArray(drivernames);
len = ArrayLen(a_drivernames);
for (x = 1; x LTE len; x=x+1) {
try {
driver = CreateObject("java", a_drivernames[x]);
writeoutput("<tr><td> " & a_drivernames[x] & " </td> " & "<td align='center'>" & driver.getMajorVersion() & "." & driver.getMinorVersion() & "</td></tr>");
}catch (Any excpt){
writeoutput("<tr><td> " & a_drivernames[x] & " </td> " & "<td align='center'>Unavailable</td></tr>");
}
args= ArrayNew(1);
try{
driver.main(args);
}catch(Any excpt){}
}
</cfscript>
</table>
<br><br><br>
<h3>Extended version information is output to system out (console or out.log).</h3>
</body>
</html>