I've got a dbf file, and I can tell within the view that kinds of intersting fields are L ( I guess it's logical type ) and M (I guess it is a Memo type)

I attempt to recreate dbf template using dbf_jdbc, like table:

 private static final String TABLE = "create table SAMPLE ( "
          + "   SM Logical, "
          + "   PRIM  MEMO " + ")";
...
String url = "jdbc:DBF:/C:\\TEST";
Connection dbfConn = null;
PreparedStatement ps = null;
...
// instantiate it
Class.forName( "com.hxtt.sql.dbf.DBFDriver" ).newInstance();
dbfConn = DriverManager.getConnection( url, properties );
Statement stmt = dbfConn.createStatement();
stmt.executeUpdate(TABLE);

But i am obtaining the following error:

java.sql.SQLException: Syntax error:  Stopped parse at MEMO
java.sql.SQLException: Syntax error:  Stopped parse at LOGICAL

The main reason - type names, because after i use varchar, everythins is okay.

Dbf_jdbc version (from jar manifest file):

Manifest-Version: 1.0
Created-By: HXTT Version Robot
Main-Class: com.hxtt.sql.admin.Admin

Name: com/hxtt/sql/dbf/
Specification-Title: HXTT DBF JDBC 3.0 Package
Implementation-Title: com.hxtt.sql.dbf
Specification-Version: 4.2.056 on April 01, 2009
Specification-Vendor: Hongxin Technology & Trade Ltd.
Comment: JDBC 3.0 Package for Xbase database
Implementation-Version: 4.2.056 on April 01, 2009
Implementation-Vendor: Hongxin Technology & Trade Ltd.
Implementation-URL: http://www.hxtt.com/dbf.html

Name: com/hxtt/sql/admin/
Specification-Title: HXTT Database Admin
Implementation-Title: com.hxtt.sql.admin
Specification-Vendor: Hongxin Technology & Trade Ltd.
Specification-Version: 0.5 on April 01, 2009
Comment: HXTT Database Admin
Implementation-Version: 0.5 on April 01, 2009
Implementation-Vendor: Hongxin Technology & Trade Ltd.
Implementation-URL: http://www.hxtt.com/dbf/dbadmin.html

So my real question is which sql type must i use and so i could create dbf template using code so when I open personal files using dbf viewer I saw letters M and L as type shortnames.

I possibly could not discover the reason from the trouble with dbf_jdbc. I made use of javadbf framework to produce a template. The next example demonstrates it:

File file = new File( filePathName );
DBFWriter dbfWriter = new DBFWriter( file );
dbfWriter.setCharactersetName( "cp866" );

DBFField[] fields = new DBFField[ 29 ];
fields[ 0 ] = new DBFField();
fields[ 0 ].setDataType( DBFField.FIELD_TYPE_L );
fields[ 0 ].setName( "SM" );
...
fields[ 19 ] = new DBFField();
fields[ 19 ].setDataType( DBFField.FIELD_TYPE_M );
fields[ 19 ].setName( "PRIM" );

create table SAMPLE ( " + " SM BIT , " + " PRIM longvarchar" + ")"

SQL Data Types for Create Table at http://www.hxtt.com/dbf/sqlsyntax.html#createtable

I'm not sure about java based dbc driver, but an implied abbreviated version would be to only use "L" or "M" correspondingly

create table SAMPLE ( SM   L,  PRIM   M )";

Furthermore for many other forms

C(?) = character (?=length of character based field)
I = integer
D = date (only date portion)
T = date/time
B(?) = double(?=decimal precision -- ex: B(3) = up to 3 decimals )

dBase III files support:

  • Char name C(40)
  • Date birth D
  • Logical member L
  • Memo desc M
  • Number rate N(6, 2)

The very first letter from the type is what you would like to make use of.

Furthermore, other dbf formats allow:

  • Currency price Y (note Y, not C)
  • DateTime appt T (note T, not D)
  • Double mass B (note B, not D)
  • Float (just like Number)
  • General bin_data G
  • Integer age I
  • Picture photo P

Currency, Double, Integer, General, and Picture all keep data as binary, as the others keep data as text.