Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc select query problem on selecting MS-ACCESS date

 
vinod nenmelli seshadri
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi to all,
I am running a calendar servlet downloaded from sourceforge.net which gives an open source calendar servlet which has mysql database as backend for storing events in calendar. But i need to use MS-ACCESS for its backend. I need to convert a date String into a valid jdbc query for selecting events depending on a particular calendar date. I have used MS-ACCESS DATE/TIME datatype and format is "dd-MM-yyyy". My particular code is
String startDate ="12-10-2002"; //dd-MM-yyyy
String sqlQueryString = "SELECT * FROM Events "+ "WHERE Sdate >='" + startDate + "'";
when i run this query the following error occurs...
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
pl do help me soon...
Thanks in advance
 
Sam Moran
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Access, by default, stores dates as m/dd/yy! Be sure not to assemble it as a String! Like this:
ResultSet cntres = stmt.executeQuery("SELECT Count(1) FROM Hdagent WHERE ( STARTTIME > 11/20/02 )");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic