1.) You said "date variable i am taking as Date object ". But you have
- String date= "25-jun-2012";
That is a string not a date.
2.) Don't ever use Statement. Use PreparedStatement instead because
a.)PreparedStatement will cache the compiled query on the database and so will be faster for multiple invocations
b.)PreparedStatement protects against SQL injection.
3.) You should create a java.sql.Date object to set as the parameter in your prepared statement. You change the String to a Date using the SimpleDateFormat class, something like
-
date = new SimpleDateFormat("MM-dd-yyyy").parse("25-06-2012");
-
PreparedStatement ps = connection.prepareStatement(sql); ps.setDate(1, new java.sql.Date(date.getTime()));
-