logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

MDBTools and UnixODBC: msg#00011

Subject: MDBTools and UnixODBC

Hi.. As part of the course I'm currently studying, we are asked to use 
Java to manipulate an MS Access database. 

The general idea is that we do this using Java, and the JDBC-ODBC 
gateway for Windows. However, the course team have said that they would 
be interested to hear of success from those of us who are using Linux. 

This is how I came to be experimenting with mdbtools.

I can access an mdb database file using the various stand-alone utilities 
that come as part of the mdbtools package, but so far,  I'm having no 
success interfacing the database to the ODBC framework using the 
libmdbodbc library that comes as part of mdbtools and consequently my 
attempts at accessing the database via the JDBC-ODBC bridge are also 
failing. 

A guy called Bryan Mills has a webpage documenting his success using  
the mdb ODBC driver and UnixODBC (which he accesses with PHP rather than 
Java) but his success seems to be unique. 

I can't find anyone else on the net who has duplicated it. Bryan's 
webpage is at http://bryanmills.net:8086/archives/000099.html

I've followed Bryan Mills' example for creating the UnixODBC template 
files (where my odbcinst.ini references the mdb driver library and 
odbc.ini references the DSN and its database)  and then I've used the 
isql tool which comes as part of UnixODBC to successfully query the mdb 
database, but that's about as far as my successes have gone.

        root@home mdbtools]# isql M360products
        +---------------------------------------+
        | Connected!                            |
        | sql-statement                         | 
        | help [tablename]                      |
        | quit                                  |                               
        
        +---------------------------------------+
        SQL> select ProductName,Quantity from StoreProducts where Quantity<50
        +---------------------------------------------------+---------+
        | ProductName                                       | Quantity|
        +---------------------------------------------------+---------+
        | Blue Shirts                                       | 30      |
        | Green Shirts                                      | 0       |
        | Grey Trousers                                     | 0       |
        | Khaki Trousers                                    | 33      |
        | White Jackets                                     | 22      |
        | Green Jackets                                     | 44      |
        +---------------------------------------------------+---------+
        6 rows affected
        6 rows returned
        SQL>

The following show the contents of my odbc.ini file, which should, as far 
as I understand it, bind the MDB ODBC service to port 5432. I'm curious 
to find that netstat doesn't show anything listening on 5432. Is that 
an indication that something is wrong?

        [root@home lib]# cat /etc/odbc.ini

        [ODBC Data Sources]
        M360products = libmdbodbc

        [M360products]
        Driver          = /usr/local/lib/libmdbodbc.so
        Description     = M360 products
        Database        = 
/home/michael/M360/TextExercises/C5Code/5.1/src/Ex51/ProductsExercise.mdb
        ServerName      = localhost
        Port            = 5432

Using the odbcinst tool to query UnixODBC shows that the MS Access driver 
has apparently been successfully loaded by UnixODBC, and that my demo 
MS Access database, ProductExercise.mdh has been successfully registered 
on the ODBC resource with the Data Source Name  M360Products.

        [root@home lib]# odbcinst -q -d
        [MDBToolsODBC]

        [root@ttfn35 lib]# odbcinst -q -s
        [M360products]
        [ODBC]

Unfortunately, when I execute Java code known to work for Windows ODBC
and which should issue an SQL query against this database through the 
JDBC-ODBC gateway, I get the following error reported:

        [root@home Ex51]# java ex51/QuerySolution
        ***Solution being executed***...
        Driver loaded
        Problem accessing the database java.sql.SQLException: 
        [unixODBC][Driver Manager]Data source name not found, and no default 
driver specified

I've tried using the mdbodbc driver that comes with the latest version of 
mdbtools packaged in RPM format, and I've built mdbtools from the source 
tar ball on the mdbtools site and I've tried the latest version from CVS 
(which apparently now supports mdb write) but sadly all have stalled at 
this same hurdle. 

I'm currently moving from UnixODBC to iODBC in order to rule out that as 
the problem.

Would someone kind here please point out what I'm doing wrong, and how 
they got the ODBD mdb driver to function as it is intended.

Thank you (and apologies for the long-winded posting!)

Michael



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click


<Prev in Thread] Current Thread [Next in Thread>