• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data type mismatch in criteria expression while using Datetime column

 
Kumanan Guna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using MS-Access db and trying to query from java code. Getting below error when I use datetime column.
I m trying to query all names between mentioned start and end time.

Could you please help me on this ? Tried changing format of datetime in code, but getting same error again.
I could see in access db table, datetime column values stored as "5/7/2013 5:00:00 AM" (this format also giving error).



Exception:




Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider using a PreparedStatement. That way you have:



and


Converting directly from a Java Date object lets the JDBC driver handle the conversion so you don't need to worry about formats.
 
Kumanan Guna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Consider using a PreparedStatement. That way you have:



and


Converting directly from a Java Date object lets the JDBC driver handle the conversion so you don't need to worry about formats.



Its working perfectly when after using preparedStatement. Jeanee Boyarsky, one word "Thanks" is not enough, Thanks a lot... for the solution....
Also i have already replied for Bear PM message twice, after submitting, got a message request in the queue, anything else i need to do?

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumanan Guna wrote:Its working perfectly when after using preparedStatement. Jeanee Boyarsky, one word "Thanks" is not enough, Thanks a lot... for the solution....
Also i have already replied for Bear PM message twice, after submitting, got a message request in the queue, anything else i need to do?

You're welcome. And you are all set!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic