Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v6.1
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
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
PreparedStatement and date columns
Andrey P.
2008-03-18 11:42:13
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
Hello!!! Anybody!? Any ideas??
Re:Re:PreparedStatement and date columns
HXTT Support
2008-04-01 20:44:44
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
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap