使用dbf_jdbc问题写入dbf文件

发布于 2024-12-27 23:02:30 字数 1111 浏览 1 评论 0原文

执行以下代码后无法重命名文件:

private static final String URL = "jdbc:DBF:/C:\\TEST";
private static final String TABLE = "create table SAMPLE ( "
+ " SM VARCHAR(10), "
+ " PRIM  VARCHAR(10) " + ")"; 

...

Properties properties = new Properties();
properties.setProperty( "charSet", "cp866" );
properties.setProperty( "CODEPAGEID", "66" );

// instantiate it
Class.forName( "com.hxtt.sql.dbf.DBFDriver" ).newInstance();
Connection dbfConn = DriverManager.getConnection( URL, properties );
Statement stmt = dbfConn.createStatement();
stmt.executeUpdate( TABLE );
stmt.close();
PreparedStatement ps = dbfConn.prepareStatement( "INSERT INTO SAMPLE (SM, PRIM) VALUES (?,?);"  );
ps.setString( 1, "test11" );
ps.setString( 2, "test12" );
ps.executeUpdate();
ps.close();
dbfConn.close();
new File( "C:\\TESTarj\\SAMPLE.DBF").renameTo( new File( "C:\\TESTarj\\SAMPLE_renamed.DBF" ) );

如果删除 ps.executeUpdate(); 文件将被重命名。该问题仅在上个13 号星期五出现。以前工作得很好。 dbf_jdbc、Java、tomcat版本未更改。该问题同时出现在多个盒子上。作为解决方法,我可以使用 javadbf,但在我们的情况下它不是最佳选择。

有什么想法可能导致问题吗?

File can not be renamed after the following code execution:

private static final String URL = "jdbc:DBF:/C:\\TEST";
private static final String TABLE = "create table SAMPLE ( "
+ " SM VARCHAR(10), "
+ " PRIM  VARCHAR(10) " + ")"; 

...

Properties properties = new Properties();
properties.setProperty( "charSet", "cp866" );
properties.setProperty( "CODEPAGEID", "66" );

// instantiate it
Class.forName( "com.hxtt.sql.dbf.DBFDriver" ).newInstance();
Connection dbfConn = DriverManager.getConnection( URL, properties );
Statement stmt = dbfConn.createStatement();
stmt.executeUpdate( TABLE );
stmt.close();
PreparedStatement ps = dbfConn.prepareStatement( "INSERT INTO SAMPLE (SM, PRIM) VALUES (?,?);"  );
ps.setString( 1, "test11" );
ps.setString( 2, "test12" );
ps.executeUpdate();
ps.close();
dbfConn.close();
new File( "C:\\TESTarj\\SAMPLE.DBF").renameTo( new File( "C:\\TESTarj\\SAMPLE_renamed.DBF" ) );

If you remove ps.executeUpdate(); file is renamed. The problem appeared only on last Friday the 13th. It worked fine before. dbf_jdbc, Java, tomcat versions have not been changed. The problem appeared on several boxes at the same time. As a workaround I can use javadbf, but it's not the best choice in our case.

Any ideas what may be a cause of problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

故事与诗 2025-01-03 23:02:30
 properties.setProperty( "delayedClose", "0" );

//delayedClose 表示关闭事务的延迟秒数。该选项用于避免后续 SQL 的频繁关闭/打开表操作。当delayedClose<=60s时,自动临时索引被禁用。您可以使用 0~120 秒。默认值:3。

 properties.setProperty( "delayedClose", "0" );

//delayedClose Indicates the delayed seconds for close transaction. That option is used to avoid frequent close/open table operations for following sqls. Automatic temporary index is disabled when delayedClose<=60s. You can use 0~120 seconds. Default: 3.

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