Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v6.1
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT DBF
Statement.executeUpdate locks a file
Alexander
2012-01-20 05:47:35.0
Hello,

I've created a detailed question at stackoverflow.com:
stackoverflow.com/questions/8942054/wring-dbf-file-using-dbf-jdbc-issue

Could you please help me with a solution.

Short description:
File can not be renamed after the PreparedStatement.executeUpdate() invocation. It is locked.
Re:Statement.executeUpdate locks a file
HXTT Support
2012-01-20 07:54:49.0
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.
Re:Re:Statement.executeUpdate locks a file
Alexander
2012-01-22 20:28:35.0
If I have thousands of records I may have performance issue with opening/closing stream. Is there any way to set "delayedClose" property to undefined and force closing file when finish working with PreparedStatement? I thought that PreparedStatement.close() does it. But, actually it does not. Is there any alternative way?
Re:Re:Re:Statement.executeUpdate locks a file
HXTT Support
2012-01-22 23:46:17.0
>new File( "C:\\TESTarj\\SAMPLE.DBF").renameTo( new File( "C:\\TESTarj\\SAMPLE_renamed.DBF" ) );
You can use sql: RENAME table SAMPLE to SAMPLE_renamed;

Re:Re:Re:Re:Statement.executeUpdate locks a file
Alexander
2012-01-23 02:40:59.0
I've tried:
PreparedStatement updateTableStatement = dbfConn.prepareStatement( "RENAME table sample to QQQ" );
updateTableStatement.executeUpdate();

But i'm getting exception:
java.sql.SQLException: Failed to acquire table sample: java.lang.InterruptedException: Timeout Interrupted Exception: beyond 1000 msecs. at com.hxtt.concurrent.ae.new(Unknown So...

Also I tried to use:
PreparedStatement updateTableStatement = dbfConn.prepareStatement( "RENAME table sample to ?" );
updateTableStatement.setString( 1, realFileName );
updateTableStatement.executeUpdate();

But got exception with incorrect syntax.
Could you please specify, what am I doing wrong?
Re:Re:Re:Re:Re:Statement.executeUpdate locks a file
HXTT Support
2012-01-23 02:55:44.0
You can use Statement object, PreparedStatement is used for reused object.
Re:Re:Re:Re:Re:Statement.executeUpdate locks a file
HXTT Support
2012-01-23 03:07:32.0
For instance,

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test.jdbc.dbf;

import java.io.File;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Properties;

/**
*
* @author Administrator
*/
public class renameDemo {

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

public static void main(String argv[]) {
try {
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();

stmt.executeUpdate("rename table SAMPLE to SAMPLE_renamed");
stmt.close();
dbfConn.close();
//new File("C:\\TESTarj\\SAMPLE.DBF").renameTo(new File("C:\\TESTarj\\SAMPLE_renamed.DBF"));
}catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}

}
}

Re:Re:Re:Re:Re:Re:Re:Statement.executeUpdate locks a file
Alexander
2012-01-23 03:45:15.0
The reason of the problem I had is the updated name of a table. Actually it consists of digits only. In the example I've used suffix but on a production server it looks like '60343287'. That's why I get Syntax parse error. Could you offer anything for this case?
Re:Re:Re:Re:Re:Re:Re:Statement.executeUpdate locks a file
Alexander
2012-01-23 03:47:28.0
I suppose table name rules should correspond to file system name rules, not to sql name rules, don't they? There is nothing wrong with file name: '4321432.DBF'
Re:Re:Re:Re:Re:Re:Re:Re:Statement.executeUpdate locks a file
HXTT Support
2012-04-07 18:12:12.0
Sorry for missed that thread. a table name, which consists of digits only, can't be accepted by any sql engine. You can use "4321432" or [4321432] .
Re:Re:Re:Re:Re:Re:Re:Re:Statement.executeUpdate locks a file
HXTT Support
2012-04-07 18:12:51.0
For instance, select * FROM '60343287';

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap