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.
- Download a JDK 7 or JRE 7 and install it.
- Goto JRE\lib folder and find the rt.jar
- Unzip it (if you have WinRAR installed) or you can rename it to rt.zip and unzip it.
- 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
- 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
- The above command will create a file named jdbc.jar
- Copy JDBC.jar to your Lucee lib/ext folder. This is typically at C:\lucee\jdk\jre\lib\ext.
- 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.
- Restart Lucee.
You should now have the classes available to set up an ODBC datasource in Lucee.
- Confirm that your ODBC datasource is set up in the Windows ODBC manager.
- Go to your Lucee server or web admin.
- Select Datasource from the left menu.
- Under “Create new datasource”, give it a name and select “Other-JDBC Driver” and click Create.
- Add a username of “System” and leave password blank.
- For Class, enter “sun.jdbc.odbc.JdbcOdbcDriver”.
- 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.
- Click UPDATE.
- 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”
Finally have it seeing the driver but now I’m getting Java.lang.NullPointerException.. Using Lucee 126.96.36.199 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
You need the JDK, not the JRE to get the jar executable
I’ve just installed Lucee 188.8.131.52. 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 ;java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver;)
I’ve tried modifying the registry in Windows and then it fails on
lucee.runtime.exp.NativeException: sun/security/action/LoadLibraryAction at sun.jdbc.odbc.JdbcOdbc.(Unknown Source) while setting the ODBC
I get a
Lucee 184.108.40.206 Error (java.lang.NoClassDefFoundError) when I try to use the datasource.
20 hours in and still no joy.
Morgan, Mike or Timothy: did you ever get this working? We find ourselves trying to access legacy data via ODBC and I get the “Java.lang.NullPointerException” as well