我有一个dbf文件,我可以在视图中看到有趣的字段类型是L(我认为它是逻辑类型)和M(我想它是一个备注类型)
我尝试使用dbf_jdbc重新创建dbf模板,如表:
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);
但是我收到以下错误:
java.sql.SQLException: Syntax error: Stopped parse at MEMO
java.sql.SQLException: Syntax error: Stopped parse at LOGICAL
原因 - 键入名称,因为当我使用varchar时,everythins就可以了。
Dbf_jdbc版本(来自jar清单文件):
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
所以我的问题是我应该使用哪种sql类型,所以我可以使用代码创建dbf模板,当我使用dbf viewer打开文件时,我可以看到字母M和L作为类型短名称。
答案 0 :(得分:2)
创建表SAMPLE(“ +“SM BIT” +“PRIM longvarchar”+“)”;
创建表的SQL数据类型答案 1 :(得分:1)
我找不到dbf_jdbc问题的原因。我使用javadbf框架来创建模板。以下示例说明了它:
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" );
答案 2 :(得分:0)
我不知道基于java的dbc驱动程序,但隐含的缩写版本只是分别使用“L”或“M”
create table SAMPLE ( SM L, PRIM M )";
另外还有一些其他类型
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 )
答案 3 :(得分:0)
dBase III文件支持:
name C(40)
birth D
member L
desc M
rate N(6, 2)
该类型的第一个字母是您想要使用的。
此外,其他dbf格式允许:
price Y
(注意Y
,而不是C
)appt T
(注意T
,而不是D
)mass B
(注意B
,而不是D
)bin_data G
age I
photo P
Currency,Double,Integer,General和Picture都将数据存储为二进制,而其他数据将数据存储为文本。