You haven't told us what error you are getting. If you tell us what the problem is, then perhaps we can help.
In general, if you use PreparedStatement, then set the parameters using the appropriate methods (setInt(int, int), setString(int, String)), then you will have neater code, and be less likely to encounter these kinds of errors.
Gaurav, I agree with Horatio that you should use PreparedStatement. (You should also try to keep JDBC out of your JSP, but that's another story.) Given that, it is still useful to understand the error because it applies to pure SQL queries too.
Last used is a numeric field. Therefore, it shouldn't have quotes around it. The quotes tell your database that last used is a string. Then it has errors comparing two different types.