wood burning stoves*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

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!
 
Consider Paul's rocket mass heater.
 
subject: Data type mismatch in criteria expression while using Datetime column
 
Similar Threads
Getting error while inserting data into table
Problem with JDBC in Windows 7
error when i run the program
In Access,Oracle8i PE ResultSet is not scrolling
comparing dates in SELECT statment