[Looking for Charlie's main web site?]

Determining Your JDBC Driver Version: Pick from a couple of ways

Following onto my 2 previous entries related to updating JDBC drivers in CFMX 6 and 7, some readers may appreciate a little more help on the matter of determining just what version of the drivers they do now have installed.

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. (Note that while they may show how to look at some particular driver, like SQL Server, you can--and would need--to change what they show to look at whichever driver you are interested in. More on that below.):

So a couple more thoughts on all this.

And about the last two options above

First, in the case of the second two options above, note two things:

  • Those last two links are versions of each page as recovered using the good 'ol internet archive/wayback machine. For more on the value of this wonderful tool, see my post on that.
  • Note that those last two links make reference to files or folders under C:\CFusionMX\ or C:\CFusionMX7\ folders, reflecting the time they were written. For those on CF10 and above, you would look now instead under [yourcf]\cfusion\, or if using instances, [yourcf]\[yourinstance]\.

Finding the version of the driver YOU are using

Second, I said above that you would need to use the name of the driver you really mean to look at, which may be different than what their example show. For instance, Pete's code shows looking at the SQL Server driver, macromedia.jdbc.sqlserver.SQLServerDriver. So what if you're using the Adobe-provided Oracle driver? Or any other?

Well, some good news if you use an "other" driver type (where you choose that in the CF Admin DSN page), then you must provide the driver classname yourself. That would be the name to use.

But what if you one of the several other kinds of drivers listed on that page? CF doesn't show you the classnames it uses for that. (And I could not find it in several places I looked. More below.)

But again see Steven Erat's code above that listed several of the class names known at the time (and which still seem fairly accurate more recently).

And while there are still other places that clever readers may want to point out that may hold them, I could not find them in these places:

  • The DSN classname is not listed in the CF Admin page where you add/edit a DSN
  • The DSN classname is not not listed in the CF Admin "settings summary" page, even though that does offer useful additional info, like the underlying jdbc URL that CF builds, when using its built-in DB drivers
  • They classname is also not listed in the XML within the neo-datasources.xml or neo-drivers.xml files, if you know about them. There ARE classnames there, but you will see that if you look, for instance, at the SQLServer one, it does show a classname (in the "class" xml element). But it's just macromedia.jdbc.MacromediaDriver, not the macromedia.jdbc.sqlserver.SQLServerDriver used in the examples above.
  • They're also not listed in the "system information" page in the CF admin--the "i" icon in the top right--which shows the "CF Server Java Class Path". That does not list the class names for the Adobe-provided DB drivers, because they are instead all embedded in one jar, called macromedia_drivers.jar. Really determined folks may know you can unzip that and dig around and determine class names and paths, but I won't elaborate that here.

So it seems that for the built-in CF-provided drivers, you're best off just using the variations offered in those examples above (especially Steven's).

Hope all that help others as much as they have me over the years.

Comments
I found yet a 4th option, some different CFML code offered by Ken Smith on the Adobe CF Admin forums:

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>&nbsp;" & a_drivernames[x] & "&nbsp;</td> " & "<td align='center'>" & driver.getMajorVersion() & "." & driver.getMinorVersion() & "</td></tr>");
   }catch (Any excpt){
      writeoutput("<tr><td>&nbsp;" & a_drivernames[x] & "&nbsp;</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>
# Posted By Charlie Arehart | 10/30/08 11:49 AM
As an update to this post (from 2006), regarding the command-line example frmo sarge (in a blog post of his from 2005, in the CF7 timeframe), the way to do that as of later releases is just different with respect to the path to where the CF lib folder is. For instance, in CF 2016 on Windows, one can get the SQL Server driver version using this:

java -cp C:\ColdFusion2016\cfusion\lib\macromedia_drivers.jar macromedia.jdbc.sqlserver.SQLServerDriver

And if you get an error that java "is not recognized as an internal or external command", it's simply that you have no "public JRE" on your server, which can be a good thing, security wise. Just replace the java portion of the command above with with c:\ColdFusion2016\jre\bin\java, again on WIndows and for CF 2016, which will point to the jvm installed within CF. So the final version would be:

c:\ColdFusion2016\jre\bin\java -cp C:\ColdFusion2016\cfusion\lib\macromedia_drivers.jar macromedia.jdbc.sqlserver.SQLServerDriver
# Posted By Charlie Arehart | 2/17/16 12:07 PM
Copyright ©2018 Charlie Arehart
Carehart Logo
BlogCFC was created by Raymond Camden. This blog is running version 5.005.
(Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting