General discussion

Locked

Java - Date variables and SQL ResultSet

By MK1 ·
I am running an SQL query in my Java program which returns a date variable as part of the resultset. I then try to assign this value to another Date variable and use in a subsequent query but receive error messages in relation to syntax
Some samplecode:
java.util.Date d1 = rs3.getDate(1);

ResultSet rs1 = myDB2.Select2("select * from worksheet where worksheet.work_date = " + d1 + " order by worksheet.work_date");

If anybody has any suggestions I would be most grateful for any assistance

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Java - Date variables and SQL ResultSet

by nikki96 In reply to Java - Date variables and ...

Use java.sql.Date instead of java.util.Date.

This assumes your field was declared as a date type, not a string and that this is not Access. Access needs dates surrounded by pound signs inside queries.

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Forums