|
Hi, we've recently purchased a license for the DBF driver and it has been working great. Yet, we have encountered an issue and were wondering if you have encountered this same issue before. We're using the hibernate support package for Hibernate version from 5.0 to 5.2.X, with Hibernate 5.2.18 and it seems that after querying Select -> Insert -> Select, the second select returns the same results as the first one. Any help would be greatly appreciated!
|
1st possible occasion:
query it from a connection, insert a row(but is using transaction), not commit.
query it from another connection, can't see it.
package test.jdbc.dbf;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
* Sample program that shows insert statement is not committed when transaction
* isolation is set to TRANSACTION_READ_COMMITTED
*
*/
public class DBFTestTrans1 {
public static void main(String[] args) throws Exception {
String user = "";
String password = "";
String url = "jdbc:dbf:////d:/test/dbf";
String driver = "com.hxtt.sql.dbf.DBFDriver";
Class.forName(driver);
Connection connection = DriverManager.getConnection(url, user, password);
connection.setAutoCommit(true); // when following line is commented out it works!
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Statement statement = connection.createStatement();
if (false) {//init database
statement.execute("drop table if exists tst;create table if not exists tst (x integer);create index a on tst (x)");
// statement.execute("create table if not exists tst (x integer)");
statement.close();
}
ResultSet rs = statement.executeQuery("select recno(),x from tst where x=1");
int count = 0;
while (rs.next()) {
System.out.println(rs.getInt(1));
count++;
}
System.out.println("read " + count + " record(s)");
statement = connection.createStatement();
statement.executeUpdate("insert into tst (x) values (1)");
// connection.commit();
// connection.close();
// connection = DriverManager.getConnection(url, user, password);
rs = statement.executeQuery("select recno(),x from tst where x=1");
count = 0;
while (rs.next()) {
System.out.println(rs.getInt(1));
count++;
}
System.out.println("read " + count + " record(s)");
{
Connection anotherConnection = DriverManager.getConnection(url, user, password);
Statement anotherStatement = anotherConnection.createStatement();
rs = anotherStatement.executeQuery("select recno(),x from tst where x=1");
count = 0;
while (rs.next()) {
System.out.println(rs.getInt(1));
count++;
}
System.out.println("read " + count + " record(s)");
anotherConnection.close();
}
statement.close();
//connection.commit();
connection.close();
}
}
|
Thank you for the quick response! Using direct separate JDBC connections, (that are closed after the query is finished), for the queries, everything works correctly. Yet, if we use hibernate for these operations, the second select returns the same result as the first one. Could you provide a working sample or some assistance with the configuration of hibernate using this driver/dBase?
Thank you once again!
|
|
Please download the latest package. Your issue should disappear.
|