2004-05-02 23:11:07 UTC
Why?
I needed a way to read an access database from java and found the java -> jdbc -> odbc -> mdbtools.odbc - mdbtools core to be too much of a hassle, both for setting up and runtime.
Instead I opted for a 100% java solution and started to port mdbtools to 100% java. This allows for simple setup (ie just ensure the jar file is on the classpath) and development (no new api) and rumtime (if mdbtools crashes all you have to do is catch the exception)
How was this done?
My approach is to simply port the c code with minimal changes and then run the programs in util to ensure the ported code works, and then to implement a jdbc driver that uses the ported code.
Status:
Right now i got the mdb-tables file ported to java and enough of the libmdb code to enable mdb-tables to work. (ie from java I can get a list of table names) I also have a jdbc driver that accepts the query:
list tables
and hands back the table names.
Code:
As an example: to get all the table names from an access database simply do:
Class.forName("mdbtools.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mdbtools:" + filename);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("list tables");
while (rset.next())
System.out.println(rset.getString(1));
What's next:
Next I'm going to work on getting mdb-schema ported and allow the jdbc driver to accept:
desc table_name
and pass back the schema for the table
After that I'll get mdb-export to work. At this point a java program can open an access database and dump out all of the data.
Version:
I'm using the 0.5 version that i downloaded last week.
Once I get the mdb-export to work I'll see about synching to head
Help out?
If you would like the driver to further test the port just let me know