0

I am using the JDBC-ODBC bridge to connect to a QuickBooks database. (Intuit has offered sparse support, and does not have their own direct java driver to my knowledge). This was great in JRE/JDK 7. Now in JRE/JDK 8 this feature was removed. That's fine. I am attempting to use the solution mentioned by "frhack" in THIS (Removal of JDBC ODBC bridge in java 8) post. However, what frhack is suggesting is to essentially move the bridge directly from Java 7 to Java 8, a process which i would have to do each time if i wish to update my JDK.

What i want to do instead, is make the jdbc.jar file, with the DLL file included, so that i can simply use it as a standalone library. I created a jar as instructed, but also placed the DLL in the root of the archive.

This seems to work...... partly. I did not need to change any of my code, and the class loads! However, when i try to connect to the data source, the new library throws an NPE. Since this is compiled code (Class files), i can not see the exact problem, but i presume one possibility is it doesn't know that the location of the dll file has changed. Following is a section of my code, alongside some output of a stack trace.


Output of stack trace:

Debug - Exception caught!
java.lang.NullPointerException
    at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:453)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at Dashboard.Modules.Uploader.Data.DatabaseManager.connect(DatabaseManager.java:83)
    at Dashboard.Modules.Uploader.Data.DatabaseManager.outputData(DatabaseManager.java:57)
    at Dashboard.Modules.Uploader.Uploader.exportData(Uploader.java:182)
    at Dashboard.Modules.Uploader.Uploader.run(Uploader.java:112)

Code snippet of DatabaseManager.java:

25    private final String url = "jdbc:odbc:quickbooks";
...
28    private final String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
...
77    private boolean connect()
78    {
79        boolean result = true;
80        try
81        {
82            Class.forName(driver);
83            con = DriverManager.getConnection(url);
84        }
85        catch (ClassNotFoundException | SQLException e)
86        {
87            result = false;
88            e.printStackTrace();
89            System.out.println(e.getMessage());
90        }
91        catch (Exception x)
92        {
93            System.out.println("Debug - Exception caught!");
94            x.printStackTrace();
95        }
96        
97        return result;
98    }

Is my assumption correct? Is there a way to structure the jar file to include the DLL file so that it is usable, or another place within my project i can place this? I would prefer to embed it into the jar itself, because of the ease of use once this is set up.

Thanks in advance for any help and advice on this!

Community
  • 1
  • 1
Drifter64
  • 1,103
  • 3
  • 11
  • 30
  • If you want to see where the DLL is being loaded from (if it is being loaded at all), try using [SysInternals Process Monitor](https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx). – Luke Woodward Jul 21 '16 at 19:12
  • That's interesting, but im fairly sure that the NPE has to do with the location of the DLL. After all, the solution which asks that you rip out part of JDK7 to put in JDK8 has you store the DLL in a specific location, which is being violated by me without knowledge of how to modify things to point to the new location. – Drifter64 Aug 04 '16 at 13:11

0 Answers0