You need to alter your query. Something like this:-
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String jdStr = sdf.format(jd);
String jd1Str = sdf.format(jd1);
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement("SELECT date FROM invoice WHERE date >= '" + jdStr + "' AND date <= '" + jd1Str + "'");
Previously, in your query, the 2 parameters, jd
& jd1
were not getting append. This change will now append it in the query. The problem was with the jd & jd1
not correctly being appended in the query.
Note:- I've added a SDF so that you could format your date in format needed and append it to the query.