Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
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
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT DBF
Problems with concurrent selects
Fernando Hartmann
2009-09-09 18:33:58.0

In the following sample program we are experiencing a weird problem, when I execute selects reading date fields at the same time (threads) over a table in a computer with 2 or more processors we receive, some times the correct answer, some times a error (bellow) or some times o wrong number of records in the resultset.

package tests;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class TestWithConcurrency {

public static void main(String args[]) throws Exception {
Class.forName("com.hxtt.sql.dbf.DBFDriver");

String sql = "SELECT CASE WHEN datez IS NULL THEN NULL "+
"WHEN MONTH(datez)>11 THEN CDATE('01/12/'+STR(YEAR(datez)),'dd/MM/yyyy') "+
"ELSE CDATE('01/01/'+STR(YEAR(datez)),'dd/MM/yyyy') END AS M11C0 "+
"FROM tst "+
"ORDER BY 1 ASC";

Connection conn = DriverManager.getConnection("jdbc:dbf:/C:/TEMP/");
ConcurrentQuery cq1 = new ConcurrentQuery(conn, 50, sql);
Connection conn2 = DriverManager.getConnection("jdbc:dbf:/C:/TEMP/");
ConcurrentQuery cq2 = new ConcurrentQuery(conn2, 0, sql);
}
}
class ConcurrentQuery implements Runnable {

private Connection conn;
private long sleeping = 0;
private String sql;

public ConcurrentQuery(Connection conn, long sleeping, String sql) {
this.conn = conn;
this.sleeping = sleeping;
this.sql = sql;
Thread t = new Thread(this);
t.start();
}

public void run() {
try{
Thread.sleep(sleeping);
ResultSet rs = conn.createStatement().executeQuery(sql);
writeResult(rs);
rs.close();
}catch (Exception e){
e.printStackTrace();
} finally {
try{
conn.close();
}catch (Exception ex){
ex.printStackTrace();
}
}
}
private void writeResult(ResultSet rs) throws Exception{
int rows = 0;
while (rs.next()) {
rows = rs.getRow();
}
System.out.println("Rows in rs: " + rows );
}
}

Error

java.lang.ArrayIndexOutOfBoundsException: 13
at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:436)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2081)
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2472)
at java.util.Calendar.updateTime(Calendar.java:2468)
at java.util.Calendar.getTimeInMillis(Calendar.java:1087)
at java.util.Calendar.getTime(Calendar.java:1060)
at com.hxtt.global.ah.a(Unknown Source)
at com.hxtt.global.ah.a(Unknown Source)
at com.hxtt.b.b.a(Unknown Source)
at com.hxtt.sql.dbf.i.a(Unknown Source)
at com.hxtt.sql.dbf.i.a(Unknown Source)
at com.hxtt.sql.dbf.i.a(Unknown Source)
at com.hxtt.sql.cq.a(Unknown Source)
at com.hxtt.sql.ej.a(Unknown Source)
at com.hxtt.sql.dl.a(Unknown Source)
at com.hxtt.d.k.a(Unknown Source)
at com.hxtt.d.b.a(Unknown Source)
at com.hxtt.d.k.a(Unknown Source)
at com.hxtt.d.m.a(Unknown Source)
at com.hxtt.d.k.a(Unknown Source)
at com.hxtt.d.d.aN(Unknown Source)
at com.hxtt.d.d.a(Unknown Source)
at com.hxtt.d.k.a(Unknown Source)
at com.hxtt.d.b.a(Unknown Source)
at com.hxtt.d.k.a(Unknown Source)
at com.hxtt.sql.df.a(Unknown Source)
at com.hxtt.sql.cx.new(Unknown Source)
at com.hxtt.sql.cx.next(Unknown Source)
at tests.ConcurrentQuery.writeResult(TestWithConcurrency.java:56)
at tests.ConcurrentQuery.run(TestWithConcurrency.java:42)
at java.lang.Thread.run(Thread.java:619)



Re:Problems with concurrent selects
HXTT Support
2009-09-10 22:24:32.0
Thanks. Please download the latest package, that CDATE function can support multithread now.
Re:Re:Problems with concurrent selects
Fernando Hartmann
2009-09-15 18:20:05.0
It worked, thanks.

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap