New mac programmer (Java,jdbc-odbc)

Discussion in 'Mac Programming' started by comike011, Jun 30, 2005.

  1. comike011 macrumors newbie

    Joined:
    Jun 30, 2005
    Location:
    New York, New York
    #1
    SO Im new to both mac programming and database access via java programs. Im trying to write a program that uses a .mdb database using xcode but am not able to load the driver apparently. The following:

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    is leading to a ClassNotFoundException that stops the program. This is probably a pretty lame question, but I cant figure it out (can you get banned for insulting yourself?). Any help with how to this would be great, Thanks.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    That class is not in your classpath. To find out what your classpath is open the Terminal and type echo $CLASSPATH. It may well not return anything in which case you are using the system classpath. If this is the case find out where that class is on your system and and that folder root your your classpath (i.e. you want to add folder that contains sun, not the folder with the actual class file).
     
  3. dlamet macrumors newbie

    Joined:
    Nov 11, 2009
    #3
    JDBC-ODBC Bridge Not Default on Mac OS

    The reason you're not finding the sun.jdbc.odbc.JdbcOdbcDriver is that it's not provided in the version of Java shipped on the Mac. The JDBC-ODBC Bridge using that class was written a long time ago when ODBC was not available on the Mac. It used native Windows components, and so was not portable.

    ODBC is now provided on OS X via the iODBC open source project. They do a reasonably good job of implementing ODBC for non-Windows systems. But they don't take ownership of the JDBC-ODBC Bridge, and neither does Apple who produces Java for OS X. Hopefully some eager souls out there are working on this void. OpenLink provides a solution, but it's very expensive. (Just priced out a minimal installation at $569.25.)

    If you're trying to get to MS Access via JDBC, there are a couple of direct alternatives. HXTT sells a driver <http://www.hxtt.com/access.html> and so does Stels <http://www.csv-jdbc.com/stels_mdb_jdbc.htm>. I've just done minimal evaluation on both, and they both seem to work well. Bypassing ODBC will be more efficient for you anyway. One less layer.

    Dan
     

Share This Page