Web Trenches

JDBC-ODBC Bridge on Lucee



First, you will need to extract and repackage the appropriate classes and DLL from a Java 1.7 install. This section is adapted from http://bigfatball.blogspot.it/2016/03/how-to-enable-jdbc-odbc-bridge-for-jdk-8.html.

  1. Download a JDK 7 or JRE 7 and install it.
  2. Goto JRE\lib folder and find the rt.jar
  3. Unzip it (if you have WinRAR installed) or you can rename it to rt.zip and unzip it.
  4. Copy sun\jdbc and sun\security\action folders out to a new folder, keep the folder structure. i.e., you should have the folder structure like below:
    • Sun –> Security –> Action
    • Sun –> JDBC
  5. Open a CMD window. Go to the parent folder of Sun folder. Run the command:jar -cvf jdbc.jar sun

    NOTE: You may need the full path to jar.exe in here. Example: “c:\Program Files\Java\jdk1.7.x\bin\jar.exe” -cvf jdbc.jar sun

  6. The above command will create a file named jdbc.jar
  7. Copy JDBC.jar to your Lucee lib/ext folder.  This is typically at C:\lucee\jdk\jre\lib\ext.
  8. Copy jdbcodbc.dll from JRE\bin  of your JRE 7 installation to Lucee’s JRE\bin. This is typically at C:\lucee\jdk\jre\bin.
  9. Restart Lucee.

You should now have the classes available to set up an ODBC datasource in Lucee.

  1. Confirm that your ODBC datasource is set up in the Windows ODBC manager.
  2. Go to your Lucee server or web admin.
  3. Select Datasource from the left menu.
  4. Under “Create new datasource”, give it a name and select “Other-JDBC Driver” and click Create.
  5. Add a username of “System” and leave password blank.
  6. For Class, enter “sun.jdbc.odbc.JdbcOdbcDriver”.
  7. For Connect string, enter “jdbc:odbc:<odbc data source name>”. For example, “jdbc:odbc:mydsn”. This must exactly match the ODBC datasource name in Windows.
  8. Click UPDATE.
  9. After submission, you should see an OK next to your new datasource and it is available for use.

DISCLAIMER: I have no idea if this violates any licensing for Java.

5 Replies to “JDBC-ODBC Bridge on Lucee”

  1. Finally have it seeing the driver but now I’m getting Java.lang.NullPointerException.. Using Lucee 5.2.4.37 war on Tomcat.. all Lucee files seem to be in webapps/ROOT/WEB-INF so I’m thinking issue is with placement of the JdbcOdbc.dll

    in order to see jdbc.jar had to put it in ROOT/WEB-INF/lib

    for jdbcodbc.dll the only place I see other dll files is webapps/ROOT/WEB_INF/bin

  2. I’ve just installed Lucee 5.3.6.61. There is no c:\lucee\jdk c:\lucee\jre

    I installed the JDK to get the jar.exe and had no issue creating the jdbc.jar. I also found one online and get the same result.

    lucee.commons.lang.ClassException: cannot load class through its string name, because no definition for the class with the specified name [sun.jdbc.odbc.JdbcOdbcDriver] could be found caused by (java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver not found by lucee.core [46];java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver;)

    I’ve tried modifying the registry in Windows and then it fails on
    sun/security/action/LoadLibraryAction

    lucee.runtime.exp.NativeException: sun/security/action/LoadLibraryAction at sun.jdbc.odbc.JdbcOdbc.(Unknown Source) while setting the ODBC

    I get a
    Lucee 5.3.6.61 Error (java.lang.NoClassDefFoundError) when I try to use the datasource.

    20 hours in and still no joy.

Leave a Reply

Your email address will not be published. Required fields are marked *