Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use the JDBC to Microsoft Access in Linux?.Urgent

Status
Not open for further replies.

djiska

Programmer
Mar 5, 2003
3
ES
Hi
I run an application. This application is attempted to connect to a Access's file(this file is in Linux). But it gives me a exception "java.sql.SQLException:No suitable driver". I think that it can lack the driver. if it is so. can you tell me where can I to get?

The code is that:This run rightly in Windowss

import java.sql.*;
    class Test
    {
        public static void main(String[] args)                                                 
        {
            try {
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                        // set this to a MS Access DB you have on your machine
                                        String filename = "/home/jaac/java/prueba/prueba.mdb";
                                        String database = "jdbc:eek:dbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
                                        database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
                                        // now we can get the connection from the DriverManager
                                          Connection con = DriverManager.getConnection( database ,"","");
                        }
                        catch (Exception e) {
                                   System.out.println("Error: " + e);
                        }
                 }
         }
 
I believe you have to set up an ODBC connection to the Access database before you can connect to it with java. Have you already done this? If you have, you can test it by loading Access on the windows box and going through "Get external data -> link tables".

"When you have eliminated the impossible, whatever remains, however
improbable, must be the truth." ~ Arthur Conan Doyle
 
try this...

connection = DriverManager.getConnection("jdbc:eek:dbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=" + filename+","","");

The two quotes at the end are if you want to supply a user name/password (below is another example) there needs to be 1 blank apace before (*.mdb) !!!

jdbc:eek:dbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=" + DataBasePath + ","dba","sql");

And if I'm not mistaken (However I can/and have been wrong in the past)..."DriverID=22;" is if you are connecting to an Excel spreadsheet w/ODBC...

also you may want to take a look at this site:
it show you how to:
Connect an MS Access database, using:
The JDBC/ODBC Bridge (local)
RmiJdbc and the JDBC/ODBC Bridge (allows remote client/server)
Or how to make the JDBC/ODBC Bridge become a Type 3 (client/server) JDBC Driver!

hope this help...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top