Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access 7.1.253
  HXTT Cobol 5.0.252
  HXTT DBF 7.1.253
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel 6.1.256
  HXTT Json 1.0.224
  HXTT Paradox 7.1.252
  HXTT PDF 2.0.252
  HXTT Text(CSV) 7.1.252
  HXTT Word 1.1.252
  HXTT XML 4.0.253
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
Changes by other programs are not see when prepared statements are cached
Rob Gansevles
2009-02-24 02:08:36
Hello,

We still have another issue, it seems when changes are made by another client and we are re-using prepared statements (for performance) we do not see the changes.

Sample programs:
1. start DBFTest3a, it creates a test table and sleeps some time
2. during the sleep, run DBFTest3b, it updates the table
after the sleep period the first program still sees the original value unless the prepared statement is closed first.

You may have to change the url to point to an empty directory.

Regards,

Rob

------ sample DBFTest3a -------
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
* Sample program that shows prepared statements cannot be cached (reused) when changes are made outside the jvm.
*
*/
public class DBFTest3a
{
private static final String SELECT_X_FROM_TST = "select x from tst";

public static void main(String[] args) throws Exception
{
String user = "";
String password = "";
String url = "jdbc:dbf:////tmp/dbftest";
String driver = "com.hxtt.sql.dbf.DBFDriver";

Class.forName(driver);

try
{
Connection connection = DriverManager.getConnection(url, user, password);
Statement statement = connection.createStatement();
statement.execute("drop table tst");
statement.close();
connection.close();
}
catch (SQLException e)
{
// table does not exists
}

boolean ok = true;
Connection connection = DriverManager.getConnection(url, user, password);
connection.setAutoCommit(true);

Statement statement = connection.createStatement();
statement.execute("create table tst (x integer)");
statement.close();

statement = connection.createStatement();
statement.executeUpdate("insert into tst (x) values (1)");
statement.close();

connection.close();

connection = DriverManager.getConnection(url, user, password);
connection.setAutoCommit(true);
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

PreparedStatement prepareStatement = null;
ResultSet rs;
prepareStatement = connection.prepareStatement(SELECT_X_FROM_TST);
rs = prepareStatement.executeQuery();
if (rs.next())
{
int x = rs.getInt("x");
if (x != 1)
{
System.out.println("** unexpected initial value, expected 1 retrieved " + x);
ok = false;
}
}
else
{
System.out.println("** missing record");
ok = false;
}
rs.close();
prepareStatement.clearParameters();

//when following line is uncommented it works!
//prepareStatement.close();

int sleep = 15;
System.out.println(" -- sleeping for " + sleep + " seconds, run \"update tst set x = 2\" in another jvm");
Thread.sleep(sleep * 1000);
System.out.println("select updated table");

prepareStatement = connection.prepareStatement(SELECT_X_FROM_TST);

rs = prepareStatement.executeQuery();
if (rs.next())
{
int x = rs.getInt("x");
if (x != 2)
{
System.out.println("** unexpected updated value, expected 2 retrieved " + x);
ok = false;
}
}
else
{
System.out.println("** missing record");
ok = false;
}
rs.close();

prepareStatement.close();
connection.close();

System.out.println(ok ? "OK" : "FAILED");
}
}


------ sample DBFTest3b -------

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
* update test table
*
*/
public class DBFTest3b
{
private static final String UPDATE_TST_SET_X_2 = "update tst set x = 2";

public static void main(String[] args) throws Exception
{
String user = "";
String password = "";
String url = "jdbc:dbf:////tmp/dbftest";
String driver = "com.hxtt.sql.dbf.DBFDriver";

Class.forName(driver);

Connection connection = DriverManager.getConnection(url, user, password);
connection = DriverManager.getConnection(url, user, password);

Statement statement = connection.createStatement();
statement.executeUpdate(UPDATE_TST_SET_X_2);
statement.close();

connection.commit();

connection.close();

System.out.println("updated: " + UPDATE_TST_SET_X_2);
}

}
Re:Changes by other programs are not see when prepared statements are cached
HXTT Support
2009-02-24 02:47:56
>String url = "jdbc:dbf:////tmp/dbftest";
You should use lockType connection property, if you run different programs in different Java VM.
For instance, String url = "jdbc:dbf:////tmp/dbftest?lockType=VFP";
Re:Re:Changes by other programs are not see when prepared statements are cached
HXTT Support
2009-03-11 23:37:39
Please download the latest package.
# v4.2.052 fixed an insert bug on CDX index since v4.2.039.
# v4.2.040 supports EVALUATE(cExpression).
# v4.2.039 solved a CDX multiuser compatibility issue with VFP, which VFP will produce specific duplicated index information sometimes on mulituser mode.
# v4.2.038 fixed a bug on LEFT JOIN, which will return empty result for specific condition.
# v4.2.038 supports TYPE(cExpression) and VARTYPE(expression).
# v4.2.031 fixed a bug for DISTINCT operation, which missed the possible data row when there's deleted row with the same value.
# v4.2.013 fixed a bug on CDX compound format index file, which will sometimes set wrong index node information for specific complicated string index expression on insert operation.

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