• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Data from access database according to today date using java  RSS feed

 
Sagar Deshmukh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends got it using below changes



Thanks for your support
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66157
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!