File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Get Data from  access database according to today date using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Get Data from  access database according to today date using java" Watch "Get Data from  access database according to today date using java" New topic
Author

Get Data from access database according to today date using java

Sagar Deshmukh
Ranch Hand

Joined: Dec 16, 2011
Posts: 37
I google this problem didn't get any solution
I want to retrieve data from ms access database according to today date, i have write below program but getting error



Error : Data type mismatch in criteria exception

please help waiting for helpful reply

Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1037
    
  10

You should be using a PreparedStatement ( http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html ) with a java.sql.Date initialized to today using System.currentTimeMillis() when constructing.
Sagar Deshmukh
Ranch Hand

Joined: Dec 16, 2011
Posts: 37
Thanks Richard for reply,
But prepairedStatement is use for update and insert how do i use it for select clause

and i have change d1 = new java.sql.Date(d.getTime()); but still i am getting same error

Really confuse about this date
please help
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
But prepairedStatement is use for update and insert how do i use it for select clause


What does make you think this? A cursory look into the API docs of PreparedStatement (and not prepairedStatement ) reveals:
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
Sagar Deshmukh wrote:
But prepairedStatement is use for update and insert how do i use it for select clause


An excerpt from the tutorial hinted to by Richard goes:


Executing PreparedStatement Objects

As with Statement objects, to execute a PreparedStatement object, call an execute statement: executeQuery if the query returns only one ResultSet (such as a SELECT SQL statement), ...
Sagar Deshmukh
Ranch Hand

Joined: Dec 16, 2011
Posts: 37
Friends got it using below changes



Thanks for your support
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Well, it's good to see that you followed the wise advice that was given to you. Oh wait.... you didn't.

Your code is lesser for it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get Data from access database according to today date using java
 
Similar Threads
Stumped By HashSet
Example 2, page 47 from Beginning Web Services doesn't work
connecting java application to JAVADB database
Help(Client Fails to read from Server)
help me in improving performance of prepared statement