Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Get Data from access database according to today date using java

 
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

 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • 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
 
Rancher
Posts: 1041
6
  • 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: 1041
6
  • 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
 
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Arthur, where are your pants? Check under this tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic