Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

comike011

macrumors newbie
Original poster
Jun 30, 2005
6
0
New York, New York
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.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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).
 

dlamet

macrumors newbie
Nov 11, 2009
2
0
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.