dbf CREATE TABLE 抛出 java.sql.SQLException:语法错误:停止解析于

发布于 2024-12-27 14:22:12 字数 1843 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一抹微笑 2025-01-03 14:22:12

创建表样本(“
+“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

帅气尐潴 2025-01-03 14:22:12

我找不到 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" );

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:

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" );
浪推晚风 2025-01-03 14:22:12

我不知道基于 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 )

I don't know about java based dbc driver, but an implied abbreviated version is to just use "L" or "M" respectively

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

Additionally for some other types

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 )
月下伊人醉 2025-01-03 14:22:12

dBase III 文件支持:

  • 字符 name C(40)
  • 日期 birth D
  • 逻辑 member L
  • 备忘录 desc M
  • 数字 < code>rate N(6, 2)

类型的第一个字母是您要使用的。

此外,其他 dbf 格式允许:

  • 货币 price Y(注意 Y,而不是 C
  • DateTime appt T(注意T,而非 D
  • 双倍 质量 B(注意 B,而非 D
  • 浮点型(与数字相同)
  • 常规 bin_data G
  • Integer age I
  • Picture photo P

Currency、Double、Integer、General 和 Picture 均以二进制形式存储数据,而其他则以文本形式存储数据。

dBase III files support:

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

The first letter of the type is what you want to use.

Additionally, 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 (same as Numeric)
  • General bin_data G
  • Integer age I
  • Picture photo P

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文