Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help for date in java sql 1

Status
Not open for further replies.

qach238

Programmer
Jun 8, 2003
5
AU
i have a problem
i'm trying to get a statement and i need to be able to compare a date. here the example of my code:

String query = "SELECT * from EVENT WHERE event_date > \'" + eventDate + "\'";

it compiles but does not run... not that eventDate is a String and event_date is a date in MS Access. can anyone help? it's urgent!!
 

When working with dates it is better to use preparedStatements:

PreparedStatement ps=con.prepareStatement("SELECT * from EVENT WHERE event_date > ?");
ps.setDate(1, new Date(2003,06,01));
ps.executeQuery();
 
thanks for the help! i'm sure it will work... BUT
when i compile it i get this error message:

ReportDetailsUI.java:25: reference to Date is ambiguous, both class java.util.Date in java.util and class java.sql.Date in java.sql match

would you by anychance know wat's the problem?
sorry coz i'm quite new to java
 
hey i got it working already don't worry... thanks a lot for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top