5

I have a rather large DBF file, about 40 megs, that I need to be able to query. Right now I am reading the DBF, it's just tabular text, into a h2 database and querying the h2 database. This works, but seems... stupid. I've been looking for a type 4 JDBC driver for DBF, but haven't had any luck. What is the proper way to do this?

0

3 Answers 3

3

There is a registry of JDBC drivers at http://developers.sun.com/product/jdbc/drivers . You can select your platform, for example dBase for DBF files and look for a driver. For dBase it lists a bunch of drivers and many of them are type 4. I didn't look into details whether any of these drivers are free.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, that's a great reference. I think that page must have been down when I was looking (which was a couple months ago). I found links to it, but it was 404'ed or something. Doesn't look like any of these are open source / free. Nothing against paying for software of course, its just hard to justify for this particular project. Oh well. Thanks again!
If you are working with a single DBF file, it's easier to just treat it as a binary file.
I remember implementing a Turbo Pascal module reading DBF files based on the DBF file format description in Programmers' Journal in mid-eighties. I googled a bit and found following: javadbf.sarovar.org.
3

For such tasks as data exchange for large size - this way for using JDBC bridge seems to me very slowly. Also you can get some runtime errors during data exchange.

The best way is using file IO libraries. After some years I issued such pure pure lightweight library and will present you. (Under LGPL)

You may download it from here

See dbf reading code below. It is very simple.

public class Fp26Reader {
  private static void testRead() {
        DbfIterator dbfIterator = DbfEngine.getReader(

        Fp26Reader.class.getResourceAsStream("FP_26_SAMPLE.DBF"), null);

        while (dbfIterator.hasMoreRecords()) {
              DbfRecord dbfRecord = dbfIterator.nextRecord();
              String string = dbfRecord.getString("string");
              float sumFloat = dbfRecord.getFloat("sum_f");
              BigDecimal sumNumeric = dbfRecord.getBigDecimal("sum_n");
              boolean bool = dbfRecord.getBoolean("bool_val");
              Date date = dbfRecord.getDate("date_val");

              System.out.println(string + " " + sumFloat + " " + sumNumeric + " "+ bool + " " + date);
        }
  }

  public static void main(String[] args) {
        Fp26Reader.testRead();
  }

}

2 Comments

I have released 1.05 version of DbfEngine Java API on http://smart-flex.ru. This version allows read xBase .mem files (memory variables files) for Foxpro (and may be Clipper).
I hosted DnfEngine 1.09 at https://github.com/smart-flex/DbfEngine
0

You might also try using Jython along with my python dbf module. It allows for searching (brute force and indexed) as well as pythonic usage patterns. Note: I haven't tested with Jython, but am very responsive to help requests.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.