dbf CREATE TABLE 抛出 java.sql.SQLException:语法错误:停止解析于
我有一个 dbf 文件,我可以在视图中看到有趣字段的类型是 L (我认为它是逻辑类型)和 M (我认为它是 Memo 类型)
我尝试使用 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 时,一切都很好。
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 查看器打开文件时,我可以看到字母 M 和 L 作为类型短名。
I have a dbf file, and I can see in the view that types of intersting fields are L ( I suppose it is logical type ) and M (I suppose it's a Memo type)
I try 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'm getting the following error:
java.sql.SQLException: Syntax error: Stopped parse at MEMO
java.sql.SQLException: Syntax error: Stopped parse at LOGICAL
The reason - type names, because when I use varchar, everythins is fine.
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 question is which sql type should I use so I could create dbf template using code and when I open a file using dbf viewer I could see letters M and L as type shortnames.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
创建表样本(“
+“SM比特”
+ " PRIM longvarchar" + ")";
用于创建表的 SQL 数据类型位于 http://www.hxtt.com/dbf/sqlsyntax。 html#createtable
create table SAMPLE ( "
+ " SM BIT , "
+ " PRIM longvarchar" + ")";
SQL Data Types for Create Table at http://www.hxtt.com/dbf/sqlsyntax.html#createtable
我找不到 dbf_jdbc 问题的原因。我使用javadbf框架来创建模板。下面的例子说明了这一点:
I could not find the reason of the problem with dbf_jdbc. I used javadbf framework to create a template. The following example illustrates it:
我不知道基于 java 的 dbc 驱动程序,但隐含的缩写版本是分别使用“L”或“M”此外
,对于其他一些类型
I don't know about java based dbc driver, but an implied abbreviated version is to just use "L" or "M" respectively
Additionally for some other types
dBase III 文件支持:
name C(40)
birth D
member L
desc M
类型的第一个字母是您要使用的。
此外,其他 dbf 格式允许:
price Y
(注意Y
,而不是C
)appt T
(注意T
,而非D
)质量 B
(注意B
,而非D
)bin_data G
age I
photo P
Currency、Double、Integer、General 和 Picture 均以二进制形式存储数据,而其他则以文本形式存储数据。
dBase III files support:
name C(40)
birth D
member L
desc M
rate N(6, 2)
The first letter of the type is what you want to use.
Additionally, other dbf formats allow:
price Y
(noteY
, notC
)appt T
(noteT
, notD
)mass B
(noteB
, notD
)bin_data G
age I
photo P
Currency, Double, Integer, General, and Picture all store the data as binary, while the others store the data as text.