aspose file tools*
The moose likes JDBC and the fly likes Data type mismatch in criteria expression while using Datetime column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Data type mismatch in criteria expression while using Datetime column" Watch "Data type mismatch in criteria expression while using Datetime column" New topic
Author

Data type mismatch in criteria expression while using Datetime column

Kumanan Guna
Greenhorn

Joined: May 07, 2013
Posts: 9
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

Joined: May 26, 2003
Posts: 30925
    
158

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Kumanan Guna
Greenhorn

Joined: May 07, 2013
Posts: 9
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

Joined: May 26, 2003
Posts: 30925
    
158

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data type mismatch in criteria expression while using Datetime column