i used hxtt driver for performing dbf operations, so far working well except it takes hours (or maybe days) to execute delete/insert with million datas. In fact i never seen its result because it takes more than 20 hours to perform delete some records of 1800907 datas. So, i don't know, the action finish completely with hours or it just never ending process ?
below i post my code :
import java.util.*;
import java.sql.*;
import java.io.*;
import com.hxtt.sql.*;
public class TestDbf {
Connection connection;
/** Creates a new instance of TestDbf */
public TestDbf(String path) {
Properties prop = new Properties();
prop.setProperty("user", "");
prop.setProperty("OtherExtensions","true");
prop.setProperty("Version Number", "03");
try {
Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance();
connection = DriverManager.getConnection("jdbc:DBF:///"+path, prop);
}
catch(SQLException sqx) {
System.out.println("SQL Error when connecting to database");
sqx.printStackTrace();
}
catch (ClassNotFoundException cfx) {
System.out.println("could ot find HXTT class, make sure the classpath have been defined in your system !");
cfx.printStackTrace();
}
catch(Exception e) {
e.printStackTrace();
}
}
public void createIndex(String tablename, String colname, String idxname) {
try {
Statement stmt = connection.createStatement();
String sqlIndex = "create index "+idxname+" on \""+tablename+"\" ("+colname+")";
boolean isCreated = stmt.execute(sqlIndex);
stmt.close();
}
catch(SQLException sqx) {
sqx.printStackTrace();
}
catch(Exception e) {
e.printStackTrace();
}
}
public void deleteData(String tablename) {
try {
Statement stmt = connection.createStatement();
String sql = "delete from \""+tablename+"\" where exists (select 'x' from pp where trim(wcode)='54' and kdpp =
kdppx)";
boolean isDeletedKdpp1 = stmt.execute(sql);
stmt.close();
}
catch(SQLException sqx) {
sqx.printStackTrace();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] arg) {
TestDbf dbf = new TestDbf("C:\\TestDbf");
dbf.createIndex("71280206.PH8", "kdppx", "KDPPIDX71280206");
dbf.deleteData("71280206.PH8");
}
}
in above code, user just perform creating index and deleting data which involved two tables, pp.dbf (6045 records) and 71280206.PH8 (1800907 records). SQL Statement for delete action is just :
"delete from "71280206.PH8" where exists (select 'x' from pp where trim(wcode)='54' and kdpp = kdppx)".
why this action needs hours or days or hang ? (after it ran 20 hours i closed the application, so i don't know exactly when
the application will finish completely).
regards,
rtery