views:

317

answers:

3

Do you know of any good guides on how to access an Access database using Java?

I know the basics and basic SQL, but I'm thinking more about access control.

A: 

JDBC is the way to go. Google for "JDBC tutorial" + mysql, you will get all you need.

Here Be Wolves
You clearly didn't read the question. I know how to use google. Thanks.
Relequestual
On the contrary, I did read the question. I was just giving you the right terms to search for. It is infinitely better to know what you want but not have it (for now) that to not know at all.
Here Be Wolves
@jharshath: I don't see any version in the edit history of this question that mentioned MySQL.
David-W-Fenton
+4  A: 
private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}";

    // Initialize the JdbcOdbc Bridge Driver
    static {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(ClassNotFoundException e) {
            System.err.println("JdbcOdbc Bridge Driver not found!");
        }
    }

    /** Creates a Connection to a Access Database */
    public static Connection getAccessDBConnection(String filename) throws SQLException {
        filename = filename.replace('', '/').trim();
        String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix;
        return DriverManager.getConnection(databaseURL, "", "");
    }

Some useful links:

NinethSense
Brilliant, exactly what I was looking for!Few links and some code. Cheers.
Relequestual
A: 

If you mean using relational databases in Java, you'll need to know JDBC.

You won't be able to do much with security using JDBC. You'll have to build it into the application using something like JAAS or Spring Security.

duffymo