2
votes

I'm currently looking to write an importer in my Java program to import data from a file which contains a JET database, but so far searching for a JDBC driver for this format (or just another Java library which can read from it) has proved fruitless.

Does anyone know if such a driver exists, or if not what (platform independent) alternatives might be available?

3

3 Answers

2
votes

I actually have been importing CSV files into Access database using JDBC and jetEngine query like this

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// set this to a MS Access DB you have on your machine

String filename = "C:/Automation_Tools/Databases/Data.mdb";

String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";

database+= fileName.trim() + ";DriverID=22;READONLY=false}";

// add on to the end now we can get the connection from the DriverManager

con = DriverManager.getConnection( database ,"","");

and then using query like this

String sql = "INSERT INTO " + accessTableName + " SELECT * FROM [Text;HDR=YES;TextDelimiter=\";Has Quotes=TrueFMT=Delimited(,);DATABASE=" + csvDirPath + ";].[" + csvFileName + "]";

//Import/create table String sql = "SELECT * INTO " + accessTableName + " FROM [Text;HDR=YES;TextDelimiter=\";FMT=Delimited(,);DATABASE=" + csvDirPath + ";].[" + csvFileName + "]"; `

2
votes

I am just now researching this myself and am going to try out UCanAccess. According to the main page it says that it is

an open source Java JDBC Driver implementation which allows Java developers and jdbc client programs (e.g., DBeaver, NetBeans, SQLeo, Open Office Base, Libre Office Base, Squirrell) to read/write Microsoft Access database.

Because it is a pure java implementation it run in both Windows and non-Windows Operative Systems(e.g., linux/unix). No ODBC needed.

1
votes

You can use the built in JDBC ODBC bridge driver. Use a connection string like: jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=database.mdb. This is not platform independend. The Jet engine (or ACE) has to be installed. Sometimes there are problems with encoding and Memo fields.

There is an alternative: http://www.hxtt.com/access.html They claim platform independence but I didn't try it myself.