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
PreparedStatement and date columns
Andrey P.
2008-03-18 11:42:13.0
I am evaluating the driver and came across a curious issue. I execure query using PreparedStatement. Where clause has something like 'date_column BETWEEN ? AND ?' If I enter September 4, 1992 as the first parameter, no records are returned, while September 5, 1992 return records properly. BTW, all records in that column/field are dated between 1994 and 2004. Do you have any idea why it's happening? Thanks!
Re:PreparedStatement and date columns
Andrey P.
2008-04-01 19:52:16.0
Hello!!! Anybody!? Any ideas??
Re:Re:PreparedStatement and date columns
HXTT Support
2008-04-01 20:44:44.0
Sorry for omitting that thread. Failed to recur. Maybe that's an index issue. You can run once "reindex all on thattable", then your issue maybe disappear. I test your issue by the following code.


package test.jdbc.dbf;
import java.net.URL;
import java.sql.*;
import java.util.Properties;

public class testPrepBetween {

public static void main(String argv[]) {
try {
Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance();
String dir = "/dbffiles"; //Change it to yourdbfdir
String url;
if (argv.length < 1)
url = "jdbc:DBF:///" + dir;
else
url = argv[0];

Properties properties = new Properties();
// properties.put("charSet", "Cp860");

Connection con = DriverManager.getConnection(url, properties);
PreparedStatement pstmt;
ResultSet rs;
String colval;
String temp;
ResultSetMetaData resultSetMetaData;
int iNumCols;

String sql;

sql =
"SELECT int1,date1 FROM test WHERE date1 between ? and ? ";

pstmt = con.prepareStatement(sql);

resultSetMetaData = pstmt.getMetaData();
iNumCols = resultSetMetaData.getColumnCount();
for (int j = 1; j <= iNumCols; j++)
System.out.print(resultSetMetaData.getColumnLabel(j) + " ");
System.out.println();

pstmt.setDate(1, new java.sql.Date(92,3,4));
pstmt.setDate(2,new java.sql.Date(System.currentTimeMillis()));

rs = pstmt.executeQuery();

while (rs.next()) {
for (int j = 1; j <= iNumCols; j++) {
colval = rs.getObject(j) + "";
System.out.print(colval + " ");
}
System.out.println();
}
rs.close();


pstmt.close();

con.close();
}
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}

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