What isolation level are you using? If you just use read committed isolation level (default in JDBC/Derby) and a read only result set when you iterate, locks should not be kept on the records you have already read.
http://db.apache.org/derby/docs/10.5/devguide/cdevconcepts30291.html Dag